documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module BABYLON {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export interface ProcessingOptions {
  1191. defines: string[];
  1192. indexParameters: any;
  1193. isFragment: boolean;
  1194. shouldUseHighPrecisionShader: boolean;
  1195. supportsUniformBuffers: boolean;
  1196. shadersRepository: string;
  1197. includesShadersStore: {
  1198. [key: string]: string;
  1199. };
  1200. processor?: IShaderProcessor;
  1201. version: string;
  1202. platformName: string;
  1203. lookForClosingBracketForUniformBuffer?: boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeNode {
  1209. line: string;
  1210. children: ShaderCodeNode[];
  1211. additionalDefineKey?: string;
  1212. additionalDefineValue?: string;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. process(preprocessors: {
  1217. [key: string]: string;
  1218. }, options: ProcessingOptions): string;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeCursor {
  1224. private _lines;
  1225. lineIndex: number;
  1226. get currentLine(): string;
  1227. get canRead(): boolean;
  1228. set lines(value: string[]);
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /** @hidden */
  1253. export class ShaderCodeTestNode extends ShaderCodeNode {
  1254. testExpression: ShaderDefineExpression;
  1255. isValid(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module BABYLON {
  1261. /** @hidden */
  1262. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1263. define: string;
  1264. not: boolean;
  1265. constructor(define: string, not?: boolean);
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1284. leftOperand: ShaderDefineExpression;
  1285. rightOperand: ShaderDefineExpression;
  1286. isTrue(preprocessors: {
  1287. [key: string]: string;
  1288. }): boolean;
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /** @hidden */
  1293. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1294. define: string;
  1295. operand: string;
  1296. testValue: string;
  1297. constructor(define: string, operand: string, testValue: string);
  1298. isTrue(preprocessors: {
  1299. [key: string]: string;
  1300. }): boolean;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * Class used to enable access to offline support
  1306. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1307. */
  1308. export interface IOfflineProvider {
  1309. /**
  1310. * Gets a boolean indicating if scene must be saved in the database
  1311. */
  1312. enableSceneOffline: boolean;
  1313. /**
  1314. * Gets a boolean indicating if textures must be saved in the database
  1315. */
  1316. enableTexturesOffline: boolean;
  1317. /**
  1318. * Open the offline support and make it available
  1319. * @param successCallback defines the callback to call on success
  1320. * @param errorCallback defines the callback to call on error
  1321. */
  1322. open(successCallback: () => void, errorCallback: () => void): void;
  1323. /**
  1324. * Loads an image from the offline support
  1325. * @param url defines the url to load from
  1326. * @param image defines the target DOM image
  1327. */
  1328. loadImage(url: string, image: HTMLImageElement): void;
  1329. /**
  1330. * Loads a file from offline support
  1331. * @param url defines the URL to load from
  1332. * @param sceneLoaded defines a callback to call on success
  1333. * @param progressCallBack defines a callback to call when progress changed
  1334. * @param errorCallback defines a callback to call on error
  1335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1336. */
  1337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1338. }
  1339. }
  1340. declare module BABYLON {
  1341. /**
  1342. * Class used to help managing file picking and drag'n'drop
  1343. * File Storage
  1344. */
  1345. export class FilesInputStore {
  1346. /**
  1347. * List of files ready to be loaded
  1348. */
  1349. static FilesToLoad: {
  1350. [key: string]: File;
  1351. };
  1352. }
  1353. }
  1354. declare module BABYLON {
  1355. /**
  1356. * Class used to define a retry strategy when error happens while loading assets
  1357. */
  1358. export class RetryStrategy {
  1359. /**
  1360. * Function used to defines an exponential back off strategy
  1361. * @param maxRetries defines the maximum number of retries (3 by default)
  1362. * @param baseInterval defines the interval between retries
  1363. * @returns the strategy function to use
  1364. */
  1365. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. /**
  1370. * @ignore
  1371. * Application error to support additional information when loading a file
  1372. */
  1373. export abstract class BaseError extends Error {
  1374. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1375. }
  1376. }
  1377. declare module BABYLON {
  1378. /** @ignore */
  1379. export class LoadFileError extends BaseError {
  1380. request?: WebRequest;
  1381. file?: File;
  1382. /**
  1383. * Creates a new LoadFileError
  1384. * @param message defines the message of the error
  1385. * @param request defines the optional web request
  1386. * @param file defines the optional file
  1387. */
  1388. constructor(message: string, object?: WebRequest | File);
  1389. }
  1390. /** @ignore */
  1391. export class RequestFileError extends BaseError {
  1392. request: WebRequest;
  1393. /**
  1394. * Creates a new LoadFileError
  1395. * @param message defines the message of the error
  1396. * @param request defines the optional web request
  1397. */
  1398. constructor(message: string, request: WebRequest);
  1399. }
  1400. /** @ignore */
  1401. export class ReadFileError extends BaseError {
  1402. file: File;
  1403. /**
  1404. * Creates a new ReadFileError
  1405. * @param message defines the message of the error
  1406. * @param file defines the optional file
  1407. */
  1408. constructor(message: string, file: File);
  1409. }
  1410. /**
  1411. * @hidden
  1412. */
  1413. export class FileTools {
  1414. /**
  1415. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1416. */
  1417. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1418. /**
  1419. * Gets or sets the base URL to use to load assets
  1420. */
  1421. static BaseUrl: string;
  1422. /**
  1423. * Default behaviour for cors in the application.
  1424. * It can be a string if the expected behavior is identical in the entire app.
  1425. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1426. */
  1427. static CorsBehavior: string | ((url: string | string[]) => string);
  1428. /**
  1429. * Gets or sets a function used to pre-process url before using them to load assets
  1430. */
  1431. static PreprocessUrl: (url: string) => string;
  1432. /**
  1433. * Removes unwanted characters from an url
  1434. * @param url defines the url to clean
  1435. * @returns the cleaned url
  1436. */
  1437. private static _CleanUrl;
  1438. /**
  1439. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1440. * @param url define the url we are trying
  1441. * @param element define the dom element where to configure the cors policy
  1442. */
  1443. static SetCorsBehavior(url: string | string[], element: {
  1444. crossOrigin: string | null;
  1445. }): void;
  1446. /**
  1447. * Loads an image as an HTMLImageElement.
  1448. * @param input url string, ArrayBuffer, or Blob to load
  1449. * @param onLoad callback called when the image successfully loads
  1450. * @param onError callback called when the image fails to load
  1451. * @param offlineProvider offline provider for caching
  1452. * @param mimeType optional mime type
  1453. * @returns the HTMLImageElement of the loaded image
  1454. */
  1455. 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>;
  1456. /**
  1457. * Reads a file from a File object
  1458. * @param file defines the file to load
  1459. * @param onSuccess defines the callback to call when data is loaded
  1460. * @param onProgress defines the callback to call during loading process
  1461. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1462. * @param onError defines the callback to call when an error occurs
  1463. * @returns a file request object
  1464. */
  1465. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. */
  1476. 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;
  1477. /**
  1478. * Loads a file
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1483. * @param onError callback called when the file fails to load
  1484. * @param onOpened callback called when the web request is opened
  1485. * @returns a file request object
  1486. */
  1487. 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;
  1488. /**
  1489. * Checks if the loaded document was accessed via `file:`-Protocol.
  1490. * @returns boolean
  1491. */
  1492. static IsFileURL(): boolean;
  1493. }
  1494. }
  1495. declare module BABYLON {
  1496. /** @hidden */
  1497. export class ShaderProcessor {
  1498. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1499. private static _ProcessPrecision;
  1500. private static _ExtractOperation;
  1501. private static _BuildSubExpression;
  1502. private static _BuildExpression;
  1503. private static _MoveCursorWithinIf;
  1504. private static _MoveCursor;
  1505. private static _EvaluatePreProcessors;
  1506. private static _PreparePreProcessors;
  1507. private static _ProcessShaderConversion;
  1508. private static _ProcessIncludes;
  1509. /**
  1510. * Loads a file from a url
  1511. * @param url url to load
  1512. * @param onSuccess callback called when the file successfully loads
  1513. * @param onProgress callback called while file is loading (if the server supports this mode)
  1514. * @param offlineProvider defines the offline provider for caching
  1515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1516. * @param onError callback called when the file fails to load
  1517. * @returns a file request object
  1518. * @hidden
  1519. */
  1520. 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;
  1521. }
  1522. }
  1523. declare module BABYLON {
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IColor4Like {
  1528. r: float;
  1529. g: float;
  1530. b: float;
  1531. a: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IColor3Like {
  1537. r: float;
  1538. g: float;
  1539. b: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector4Like {
  1545. x: float;
  1546. y: float;
  1547. z: float;
  1548. w: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IVector3Like {
  1554. x: float;
  1555. y: float;
  1556. z: float;
  1557. }
  1558. /**
  1559. * @hidden
  1560. */
  1561. export interface IVector2Like {
  1562. x: float;
  1563. y: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IMatrixLike {
  1569. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1570. updateFlag: int;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IViewportLike {
  1576. x: float;
  1577. y: float;
  1578. width: float;
  1579. height: float;
  1580. }
  1581. /**
  1582. * @hidden
  1583. */
  1584. export interface IPlaneLike {
  1585. normal: IVector3Like;
  1586. d: float;
  1587. normalize(): void;
  1588. }
  1589. }
  1590. declare module BABYLON {
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module BABYLON {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module BABYLON {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module BABYLON {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. }
  1895. declare module BABYLON {
  1896. /**
  1897. * Class used to represent a viewport on screen
  1898. */
  1899. export class Viewport {
  1900. /** viewport left coordinate */
  1901. x: number;
  1902. /** viewport top coordinate */
  1903. y: number;
  1904. /**viewport width */
  1905. width: number;
  1906. /** viewport height */
  1907. height: number;
  1908. /**
  1909. * Creates a Viewport object located at (x, y) and sized (width, height)
  1910. * @param x defines viewport left coordinate
  1911. * @param y defines viewport top coordinate
  1912. * @param width defines the viewport width
  1913. * @param height defines the viewport height
  1914. */
  1915. constructor(
  1916. /** viewport left coordinate */
  1917. x: number,
  1918. /** viewport top coordinate */
  1919. y: number,
  1920. /**viewport width */
  1921. width: number,
  1922. /** viewport height */
  1923. height: number);
  1924. /**
  1925. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1926. * @param renderWidth defines the rendering width
  1927. * @param renderHeight defines the rendering height
  1928. * @returns a new Viewport
  1929. */
  1930. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1931. /**
  1932. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1933. * @param renderWidth defines the rendering width
  1934. * @param renderHeight defines the rendering height
  1935. * @param ref defines the target viewport
  1936. * @returns the current viewport
  1937. */
  1938. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1939. /**
  1940. * Returns a new Viewport copied from the current one
  1941. * @returns a new Viewport
  1942. */
  1943. clone(): Viewport;
  1944. }
  1945. }
  1946. declare module BABYLON {
  1947. /**
  1948. * Class containing a set of static utilities functions for arrays.
  1949. */
  1950. export class ArrayTools {
  1951. /**
  1952. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1953. * @param size the number of element to construct and put in the array
  1954. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1955. * @returns a new array filled with new objects
  1956. */
  1957. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1958. }
  1959. }
  1960. declare module BABYLON {
  1961. /**
  1962. * Represents a plane by the equation ax + by + cz + d = 0
  1963. */
  1964. export class Plane {
  1965. private static _TmpMatrix;
  1966. /**
  1967. * Normal of the plane (a,b,c)
  1968. */
  1969. normal: Vector3;
  1970. /**
  1971. * d component of the plane
  1972. */
  1973. d: number;
  1974. /**
  1975. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1976. * @param a a component of the plane
  1977. * @param b b component of the plane
  1978. * @param c c component of the plane
  1979. * @param d d component of the plane
  1980. */
  1981. constructor(a: number, b: number, c: number, d: number);
  1982. /**
  1983. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1984. */
  1985. asArray(): number[];
  1986. /**
  1987. * @returns a new plane copied from the current Plane.
  1988. */
  1989. clone(): Plane;
  1990. /**
  1991. * @returns the string "Plane".
  1992. */
  1993. getClassName(): string;
  1994. /**
  1995. * @returns the Plane hash code.
  1996. */
  1997. getHashCode(): number;
  1998. /**
  1999. * Normalize the current Plane in place.
  2000. * @returns the updated Plane.
  2001. */
  2002. normalize(): Plane;
  2003. /**
  2004. * Applies a transformation the plane and returns the result
  2005. * @param transformation the transformation matrix to be applied to the plane
  2006. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2007. */
  2008. transform(transformation: DeepImmutable<Matrix>): Plane;
  2009. /**
  2010. * Compute the dot product between the point and the plane normal
  2011. * @param point point to calculate the dot product with
  2012. * @returns the dot product (float) of the point coordinates and the plane normal.
  2013. */
  2014. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2015. /**
  2016. * Updates the current Plane from the plane defined by the three given points.
  2017. * @param point1 one of the points used to contruct the plane
  2018. * @param point2 one of the points used to contruct the plane
  2019. * @param point3 one of the points used to contruct the plane
  2020. * @returns the updated Plane.
  2021. */
  2022. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2023. /**
  2024. * Checks if the plane is facing a given direction
  2025. * @param direction the direction to check if the plane is facing
  2026. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2027. * @returns True is the vector "direction" is the same side than the plane normal.
  2028. */
  2029. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2030. /**
  2031. * Calculates the distance to a point
  2032. * @param point point to calculate distance to
  2033. * @returns the signed distance (float) from the given point to the Plane.
  2034. */
  2035. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2036. /**
  2037. * Creates a plane from an array
  2038. * @param array the array to create a plane from
  2039. * @returns a new Plane from the given array.
  2040. */
  2041. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2042. /**
  2043. * Creates a plane from three points
  2044. * @param point1 point used to create the plane
  2045. * @param point2 point used to create the plane
  2046. * @param point3 point used to create the plane
  2047. * @returns a new Plane defined by the three given points.
  2048. */
  2049. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2050. /**
  2051. * Creates a plane from an origin point and a normal
  2052. * @param origin origin of the plane to be constructed
  2053. * @param normal normal of the plane to be constructed
  2054. * @returns a new Plane the normal vector to this plane at the given origin point.
  2055. * Note : the vector "normal" is updated because normalized.
  2056. */
  2057. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2058. /**
  2059. * Calculates the distance from a plane and a point
  2060. * @param origin origin of the plane to be constructed
  2061. * @param normal normal of the plane to be constructed
  2062. * @param point point to calculate distance to
  2063. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2064. */
  2065. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2066. }
  2067. }
  2068. declare module BABYLON {
  2069. /** @hidden */
  2070. export class PerformanceConfigurator {
  2071. /** @hidden */
  2072. static MatrixUse64Bits: boolean;
  2073. /** @hidden */
  2074. static MatrixTrackPrecisionChange: boolean;
  2075. /** @hidden */
  2076. static MatrixCurrentType: any;
  2077. /** @hidden */
  2078. static MatrixTrackedMatrices: Array<any> | null;
  2079. /** @hidden */
  2080. static SetMatrixPrecision(use64bits: boolean): void;
  2081. }
  2082. }
  2083. declare module BABYLON {
  2084. /**
  2085. * Class representing a vector containing 2 coordinates
  2086. */
  2087. export class Vector2 {
  2088. /** defines the first coordinate */
  2089. x: number;
  2090. /** defines the second coordinate */
  2091. y: number;
  2092. /**
  2093. * Creates a new Vector2 from the given x and y coordinates
  2094. * @param x defines the first coordinate
  2095. * @param y defines the second coordinate
  2096. */
  2097. constructor(
  2098. /** defines the first coordinate */
  2099. x?: number,
  2100. /** defines the second coordinate */
  2101. y?: number);
  2102. /**
  2103. * Gets a string with the Vector2 coordinates
  2104. * @returns a string with the Vector2 coordinates
  2105. */
  2106. toString(): string;
  2107. /**
  2108. * Gets class name
  2109. * @returns the string "Vector2"
  2110. */
  2111. getClassName(): string;
  2112. /**
  2113. * Gets current vector hash code
  2114. * @returns the Vector2 hash code as a number
  2115. */
  2116. getHashCode(): number;
  2117. /**
  2118. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2119. * @param array defines the source array
  2120. * @param index defines the offset in source array
  2121. * @returns the current Vector2
  2122. */
  2123. toArray(array: FloatArray, index?: number): Vector2;
  2124. /**
  2125. * Update the current vector from an array
  2126. * @param array defines the destination array
  2127. * @param index defines the offset in the destination array
  2128. * @returns the current Vector3
  2129. */
  2130. fromArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * 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".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Update the current vector from an array
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. fromArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2541. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2542. */
  2543. toQuaternion(): Quaternion;
  2544. /**
  2545. * Adds the given vector to the current Vector3
  2546. * @param otherVector defines the second operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Adds the given coordinates to the current Vector3
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2560. * @param otherVector defines the second operand
  2561. * @returns the resulting Vector3
  2562. */
  2563. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2566. * @param otherVector defines the second operand
  2567. * @param result defines the Vector3 object where to store the result
  2568. * @returns the current Vector3
  2569. */
  2570. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2571. /**
  2572. * Subtract the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2579. * @param otherVector defines the second operand
  2580. * @returns the resulting Vector3
  2581. */
  2582. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2583. /**
  2584. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2585. * @param otherVector defines the second operand
  2586. * @param result defines the Vector3 object where to store the result
  2587. * @returns the current Vector3
  2588. */
  2589. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the resulting Vector3
  2596. */
  2597. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2607. /**
  2608. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2609. * @returns a new Vector3
  2610. */
  2611. negate(): Vector3;
  2612. /**
  2613. * Negate this vector in place
  2614. * @returns this
  2615. */
  2616. negateInPlace(): Vector3;
  2617. /**
  2618. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2619. * @param result defines the Vector3 object where to store the result
  2620. * @returns the current Vector3
  2621. */
  2622. negateToRef(result: Vector3): Vector3;
  2623. /**
  2624. * Multiplies the Vector3 coordinates by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns the current updated Vector3
  2627. */
  2628. scaleInPlace(scale: number): Vector3;
  2629. /**
  2630. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2631. * @param scale defines the multiplier factor
  2632. * @returns a new Vector3
  2633. */
  2634. scale(scale: number): Vector3;
  2635. /**
  2636. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2637. * @param scale defines the multiplier factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the current Vector3
  2640. */
  2641. scaleToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2644. * @param scale defines the scale factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the unmodified current Vector3
  2647. */
  2648. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @returns the projected vector3
  2654. */
  2655. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @param result defines the Vector3 where to store the result
  2661. */
  2662. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2665. * @param otherVector defines the second operand
  2666. * @returns true if both vectors are equals
  2667. */
  2668. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2671. * @param otherVector defines the second operand
  2672. * @param epsilon defines the minimal distance to define values as equals
  2673. * @returns true if both vectors are distant less than epsilon
  2674. */
  2675. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 coordinates equals the given floats
  2678. * @param x defines the x coordinate of the operand
  2679. * @param y defines the y coordinate of the operand
  2680. * @param z defines the z coordinate of the operand
  2681. * @returns true if both vectors are equals
  2682. */
  2683. equalsToFloats(x: number, y: number, z: number): boolean;
  2684. /**
  2685. * Multiplies the current Vector3 coordinates by the given ones
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2692. * @param otherVector defines the second operand
  2693. * @returns the new Vector3
  2694. */
  2695. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2698. * @param otherVector defines the second operand
  2699. * @param result defines the Vector3 object where to store the result
  2700. * @returns the current Vector3
  2701. */
  2702. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the new Vector3
  2709. */
  2710. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2713. * @param otherVector defines the second operand
  2714. * @returns the new Vector3
  2715. */
  2716. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2719. * @param otherVector defines the second operand
  2720. * @param result defines the Vector3 object where to store the result
  2721. * @returns the current Vector3
  2722. */
  2723. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones.
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. divideInPlace(otherVector: Vector3): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2738. * @param other defines the second operand
  2739. * @returns the current updated Vector3
  2740. */
  2741. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2742. /**
  2743. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2744. * @param x defines the x coordinate of the operand
  2745. * @param y defines the y coordinate of the operand
  2746. * @param z defines the z coordinate of the operand
  2747. * @returns the current updated Vector3
  2748. */
  2749. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2750. /**
  2751. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2752. * @param x defines the x coordinate of the operand
  2753. * @param y defines the y coordinate of the operand
  2754. * @param z defines the z coordinate of the operand
  2755. * @returns the current updated Vector3
  2756. */
  2757. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2758. /**
  2759. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2760. * Check if is non uniform within a certain amount of decimal places to account for this
  2761. * @param epsilon the amount the values can differ
  2762. * @returns if the the vector is non uniform to a certain number of decimal places
  2763. */
  2764. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2765. /**
  2766. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2767. */
  2768. get isNonUniform(): boolean;
  2769. /**
  2770. * Gets a new Vector3 from current Vector3 floored values
  2771. * @returns a new Vector3
  2772. */
  2773. floor(): Vector3;
  2774. /**
  2775. * Gets a new Vector3 from current Vector3 floored values
  2776. * @returns a new Vector3
  2777. */
  2778. fract(): Vector3;
  2779. /**
  2780. * Gets the length of the Vector3
  2781. * @returns the length of the Vector3
  2782. */
  2783. length(): number;
  2784. /**
  2785. * Gets the squared length of the Vector3
  2786. * @returns squared length of the Vector3
  2787. */
  2788. lengthSquared(): number;
  2789. /**
  2790. * Normalize the current Vector3.
  2791. * Please note that this is an in place operation.
  2792. * @returns the current updated Vector3
  2793. */
  2794. normalize(): Vector3;
  2795. /**
  2796. * Reorders the x y z properties of the vector in place
  2797. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2798. * @returns the current updated vector
  2799. */
  2800. reorderInPlace(order: string): this;
  2801. /**
  2802. * Rotates the vector around 0,0,0 by a quaternion
  2803. * @param quaternion the rotation quaternion
  2804. * @param result vector to store the result
  2805. * @returns the resulting vector
  2806. */
  2807. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2808. /**
  2809. * Rotates a vector around a given point
  2810. * @param quaternion the rotation quaternion
  2811. * @param point the point to rotate around
  2812. * @param result vector to store the result
  2813. * @returns the resulting vector
  2814. */
  2815. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2816. /**
  2817. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2818. * The cross product is then orthogonal to both current and "other"
  2819. * @param other defines the right operand
  2820. * @returns the cross product
  2821. */
  2822. cross(other: Vector3): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 with the given input length.
  2825. * Please note that this is an in place operation.
  2826. * @param len the length of the vector
  2827. * @returns the current updated Vector3
  2828. */
  2829. normalizeFromLength(len: number): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 to a new vector
  2832. * @returns the new Vector3
  2833. */
  2834. normalizeToNew(): Vector3;
  2835. /**
  2836. * Normalize the current Vector3 to the reference
  2837. * @param reference define the Vector3 to update
  2838. * @returns the updated Vector3
  2839. */
  2840. normalizeToRef(reference: Vector3): Vector3;
  2841. /**
  2842. * Creates a new Vector3 copied from the current Vector3
  2843. * @returns the new Vector3
  2844. */
  2845. clone(): Vector3;
  2846. /**
  2847. * Copies the given vector coordinates to the current Vector3 ones
  2848. * @param source defines the source Vector3
  2849. * @returns the current updated Vector3
  2850. */
  2851. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2852. /**
  2853. * Copies the given floats to the current Vector3 coordinates
  2854. * @param x defines the x coordinate of the operand
  2855. * @param y defines the y coordinate of the operand
  2856. * @param z defines the z coordinate of the operand
  2857. * @returns the current updated Vector3
  2858. */
  2859. copyFromFloats(x: number, y: number, z: number): Vector3;
  2860. /**
  2861. * Copies the given floats to the current Vector3 coordinates
  2862. * @param x defines the x coordinate of the operand
  2863. * @param y defines the y coordinate of the operand
  2864. * @param z defines the z coordinate of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. set(x: number, y: number, z: number): Vector3;
  2868. /**
  2869. * Copies the given float to the current Vector3 coordinates
  2870. * @param v defines the x, y and z coordinates of the operand
  2871. * @returns the current updated Vector3
  2872. */
  2873. setAll(v: number): Vector3;
  2874. /**
  2875. * Get the clip factor between two vectors
  2876. * @param vector0 defines the first operand
  2877. * @param vector1 defines the second operand
  2878. * @param axis defines the axis to use
  2879. * @param size defines the size along the axis
  2880. * @returns the clip factor
  2881. */
  2882. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2883. /**
  2884. * Get angle between two vectors
  2885. * @param vector0 angle between vector0 and vector1
  2886. * @param vector1 angle between vector0 and vector1
  2887. * @param normal direction of the normal
  2888. * @return the angle between vector0 and vector1
  2889. */
  2890. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. */
  2897. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. * @deprecated Please use FromArray instead.
  2904. */
  2905. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. * @deprecated Please use FromArrayToRef instead.
  2919. */
  2920. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2921. /**
  2922. * Sets the given vector "result" with the given floats.
  2923. * @param x defines the x coordinate of the source
  2924. * @param y defines the y coordinate of the source
  2925. * @param z defines the z coordinate of the source
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2931. * @returns a new empty Vector3
  2932. */
  2933. static Zero(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2936. * @returns a new unit Vector3
  2937. */
  2938. static One(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2941. * @returns a new up Vector3
  2942. */
  2943. static Up(): Vector3;
  2944. /**
  2945. * Gets a up Vector3 that must not be updated
  2946. */
  2947. static get UpReadOnly(): DeepImmutable<Vector3>;
  2948. /**
  2949. * Gets a zero Vector3 that must not be updated
  2950. */
  2951. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2952. /**
  2953. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2954. * @returns a new down Vector3
  2955. */
  2956. static Down(): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Forward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2965. * @param rightHandedSystem is the scene right-handed (negative-z)
  2966. * @returns a new forward Vector3
  2967. */
  2968. static Backward(rightHandedSystem?: boolean): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2971. * @returns a new right Vector3
  2972. */
  2973. static Right(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2976. * @returns a new left Vector3
  2977. */
  2978. static Left(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2981. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2982. * @param vector defines the Vector3 to transform
  2983. * @param transformation defines the transformation matrix
  2984. * @returns the transformed Vector3
  2985. */
  2986. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2989. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2990. * @param vector defines the Vector3 to transform
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2997. * This method computes tranformed coordinates only, not transformed direction vectors
  2998. * @param x define the x coordinate of the source vector
  2999. * @param y define the y coordinate of the source vector
  3000. * @param z define the z coordinate of the source vector
  3001. * @param transformation defines the transformation matrix
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3007. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the new Vector3
  3011. */
  3012. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3023. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3033. * @param value1 defines the first control point
  3034. * @param value2 defines the second control point
  3035. * @param value3 defines the third control point
  3036. * @param value4 defines the fourth control point
  3037. * @param amount defines the amount on the spline to use
  3038. * @returns the new Vector3
  3039. */
  3040. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3041. /**
  3042. * 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"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @returns the new Vector3
  3049. */
  3050. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * 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"
  3053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3055. * @param value defines the current value
  3056. * @param min defines the lower range value
  3057. * @param max defines the upper range value
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Checks if a given vector is inside a specific range
  3063. * @param v defines the vector to test
  3064. * @param min defines the minimum range
  3065. * @param max defines the maximum range
  3066. */
  3067. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3070. * @param value1 defines the first control point
  3071. * @param tangent1 defines the first tangent vector
  3072. * @param value2 defines the second control point
  3073. * @param tangent2 defines the second tangent vector
  3074. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3075. * @returns the new Vector3
  3076. */
  3077. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3080. * @param start defines the start value
  3081. * @param end defines the end value
  3082. * @param amount max defines amount between both (between 0 and 1)
  3083. * @returns the new Vector3
  3084. */
  3085. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3086. /**
  3087. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3088. * @param start defines the start value
  3089. * @param end defines the end value
  3090. * @param amount max defines amount between both (between 0 and 1)
  3091. * @param result defines the Vector3 where to store the result
  3092. */
  3093. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3094. /**
  3095. * Returns the dot product (float) between the vectors "left" and "right"
  3096. * @param left defines the left operand
  3097. * @param right defines the right operand
  3098. * @returns the dot product
  3099. */
  3100. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3101. /**
  3102. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3103. * The cross product is then orthogonal to both "left" and "right"
  3104. * @param left defines the left operand
  3105. * @param right defines the right operand
  3106. * @returns the cross product
  3107. */
  3108. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Sets the given vector "result" with the cross product of "left" and "right"
  3111. * The cross product is then orthogonal to both "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3117. /**
  3118. * Returns a new Vector3 as the normalization of the given vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @returns the new Vector3
  3121. */
  3122. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Sets the given vector "result" with the normalization of the given first vector
  3125. * @param vector defines the Vector3 to normalize
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3129. /**
  3130. * Project a Vector3 onto screen space
  3131. * @param vector defines the Vector3 to project
  3132. * @param world defines the world matrix to use
  3133. * @param transform defines the transform (view x projection) matrix to use
  3134. * @param viewport defines the screen viewport to use
  3135. * @returns the new Vector3
  3136. */
  3137. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3138. /**
  3139. * Project a Vector3 onto screen space to reference
  3140. * @param vector defines the Vector3 to project
  3141. * @param world defines the world matrix to use
  3142. * @param transform defines the transform (view x projection) matrix to use
  3143. * @param viewport defines the screen viewport to use
  3144. * @param result the vector in which the screen space will be stored
  3145. * @returns the new Vector3
  3146. */
  3147. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3148. /** @hidden */
  3149. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3150. /**
  3151. * Unproject from screen space to object space
  3152. * @param source defines the screen space Vector3 to use
  3153. * @param viewportWidth defines the current width of the viewport
  3154. * @param viewportHeight defines the current height of the viewport
  3155. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3156. * @param transform defines the transform (view x projection) matrix to use
  3157. * @returns the new Vector3
  3158. */
  3159. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3160. /**
  3161. * Unproject from screen space to object space
  3162. * @param source defines the screen space Vector3 to use
  3163. * @param viewportWidth defines the current width of the viewport
  3164. * @param viewportHeight defines the current height of the viewport
  3165. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3166. * @param view defines the view matrix to use
  3167. * @param projection defines the projection matrix to use
  3168. * @returns the new Vector3
  3169. */
  3170. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3171. /**
  3172. * Unproject from screen space to object space
  3173. * @param source defines the screen space Vector3 to use
  3174. * @param viewportWidth defines the current width of the viewport
  3175. * @param viewportHeight defines the current height of the viewport
  3176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3177. * @param view defines the view matrix to use
  3178. * @param projection defines the projection matrix to use
  3179. * @param result defines the Vector3 where to store the result
  3180. */
  3181. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3182. /**
  3183. * Unproject from screen space to object space
  3184. * @param sourceX defines the screen space x coordinate to use
  3185. * @param sourceY defines the screen space y coordinate to use
  3186. * @param sourceZ defines the screen space z coordinate to use
  3187. * @param viewportWidth defines the current width of the viewport
  3188. * @param viewportHeight defines the current height of the viewport
  3189. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3190. * @param view defines the view matrix to use
  3191. * @param projection defines the projection matrix to use
  3192. * @param result defines the Vector3 where to store the result
  3193. */
  3194. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3195. /**
  3196. * Gets the minimal coordinate values between two Vector3
  3197. * @param left defines the first operand
  3198. * @param right defines the second operand
  3199. * @returns the new Vector3
  3200. */
  3201. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Gets the maximal coordinate values between two Vector3
  3204. * @param left defines the first operand
  3205. * @param right defines the second operand
  3206. * @returns the new Vector3
  3207. */
  3208. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3209. /**
  3210. * Returns the distance between the vectors "value1" and "value2"
  3211. * @param value1 defines the first operand
  3212. * @param value2 defines the second operand
  3213. * @returns the distance
  3214. */
  3215. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3216. /**
  3217. * Returns the squared distance between the vectors "value1" and "value2"
  3218. * @param value1 defines the first operand
  3219. * @param value2 defines the second operand
  3220. * @returns the squared distance
  3221. */
  3222. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3223. /**
  3224. * Returns a new Vector3 located at the center between "value1" and "value2"
  3225. * @param value1 defines the first operand
  3226. * @param value2 defines the second operand
  3227. * @returns the new Vector3
  3228. */
  3229. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3230. /**
  3231. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3232. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3233. * to something in order to rotate it from its local system to the given target system
  3234. * Note: axis1, axis2 and axis3 are normalized during this operation
  3235. * @param axis1 defines the first axis
  3236. * @param axis2 defines the second axis
  3237. * @param axis3 defines the third axis
  3238. * @returns a new Vector3
  3239. */
  3240. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3241. /**
  3242. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3243. * @param axis1 defines the first axis
  3244. * @param axis2 defines the second axis
  3245. * @param axis3 defines the third axis
  3246. * @param ref defines the Vector3 where to store the result
  3247. */
  3248. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3249. }
  3250. /**
  3251. * Vector4 class created for EulerAngle class conversion to Quaternion
  3252. */
  3253. export class Vector4 {
  3254. /** x value of the vector */
  3255. x: number;
  3256. /** y value of the vector */
  3257. y: number;
  3258. /** z value of the vector */
  3259. z: number;
  3260. /** w value of the vector */
  3261. w: number;
  3262. /**
  3263. * Creates a Vector4 object from the given floats.
  3264. * @param x x value of the vector
  3265. * @param y y value of the vector
  3266. * @param z z value of the vector
  3267. * @param w w value of the vector
  3268. */
  3269. constructor(
  3270. /** x value of the vector */
  3271. x: number,
  3272. /** y value of the vector */
  3273. y: number,
  3274. /** z value of the vector */
  3275. z: number,
  3276. /** w value of the vector */
  3277. w: number);
  3278. /**
  3279. * Returns the string with the Vector4 coordinates.
  3280. * @returns a string containing all the vector values
  3281. */
  3282. toString(): string;
  3283. /**
  3284. * Returns the string "Vector4".
  3285. * @returns "Vector4"
  3286. */
  3287. getClassName(): string;
  3288. /**
  3289. * Returns the Vector4 hash code.
  3290. * @returns a unique hash code
  3291. */
  3292. getHashCode(): number;
  3293. /**
  3294. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3295. * @returns the resulting array
  3296. */
  3297. asArray(): number[];
  3298. /**
  3299. * Populates the given array from the given index with the Vector4 coordinates.
  3300. * @param array array to populate
  3301. * @param index index of the array to start at (default: 0)
  3302. * @returns the Vector4.
  3303. */
  3304. toArray(array: FloatArray, index?: number): Vector4;
  3305. /**
  3306. * Update the current vector from an array
  3307. * @param array defines the destination array
  3308. * @param index defines the offset in the destination array
  3309. * @returns the current Vector3
  3310. */
  3311. fromArray(array: FloatArray, index?: number): Vector4;
  3312. /**
  3313. * Adds the given vector to the current Vector4.
  3314. * @param otherVector the vector to add
  3315. * @returns the updated Vector4.
  3316. */
  3317. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3318. /**
  3319. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3320. * @param otherVector the vector to add
  3321. * @returns the resulting vector
  3322. */
  3323. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3324. /**
  3325. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3326. * @param otherVector the vector to add
  3327. * @param result the vector to store the result
  3328. * @returns the current Vector4.
  3329. */
  3330. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3331. /**
  3332. * Subtract in place the given vector from the current Vector4.
  3333. * @param otherVector the vector to subtract
  3334. * @returns the updated Vector4.
  3335. */
  3336. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3337. /**
  3338. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3339. * @param otherVector the vector to add
  3340. * @returns the new vector with the result
  3341. */
  3342. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3345. * @param otherVector the vector to subtract
  3346. * @param result the vector to store the result
  3347. * @returns the current Vector4.
  3348. */
  3349. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. */
  3353. /**
  3354. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3355. * @param x value to subtract
  3356. * @param y value to subtract
  3357. * @param z value to subtract
  3358. * @param w value to subtract
  3359. * @returns new vector containing the result
  3360. */
  3361. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3362. /**
  3363. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3364. * @param x value to subtract
  3365. * @param y value to subtract
  3366. * @param z value to subtract
  3367. * @param w value to subtract
  3368. * @param result the vector to store the result in
  3369. * @returns the current Vector4.
  3370. */
  3371. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3374. * @returns a new vector with the negated values
  3375. */
  3376. negate(): Vector4;
  3377. /**
  3378. * Negate this vector in place
  3379. * @returns this
  3380. */
  3381. negateInPlace(): Vector4;
  3382. /**
  3383. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3384. * @param result defines the Vector3 object where to store the result
  3385. * @returns the current Vector4
  3386. */
  3387. negateToRef(result: Vector4): Vector4;
  3388. /**
  3389. * Multiplies the current Vector4 coordinates by scale (float).
  3390. * @param scale the number to scale with
  3391. * @returns the updated Vector4.
  3392. */
  3393. scaleInPlace(scale: number): Vector4;
  3394. /**
  3395. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3396. * @param scale the number to scale with
  3397. * @returns a new vector with the result
  3398. */
  3399. scale(scale: number): Vector4;
  3400. /**
  3401. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3402. * @param scale the number to scale with
  3403. * @param result a vector to store the result in
  3404. * @returns the current Vector4.
  3405. */
  3406. scaleToRef(scale: number, result: Vector4): Vector4;
  3407. /**
  3408. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3409. * @param scale defines the scale factor
  3410. * @param result defines the Vector4 object where to store the result
  3411. * @returns the unmodified current Vector4
  3412. */
  3413. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3414. /**
  3415. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3416. * @param otherVector the vector to compare against
  3417. * @returns true if they are equal
  3418. */
  3419. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3420. /**
  3421. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3422. * @param otherVector vector to compare against
  3423. * @param epsilon (Default: very small number)
  3424. * @returns true if they are equal
  3425. */
  3426. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3427. /**
  3428. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3429. * @param x x value to compare against
  3430. * @param y y value to compare against
  3431. * @param z z value to compare against
  3432. * @param w w value to compare against
  3433. * @returns true if equal
  3434. */
  3435. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3436. /**
  3437. * Multiplies in place the current Vector4 by the given one.
  3438. * @param otherVector vector to multiple with
  3439. * @returns the updated Vector4.
  3440. */
  3441. multiplyInPlace(otherVector: Vector4): Vector4;
  3442. /**
  3443. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3444. * @param otherVector vector to multiple with
  3445. * @returns resulting new vector
  3446. */
  3447. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3448. /**
  3449. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3450. * @param otherVector vector to multiple with
  3451. * @param result vector to store the result
  3452. * @returns the current Vector4.
  3453. */
  3454. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3455. /**
  3456. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3457. * @param x x value multiply with
  3458. * @param y y value multiply with
  3459. * @param z z value multiply with
  3460. * @param w w value multiply with
  3461. * @returns resulting new vector
  3462. */
  3463. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3464. /**
  3465. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3466. * @param otherVector vector to devide with
  3467. * @returns resulting new vector
  3468. */
  3469. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3470. /**
  3471. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3472. * @param otherVector vector to devide with
  3473. * @param result vector to store the result
  3474. * @returns the current Vector4.
  3475. */
  3476. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3477. /**
  3478. * Divides the current Vector3 coordinates by the given ones.
  3479. * @param otherVector vector to devide with
  3480. * @returns the updated Vector3.
  3481. */
  3482. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3483. /**
  3484. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3485. * @param other defines the second operand
  3486. * @returns the current updated Vector4
  3487. */
  3488. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3489. /**
  3490. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3491. * @param other defines the second operand
  3492. * @returns the current updated Vector4
  3493. */
  3494. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3495. /**
  3496. * Gets a new Vector4 from current Vector4 floored values
  3497. * @returns a new Vector4
  3498. */
  3499. floor(): Vector4;
  3500. /**
  3501. * Gets a new Vector4 from current Vector3 floored values
  3502. * @returns a new Vector4
  3503. */
  3504. fract(): Vector4;
  3505. /**
  3506. * Returns the Vector4 length (float).
  3507. * @returns the length
  3508. */
  3509. length(): number;
  3510. /**
  3511. * Returns the Vector4 squared length (float).
  3512. * @returns the length squared
  3513. */
  3514. lengthSquared(): number;
  3515. /**
  3516. * Normalizes in place the Vector4.
  3517. * @returns the updated Vector4.
  3518. */
  3519. normalize(): Vector4;
  3520. /**
  3521. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3522. * @returns this converted to a new vector3
  3523. */
  3524. toVector3(): Vector3;
  3525. /**
  3526. * Returns a new Vector4 copied from the current one.
  3527. * @returns the new cloned vector
  3528. */
  3529. clone(): Vector4;
  3530. /**
  3531. * Updates the current Vector4 with the given one coordinates.
  3532. * @param source the source vector to copy from
  3533. * @returns the updated Vector4.
  3534. */
  3535. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3536. /**
  3537. * Updates the current Vector4 coordinates with the given floats.
  3538. * @param x float to copy from
  3539. * @param y float to copy from
  3540. * @param z float to copy from
  3541. * @param w float to copy from
  3542. * @returns the updated Vector4.
  3543. */
  3544. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3545. /**
  3546. * Updates the current Vector4 coordinates with the given floats.
  3547. * @param x float to set from
  3548. * @param y float to set from
  3549. * @param z float to set from
  3550. * @param w float to set from
  3551. * @returns the updated Vector4.
  3552. */
  3553. set(x: number, y: number, z: number, w: number): Vector4;
  3554. /**
  3555. * Copies the given float to the current Vector3 coordinates
  3556. * @param v defines the x, y, z and w coordinates of the operand
  3557. * @returns the current updated Vector3
  3558. */
  3559. setAll(v: number): Vector4;
  3560. /**
  3561. * Returns a new Vector4 set from the starting index of the given array.
  3562. * @param array the array to pull values from
  3563. * @param offset the offset into the array to start at
  3564. * @returns the new vector
  3565. */
  3566. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the starting index of the given array.
  3569. * @param array the array to pull values from
  3570. * @param offset the offset into the array to start at
  3571. * @param result the vector to store the result in
  3572. */
  3573. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3574. /**
  3575. * Updates the given vector "result" from the starting index of the given Float32Array.
  3576. * @param array the array to pull values from
  3577. * @param offset the offset into the array to start at
  3578. * @param result the vector to store the result in
  3579. */
  3580. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3581. /**
  3582. * Updates the given vector "result" coordinates from the given floats.
  3583. * @param x float to set from
  3584. * @param y float to set from
  3585. * @param z float to set from
  3586. * @param w float to set from
  3587. * @param result the vector to the floats in
  3588. */
  3589. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3590. /**
  3591. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3592. * @returns the new vector
  3593. */
  3594. static Zero(): Vector4;
  3595. /**
  3596. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3597. * @returns the new vector
  3598. */
  3599. static One(): Vector4;
  3600. /**
  3601. * Returns a new normalized Vector4 from the given one.
  3602. * @param vector the vector to normalize
  3603. * @returns the vector
  3604. */
  3605. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3606. /**
  3607. * Updates the given vector "result" from the normalization of the given one.
  3608. * @param vector the vector to normalize
  3609. * @param result the vector to store the result in
  3610. */
  3611. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3612. /**
  3613. * Returns a vector with the minimum values from the left and right vectors
  3614. * @param left left vector to minimize
  3615. * @param right right vector to minimize
  3616. * @returns a new vector with the minimum of the left and right vector values
  3617. */
  3618. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3619. /**
  3620. * Returns a vector with the maximum values from the left and right vectors
  3621. * @param left left vector to maximize
  3622. * @param right right vector to maximize
  3623. * @returns a new vector with the maximum of the left and right vector values
  3624. */
  3625. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Returns the distance (float) between the vectors "value1" and "value2".
  3628. * @param value1 value to calulate the distance between
  3629. * @param value2 value to calulate the distance between
  3630. * @return the distance between the two vectors
  3631. */
  3632. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3633. /**
  3634. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3635. * @param value1 value to calulate the distance between
  3636. * @param value2 value to calulate the distance between
  3637. * @return the distance between the two vectors squared
  3638. */
  3639. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3640. /**
  3641. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3642. * @param value1 value to calulate the center between
  3643. * @param value2 value to calulate the center between
  3644. * @return the center between the two vectors
  3645. */
  3646. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3647. /**
  3648. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3649. * This methods computes transformed normalized direction vectors only.
  3650. * @param vector the vector to transform
  3651. * @param transformation the transformation matrix to apply
  3652. * @returns the new vector
  3653. */
  3654. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3655. /**
  3656. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3657. * This methods computes transformed normalized direction vectors only.
  3658. * @param vector the vector to transform
  3659. * @param transformation the transformation matrix to apply
  3660. * @param result the vector to store the result in
  3661. */
  3662. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3663. /**
  3664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param x value to transform
  3667. * @param y value to transform
  3668. * @param z value to transform
  3669. * @param w value to transform
  3670. * @param transformation the transformation matrix to apply
  3671. * @param result the vector to store the results in
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3674. /**
  3675. * Creates a new Vector4 from a Vector3
  3676. * @param source defines the source data
  3677. * @param w defines the 4th component (default is 0)
  3678. * @returns a new Vector4
  3679. */
  3680. static FromVector3(source: Vector3, w?: number): Vector4;
  3681. }
  3682. /**
  3683. * Class used to store quaternion data
  3684. * @see https://en.wikipedia.org/wiki/Quaternion
  3685. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3686. */
  3687. export class Quaternion {
  3688. /** @hidden */
  3689. _x: number;
  3690. /** @hidden */
  3691. _y: number;
  3692. /** @hidden */
  3693. _z: number;
  3694. /** @hidden */
  3695. _w: number;
  3696. /** @hidden */
  3697. _isDirty: boolean;
  3698. /** Gets or sets the x coordinate */
  3699. get x(): number;
  3700. set x(value: number);
  3701. /** Gets or sets the y coordinate */
  3702. get y(): number;
  3703. set y(value: number);
  3704. /** Gets or sets the z coordinate */
  3705. get z(): number;
  3706. set z(value: number);
  3707. /** Gets or sets the w coordinate */
  3708. get w(): number;
  3709. set w(value: number);
  3710. /**
  3711. * Creates a new Quaternion from the given floats
  3712. * @param x defines the first component (0 by default)
  3713. * @param y defines the second component (0 by default)
  3714. * @param z defines the third component (0 by default)
  3715. * @param w defines the fourth component (1.0 by default)
  3716. */
  3717. constructor(x?: number, y?: number, z?: number, w?: number);
  3718. /**
  3719. * Gets a string representation for the current quaternion
  3720. * @returns a string with the Quaternion coordinates
  3721. */
  3722. toString(): string;
  3723. /**
  3724. * Gets the class name of the quaternion
  3725. * @returns the string "Quaternion"
  3726. */
  3727. getClassName(): string;
  3728. /**
  3729. * Gets a hash code for this quaternion
  3730. * @returns the quaternion hash code
  3731. */
  3732. getHashCode(): number;
  3733. /**
  3734. * Copy the quaternion to an array
  3735. * @returns a new array populated with 4 elements from the quaternion coordinates
  3736. */
  3737. asArray(): number[];
  3738. /**
  3739. * Check if two quaternions are equals
  3740. * @param otherQuaternion defines the second operand
  3741. * @return true if the current quaternion and the given one coordinates are strictly equals
  3742. */
  3743. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3744. /**
  3745. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3746. * @param otherQuaternion defines the other quaternion
  3747. * @param epsilon defines the minimal distance to consider equality
  3748. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3749. */
  3750. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3751. /**
  3752. * Clone the current quaternion
  3753. * @returns a new quaternion copied from the current one
  3754. */
  3755. clone(): Quaternion;
  3756. /**
  3757. * Copy a quaternion to the current one
  3758. * @param other defines the other quaternion
  3759. * @returns the updated current quaternion
  3760. */
  3761. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3762. /**
  3763. * Updates the current quaternion with the given float coordinates
  3764. * @param x defines the x coordinate
  3765. * @param y defines the y coordinate
  3766. * @param z defines the z coordinate
  3767. * @param w defines the w coordinate
  3768. * @returns the updated current quaternion
  3769. */
  3770. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3771. /**
  3772. * Updates the current quaternion from the given float coordinates
  3773. * @param x defines the x coordinate
  3774. * @param y defines the y coordinate
  3775. * @param z defines the z coordinate
  3776. * @param w defines the w coordinate
  3777. * @returns the updated current quaternion
  3778. */
  3779. set(x: number, y: number, z: number, w: number): Quaternion;
  3780. /**
  3781. * Adds two quaternions
  3782. * @param other defines the second operand
  3783. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3784. */
  3785. add(other: DeepImmutable<Quaternion>): Quaternion;
  3786. /**
  3787. * Add a quaternion to the current one
  3788. * @param other defines the quaternion to add
  3789. * @returns the current quaternion
  3790. */
  3791. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3792. /**
  3793. * Subtract two quaternions
  3794. * @param other defines the second operand
  3795. * @returns a new quaternion as the subtraction result of the given one from the current one
  3796. */
  3797. subtract(other: Quaternion): Quaternion;
  3798. /**
  3799. * Multiplies the current quaternion by a scale factor
  3800. * @param value defines the scale factor
  3801. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3802. */
  3803. scale(value: number): Quaternion;
  3804. /**
  3805. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3806. * @param scale defines the scale factor
  3807. * @param result defines the Quaternion object where to store the result
  3808. * @returns the unmodified current quaternion
  3809. */
  3810. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3811. /**
  3812. * Multiplies in place the current quaternion by a scale factor
  3813. * @param value defines the scale factor
  3814. * @returns the current modified quaternion
  3815. */
  3816. scaleInPlace(value: number): Quaternion;
  3817. /**
  3818. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3819. * @param scale defines the scale factor
  3820. * @param result defines the Quaternion object where to store the result
  3821. * @returns the unmodified current quaternion
  3822. */
  3823. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3824. /**
  3825. * Multiplies two quaternions
  3826. * @param q1 defines the second operand
  3827. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3828. */
  3829. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3830. /**
  3831. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3832. * @param q1 defines the second operand
  3833. * @param result defines the target quaternion
  3834. * @returns the current quaternion
  3835. */
  3836. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3837. /**
  3838. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3839. * @param q1 defines the second operand
  3840. * @returns the currentupdated quaternion
  3841. */
  3842. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3843. /**
  3844. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3845. * @param ref defines the target quaternion
  3846. * @returns the current quaternion
  3847. */
  3848. conjugateToRef(ref: Quaternion): Quaternion;
  3849. /**
  3850. * Conjugates in place (1-q) the current quaternion
  3851. * @returns the current updated quaternion
  3852. */
  3853. conjugateInPlace(): Quaternion;
  3854. /**
  3855. * Conjugates in place (1-q) the current quaternion
  3856. * @returns a new quaternion
  3857. */
  3858. conjugate(): Quaternion;
  3859. /**
  3860. * Gets length of current quaternion
  3861. * @returns the quaternion length (float)
  3862. */
  3863. length(): number;
  3864. /**
  3865. * Normalize in place the current quaternion
  3866. * @returns the current updated quaternion
  3867. */
  3868. normalize(): Quaternion;
  3869. /**
  3870. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3871. * @param order is a reserved parameter and is ignored for now
  3872. * @returns a new Vector3 containing the Euler angles
  3873. */
  3874. toEulerAngles(order?: string): Vector3;
  3875. /**
  3876. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3877. * @param result defines the vector which will be filled with the Euler angles
  3878. * @returns the current unchanged quaternion
  3879. */
  3880. toEulerAnglesToRef(result: Vector3): Quaternion;
  3881. /**
  3882. * Updates the given rotation matrix with the current quaternion values
  3883. * @param result defines the target matrix
  3884. * @returns the current unchanged quaternion
  3885. */
  3886. toRotationMatrix(result: Matrix): Quaternion;
  3887. /**
  3888. * Updates the current quaternion from the given rotation matrix values
  3889. * @param matrix defines the source matrix
  3890. * @returns the current updated quaternion
  3891. */
  3892. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3893. /**
  3894. * Creates a new quaternion from a rotation matrix
  3895. * @param matrix defines the source matrix
  3896. * @returns a new quaternion created from the given rotation matrix values
  3897. */
  3898. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3899. /**
  3900. * Updates the given quaternion with the given rotation matrix values
  3901. * @param matrix defines the source matrix
  3902. * @param result defines the target quaternion
  3903. */
  3904. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3905. /**
  3906. * Returns the dot product (float) between the quaternions "left" and "right"
  3907. * @param left defines the left operand
  3908. * @param right defines the right operand
  3909. * @returns the dot product
  3910. */
  3911. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3912. /**
  3913. * Checks if the two quaternions are close to each other
  3914. * @param quat0 defines the first quaternion to check
  3915. * @param quat1 defines the second quaternion to check
  3916. * @returns true if the two quaternions are close to each other
  3917. */
  3918. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3919. /**
  3920. * Creates an empty quaternion
  3921. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3922. */
  3923. static Zero(): Quaternion;
  3924. /**
  3925. * Inverse a given quaternion
  3926. * @param q defines the source quaternion
  3927. * @returns a new quaternion as the inverted current quaternion
  3928. */
  3929. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3930. /**
  3931. * Inverse a given quaternion
  3932. * @param q defines the source quaternion
  3933. * @param result the quaternion the result will be stored in
  3934. * @returns the result quaternion
  3935. */
  3936. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3937. /**
  3938. * Creates an identity quaternion
  3939. * @returns the identity quaternion
  3940. */
  3941. static Identity(): Quaternion;
  3942. /**
  3943. * Gets a boolean indicating if the given quaternion is identity
  3944. * @param quaternion defines the quaternion to check
  3945. * @returns true if the quaternion is identity
  3946. */
  3947. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3948. /**
  3949. * Creates a quaternion from a rotation around an axis
  3950. * @param axis defines the axis to use
  3951. * @param angle defines the angle to use
  3952. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3953. */
  3954. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3955. /**
  3956. * Creates a rotation around an axis and stores it into the given quaternion
  3957. * @param axis defines the axis to use
  3958. * @param angle defines the angle to use
  3959. * @param result defines the target quaternion
  3960. * @returns the target quaternion
  3961. */
  3962. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3963. /**
  3964. * Creates a new quaternion from data stored into an array
  3965. * @param array defines the data source
  3966. * @param offset defines the offset in the source array where the data starts
  3967. * @returns a new quaternion
  3968. */
  3969. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3970. /**
  3971. * Updates the given quaternion "result" from the starting index of the given array.
  3972. * @param array the array to pull values from
  3973. * @param offset the offset into the array to start at
  3974. * @param result the quaternion to store the result in
  3975. */
  3976. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3977. /**
  3978. * Create a quaternion from Euler rotation angles
  3979. * @param x Pitch
  3980. * @param y Yaw
  3981. * @param z Roll
  3982. * @returns the new Quaternion
  3983. */
  3984. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3985. /**
  3986. * Updates a quaternion from Euler rotation angles
  3987. * @param x Pitch
  3988. * @param y Yaw
  3989. * @param z Roll
  3990. * @param result the quaternion to store the result
  3991. * @returns the updated quaternion
  3992. */
  3993. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3994. /**
  3995. * Create a quaternion from Euler rotation vector
  3996. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3997. * @returns the new Quaternion
  3998. */
  3999. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4000. /**
  4001. * Updates a quaternion from Euler rotation vector
  4002. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4003. * @param result the quaternion to store the result
  4004. * @returns the updated quaternion
  4005. */
  4006. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4007. /**
  4008. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4009. * @param yaw defines the rotation around Y axis
  4010. * @param pitch defines the rotation around X axis
  4011. * @param roll defines the rotation around Z axis
  4012. * @returns the new quaternion
  4013. */
  4014. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4015. /**
  4016. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4017. * @param yaw defines the rotation around Y axis
  4018. * @param pitch defines the rotation around X axis
  4019. * @param roll defines the rotation around Z axis
  4020. * @param result defines the target quaternion
  4021. */
  4022. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4025. * @param alpha defines the rotation around first axis
  4026. * @param beta defines the rotation around second axis
  4027. * @param gamma defines the rotation around third axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4031. /**
  4032. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4033. * @param alpha defines the rotation around first axis
  4034. * @param beta defines the rotation around second axis
  4035. * @param gamma defines the rotation around third axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4039. /**
  4040. * 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)
  4041. * @param axis1 defines the first axis
  4042. * @param axis2 defines the second axis
  4043. * @param axis3 defines the third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4047. /**
  4048. * 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
  4049. * @param axis1 defines the first axis
  4050. * @param axis2 defines the second axis
  4051. * @param axis3 defines the third axis
  4052. * @param ref defines the target quaternion
  4053. */
  4054. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4055. /**
  4056. * Interpolates between two quaternions
  4057. * @param left defines first quaternion
  4058. * @param right defines second quaternion
  4059. * @param amount defines the gradient to use
  4060. * @returns the new interpolated quaternion
  4061. */
  4062. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4063. /**
  4064. * Interpolates between two quaternions and stores it into a target quaternion
  4065. * @param left defines first quaternion
  4066. * @param right defines second quaternion
  4067. * @param amount defines the gradient to use
  4068. * @param result defines the target quaternion
  4069. */
  4070. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4071. /**
  4072. * Interpolate between two quaternions using Hermite interpolation
  4073. * @param value1 defines first quaternion
  4074. * @param tangent1 defines the incoming tangent
  4075. * @param value2 defines second quaternion
  4076. * @param tangent2 defines the outgoing tangent
  4077. * @param amount defines the target quaternion
  4078. * @returns the new interpolated quaternion
  4079. */
  4080. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4081. }
  4082. /**
  4083. * Class used to store matrix data (4x4)
  4084. */
  4085. export class Matrix {
  4086. /**
  4087. * Gets the precision of matrix computations
  4088. */
  4089. static get Use64Bits(): boolean;
  4090. private static _updateFlagSeed;
  4091. private static _identityReadOnly;
  4092. private _isIdentity;
  4093. private _isIdentityDirty;
  4094. private _isIdentity3x2;
  4095. private _isIdentity3x2Dirty;
  4096. /**
  4097. * Gets the update flag of the matrix which is an unique number for the matrix.
  4098. * It will be incremented every time the matrix data change.
  4099. * You can use it to speed the comparison between two versions of the same matrix.
  4100. */
  4101. updateFlag: number;
  4102. private readonly _m;
  4103. /**
  4104. * Gets the internal data of the matrix
  4105. */
  4106. get m(): DeepImmutable<Float32Array | Array<number>>;
  4107. /** @hidden */
  4108. _markAsUpdated(): void;
  4109. /** @hidden */
  4110. private _updateIdentityStatus;
  4111. /**
  4112. * Creates an empty matrix (filled with zeros)
  4113. */
  4114. constructor();
  4115. /**
  4116. * Check if the current matrix is identity
  4117. * @returns true is the matrix is the identity matrix
  4118. */
  4119. isIdentity(): boolean;
  4120. /**
  4121. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4122. * @returns true is the matrix is the identity matrix
  4123. */
  4124. isIdentityAs3x2(): boolean;
  4125. /**
  4126. * Gets the determinant of the matrix
  4127. * @returns the matrix determinant
  4128. */
  4129. determinant(): number;
  4130. /**
  4131. * Returns the matrix as a Float32Array or Array<number>
  4132. * @returns the matrix underlying array
  4133. */
  4134. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4135. /**
  4136. * Returns the matrix as a Float32Array or Array<number>
  4137. * @returns the matrix underlying array.
  4138. */
  4139. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4140. /**
  4141. * Inverts the current matrix in place
  4142. * @returns the current inverted matrix
  4143. */
  4144. invert(): Matrix;
  4145. /**
  4146. * Sets all the matrix elements to zero
  4147. * @returns the current matrix
  4148. */
  4149. reset(): Matrix;
  4150. /**
  4151. * Adds the current matrix with a second one
  4152. * @param other defines the matrix to add
  4153. * @returns a new matrix as the addition of the current matrix and the given one
  4154. */
  4155. add(other: DeepImmutable<Matrix>): Matrix;
  4156. /**
  4157. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4158. * @param other defines the matrix to add
  4159. * @param result defines the target matrix
  4160. * @returns the current matrix
  4161. */
  4162. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4163. /**
  4164. * Adds in place the given matrix to the current matrix
  4165. * @param other defines the second operand
  4166. * @returns the current updated matrix
  4167. */
  4168. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4169. /**
  4170. * Sets the given matrix to the current inverted Matrix
  4171. * @param other defines the target matrix
  4172. * @returns the unmodified current matrix
  4173. */
  4174. invertToRef(other: Matrix): Matrix;
  4175. /**
  4176. * add a value at the specified position in the current Matrix
  4177. * @param index the index of the value within the matrix. between 0 and 15.
  4178. * @param value the value to be added
  4179. * @returns the current updated matrix
  4180. */
  4181. addAtIndex(index: number, value: number): Matrix;
  4182. /**
  4183. * mutiply the specified position in the current Matrix by a value
  4184. * @param index the index of the value within the matrix. between 0 and 15.
  4185. * @param value the value to be added
  4186. * @returns the current updated matrix
  4187. */
  4188. multiplyAtIndex(index: number, value: number): Matrix;
  4189. /**
  4190. * Inserts the translation vector (using 3 floats) in the current matrix
  4191. * @param x defines the 1st component of the translation
  4192. * @param y defines the 2nd component of the translation
  4193. * @param z defines the 3rd component of the translation
  4194. * @returns the current updated matrix
  4195. */
  4196. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4197. /**
  4198. * Adds the translation vector (using 3 floats) in the current matrix
  4199. * @param x defines the 1st component of the translation
  4200. * @param y defines the 2nd component of the translation
  4201. * @param z defines the 3rd component of the translation
  4202. * @returns the current updated matrix
  4203. */
  4204. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector in the current matrix
  4207. * @param vector3 defines the translation to insert
  4208. * @returns the current updated matrix
  4209. */
  4210. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4211. /**
  4212. * Gets the translation value of the current matrix
  4213. * @returns a new Vector3 as the extracted translation from the matrix
  4214. */
  4215. getTranslation(): Vector3;
  4216. /**
  4217. * Fill a Vector3 with the extracted translation from the matrix
  4218. * @param result defines the Vector3 where to store the translation
  4219. * @returns the current matrix
  4220. */
  4221. getTranslationToRef(result: Vector3): Matrix;
  4222. /**
  4223. * Remove rotation and scaling part from the matrix
  4224. * @returns the updated matrix
  4225. */
  4226. removeRotationAndScaling(): Matrix;
  4227. /**
  4228. * Multiply two matrices
  4229. * @param other defines the second operand
  4230. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4231. */
  4232. multiply(other: DeepImmutable<Matrix>): Matrix;
  4233. /**
  4234. * Copy the current matrix from the given one
  4235. * @param other defines the source matrix
  4236. * @returns the current updated matrix
  4237. */
  4238. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4239. /**
  4240. * Populates the given array from the starting index with the current matrix values
  4241. * @param array defines the target array
  4242. * @param offset defines the offset in the target array where to start storing values
  4243. * @returns the current matrix
  4244. */
  4245. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4246. /**
  4247. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4248. * @param other defines the second operand
  4249. * @param result defines the matrix where to store the multiplication
  4250. * @returns the current matrix
  4251. */
  4252. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4253. /**
  4254. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4255. * @param other defines the second operand
  4256. * @param result defines the array where to store the multiplication
  4257. * @param offset defines the offset in the target array where to start storing values
  4258. * @returns the current matrix
  4259. */
  4260. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4261. /**
  4262. * Check equality between this matrix and a second one
  4263. * @param value defines the second matrix to compare
  4264. * @returns true is the current matrix and the given one values are strictly equal
  4265. */
  4266. equals(value: DeepImmutable<Matrix>): boolean;
  4267. /**
  4268. * Clone the current matrix
  4269. * @returns a new matrix from the current matrix
  4270. */
  4271. clone(): Matrix;
  4272. /**
  4273. * Returns the name of the current matrix class
  4274. * @returns the string "Matrix"
  4275. */
  4276. getClassName(): string;
  4277. /**
  4278. * Gets the hash code of the current matrix
  4279. * @returns the hash code
  4280. */
  4281. getHashCode(): number;
  4282. /**
  4283. * Decomposes the current Matrix into a translation, rotation and scaling components
  4284. * @param scale defines the scale vector3 given as a reference to update
  4285. * @param rotation defines the rotation quaternion given as a reference to update
  4286. * @param translation defines the translation vector3 given as a reference to update
  4287. * @returns true if operation was successful
  4288. */
  4289. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4290. /**
  4291. * Gets specific row of the matrix
  4292. * @param index defines the number of the row to get
  4293. * @returns the index-th row of the current matrix as a new Vector4
  4294. */
  4295. getRow(index: number): Nullable<Vector4>;
  4296. /**
  4297. * Sets the index-th row of the current matrix to the vector4 values
  4298. * @param index defines the number of the row to set
  4299. * @param row defines the target vector4
  4300. * @returns the updated current matrix
  4301. */
  4302. setRow(index: number, row: Vector4): Matrix;
  4303. /**
  4304. * Compute the transpose of the matrix
  4305. * @returns the new transposed matrix
  4306. */
  4307. transpose(): Matrix;
  4308. /**
  4309. * Compute the transpose of the matrix and store it in a given matrix
  4310. * @param result defines the target matrix
  4311. * @returns the current matrix
  4312. */
  4313. transposeToRef(result: Matrix): Matrix;
  4314. /**
  4315. * Sets the index-th row of the current matrix with the given 4 x float values
  4316. * @param index defines the row index
  4317. * @param x defines the x component to set
  4318. * @param y defines the y component to set
  4319. * @param z defines the z component to set
  4320. * @param w defines the w component to set
  4321. * @returns the updated current matrix
  4322. */
  4323. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4324. /**
  4325. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4326. * @param scale defines the scale factor
  4327. * @returns a new matrix
  4328. */
  4329. scale(scale: number): Matrix;
  4330. /**
  4331. * Scale the current matrix values by a factor to a given result matrix
  4332. * @param scale defines the scale factor
  4333. * @param result defines the matrix to store the result
  4334. * @returns the current matrix
  4335. */
  4336. scaleToRef(scale: number, result: Matrix): Matrix;
  4337. /**
  4338. * Scale the current matrix values by a factor and add the result to a given matrix
  4339. * @param scale defines the scale factor
  4340. * @param result defines the Matrix to store the result
  4341. * @returns the current matrix
  4342. */
  4343. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4344. /**
  4345. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4346. * @param ref matrix to store the result
  4347. */
  4348. toNormalMatrix(ref: Matrix): void;
  4349. /**
  4350. * Gets only rotation part of the current matrix
  4351. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4352. */
  4353. getRotationMatrix(): Matrix;
  4354. /**
  4355. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4356. * @param result defines the target matrix to store data to
  4357. * @returns the current matrix
  4358. */
  4359. getRotationMatrixToRef(result: Matrix): Matrix;
  4360. /**
  4361. * Toggles model matrix from being right handed to left handed in place and vice versa
  4362. */
  4363. toggleModelMatrixHandInPlace(): void;
  4364. /**
  4365. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4366. */
  4367. toggleProjectionMatrixHandInPlace(): void;
  4368. /**
  4369. * Creates a matrix from an array
  4370. * @param array defines the source array
  4371. * @param offset defines an offset in the source array
  4372. * @returns a new Matrix set from the starting index of the given array
  4373. */
  4374. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4375. /**
  4376. * Copy the content of an array into a given matrix
  4377. * @param array defines the source array
  4378. * @param offset defines an offset in the source array
  4379. * @param result defines the target matrix
  4380. */
  4381. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4382. /**
  4383. * Stores an array into a matrix after having multiplied each component by a given factor
  4384. * @param array defines the source array
  4385. * @param offset defines the offset in the source array
  4386. * @param scale defines the scaling factor
  4387. * @param result defines the target matrix
  4388. */
  4389. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4390. /**
  4391. * Gets an identity matrix that must not be updated
  4392. */
  4393. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4394. /**
  4395. * Stores a list of values (16) inside a given matrix
  4396. * @param initialM11 defines 1st value of 1st row
  4397. * @param initialM12 defines 2nd value of 1st row
  4398. * @param initialM13 defines 3rd value of 1st row
  4399. * @param initialM14 defines 4th value of 1st row
  4400. * @param initialM21 defines 1st value of 2nd row
  4401. * @param initialM22 defines 2nd value of 2nd row
  4402. * @param initialM23 defines 3rd value of 2nd row
  4403. * @param initialM24 defines 4th value of 2nd row
  4404. * @param initialM31 defines 1st value of 3rd row
  4405. * @param initialM32 defines 2nd value of 3rd row
  4406. * @param initialM33 defines 3rd value of 3rd row
  4407. * @param initialM34 defines 4th value of 3rd row
  4408. * @param initialM41 defines 1st value of 4th row
  4409. * @param initialM42 defines 2nd value of 4th row
  4410. * @param initialM43 defines 3rd value of 4th row
  4411. * @param initialM44 defines 4th value of 4th row
  4412. * @param result defines the target matrix
  4413. */
  4414. 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;
  4415. /**
  4416. * Creates new matrix from a list of values (16)
  4417. * @param initialM11 defines 1st value of 1st row
  4418. * @param initialM12 defines 2nd value of 1st row
  4419. * @param initialM13 defines 3rd value of 1st row
  4420. * @param initialM14 defines 4th value of 1st row
  4421. * @param initialM21 defines 1st value of 2nd row
  4422. * @param initialM22 defines 2nd value of 2nd row
  4423. * @param initialM23 defines 3rd value of 2nd row
  4424. * @param initialM24 defines 4th value of 2nd row
  4425. * @param initialM31 defines 1st value of 3rd row
  4426. * @param initialM32 defines 2nd value of 3rd row
  4427. * @param initialM33 defines 3rd value of 3rd row
  4428. * @param initialM34 defines 4th value of 3rd row
  4429. * @param initialM41 defines 1st value of 4th row
  4430. * @param initialM42 defines 2nd value of 4th row
  4431. * @param initialM43 defines 3rd value of 4th row
  4432. * @param initialM44 defines 4th value of 4th row
  4433. * @returns the new matrix
  4434. */
  4435. 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;
  4436. /**
  4437. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4438. * @param scale defines the scale vector3
  4439. * @param rotation defines the rotation quaternion
  4440. * @param translation defines the translation vector3
  4441. * @returns a new matrix
  4442. */
  4443. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4444. /**
  4445. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4446. * @param scale defines the scale vector3
  4447. * @param rotation defines the rotation quaternion
  4448. * @param translation defines the translation vector3
  4449. * @param result defines the target matrix
  4450. */
  4451. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4452. /**
  4453. * Creates a new identity matrix
  4454. * @returns a new identity matrix
  4455. */
  4456. static Identity(): Matrix;
  4457. /**
  4458. * Creates a new identity matrix and stores the result in a given matrix
  4459. * @param result defines the target matrix
  4460. */
  4461. static IdentityToRef(result: Matrix): void;
  4462. /**
  4463. * Creates a new zero matrix
  4464. * @returns a new zero matrix
  4465. */
  4466. static Zero(): Matrix;
  4467. /**
  4468. * Creates a new rotation matrix for "angle" radians around the X axis
  4469. * @param angle defines the angle (in radians) to use
  4470. * @return the new matrix
  4471. */
  4472. static RotationX(angle: number): Matrix;
  4473. /**
  4474. * Creates a new matrix as the invert of a given matrix
  4475. * @param source defines the source matrix
  4476. * @returns the new matrix
  4477. */
  4478. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4479. /**
  4480. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationXToRef(angle: number, result: Matrix): void;
  4485. /**
  4486. * Creates a new rotation matrix for "angle" radians around the Y axis
  4487. * @param angle defines the angle (in radians) to use
  4488. * @return the new matrix
  4489. */
  4490. static RotationY(angle: number): Matrix;
  4491. /**
  4492. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4493. * @param angle defines the angle (in radians) to use
  4494. * @param result defines the target matrix
  4495. */
  4496. static RotationYToRef(angle: number, result: Matrix): void;
  4497. /**
  4498. * Creates a new rotation matrix for "angle" radians around the Z axis
  4499. * @param angle defines the angle (in radians) to use
  4500. * @return the new matrix
  4501. */
  4502. static RotationZ(angle: number): Matrix;
  4503. /**
  4504. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4505. * @param angle defines the angle (in radians) to use
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationZToRef(angle: number, result: Matrix): void;
  4509. /**
  4510. * Creates a new rotation matrix for "angle" radians around the given axis
  4511. * @param axis defines the axis to use
  4512. * @param angle defines the angle (in radians) to use
  4513. * @return the new matrix
  4514. */
  4515. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4516. /**
  4517. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4518. * @param axis defines the axis to use
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4523. /**
  4524. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4525. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4526. * @param from defines the vector to align
  4527. * @param to defines the vector to align to
  4528. * @param result defines the target matrix
  4529. */
  4530. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4531. /**
  4532. * Creates a rotation matrix
  4533. * @param yaw defines the yaw angle in radians (Y axis)
  4534. * @param pitch defines the pitch angle in radians (X axis)
  4535. * @param roll defines the roll angle in radians (Z axis)
  4536. * @returns the new rotation matrix
  4537. */
  4538. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4539. /**
  4540. * Creates a rotation matrix and stores it in a given matrix
  4541. * @param yaw defines the yaw angle in radians (Y axis)
  4542. * @param pitch defines the pitch angle in radians (X axis)
  4543. * @param roll defines the roll angle in radians (Z axis)
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4547. /**
  4548. * Creates a scaling matrix
  4549. * @param x defines the scale factor on X axis
  4550. * @param y defines the scale factor on Y axis
  4551. * @param z defines the scale factor on Z axis
  4552. * @returns the new matrix
  4553. */
  4554. static Scaling(x: number, y: number, z: number): Matrix;
  4555. /**
  4556. * Creates a scaling matrix and stores it in a given matrix
  4557. * @param x defines the scale factor on X axis
  4558. * @param y defines the scale factor on Y axis
  4559. * @param z defines the scale factor on Z axis
  4560. * @param result defines the target matrix
  4561. */
  4562. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4563. /**
  4564. * Creates a translation matrix
  4565. * @param x defines the translation on X axis
  4566. * @param y defines the translation on Y axis
  4567. * @param z defines the translationon Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Translation(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a translation matrix and stores it in a given matrix
  4573. * @param x defines the translation on X axis
  4574. * @param y defines the translation on Y axis
  4575. * @param z defines the translationon Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4581. * @param startValue defines the start value
  4582. * @param endValue defines the end value
  4583. * @param gradient defines the gradient factor
  4584. * @returns the new matrix
  4585. */
  4586. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4587. /**
  4588. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4589. * @param startValue defines the start value
  4590. * @param endValue defines the end value
  4591. * @param gradient defines the gradient factor
  4592. * @param result defines the Matrix object where to store data
  4593. */
  4594. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4595. /**
  4596. * Builds a new matrix whose values are computed by:
  4597. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4598. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4599. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4600. * @param startValue defines the first matrix
  4601. * @param endValue defines the second matrix
  4602. * @param gradient defines the gradient between the two matrices
  4603. * @returns the new matrix
  4604. */
  4605. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4606. /**
  4607. * Update a matrix to values which are computed by:
  4608. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4609. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4610. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4611. * @param startValue defines the first matrix
  4612. * @param endValue defines the second matrix
  4613. * @param gradient defines the gradient between the two matrices
  4614. * @param result defines the target matrix
  4615. */
  4616. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4617. /**
  4618. * 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"
  4619. * This function works in left handed mode
  4620. * @param eye defines the final position of the entity
  4621. * @param target defines where the entity should look at
  4622. * @param up defines the up vector for the entity
  4623. * @returns the new matrix
  4624. */
  4625. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4626. /**
  4627. * 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".
  4628. * This function works in left handed mode
  4629. * @param eye defines the final position of the entity
  4630. * @param target defines where the entity should look at
  4631. * @param up defines the up vector for the entity
  4632. * @param result defines the target matrix
  4633. */
  4634. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4635. /**
  4636. * 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"
  4637. * This function works in right handed mode
  4638. * @param eye defines the final position of the entity
  4639. * @param target defines where the entity should look at
  4640. * @param up defines the up vector for the entity
  4641. * @returns the new matrix
  4642. */
  4643. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4644. /**
  4645. * 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".
  4646. * This function works in right handed mode
  4647. * @param eye defines the final position of the entity
  4648. * @param target defines where the entity should look at
  4649. * @param up defines the up vector for the entity
  4650. * @param result defines the target matrix
  4651. */
  4652. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4653. /**
  4654. * Create a left-handed orthographic projection matrix
  4655. * @param width defines the viewport width
  4656. * @param height defines the viewport height
  4657. * @param znear defines the near clip plane
  4658. * @param zfar defines the far clip plane
  4659. * @returns a new matrix as a left-handed orthographic projection matrix
  4660. */
  4661. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4662. /**
  4663. * Store a left-handed orthographic projection to a given matrix
  4664. * @param width defines the viewport width
  4665. * @param height defines the viewport height
  4666. * @param znear defines the near clip plane
  4667. * @param zfar defines the far clip plane
  4668. * @param result defines the target matrix
  4669. */
  4670. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4671. /**
  4672. * Create a left-handed orthographic projection matrix
  4673. * @param left defines the viewport left coordinate
  4674. * @param right defines the viewport right coordinate
  4675. * @param bottom defines the viewport bottom coordinate
  4676. * @param top defines the viewport top coordinate
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Stores a left-handed orthographic projection into a given matrix
  4684. * @param left defines the viewport left coordinate
  4685. * @param right defines the viewport right coordinate
  4686. * @param bottom defines the viewport bottom coordinate
  4687. * @param top defines the viewport top coordinate
  4688. * @param znear defines the near clip plane
  4689. * @param zfar defines the far clip plane
  4690. * @param result defines the target matrix
  4691. */
  4692. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4693. /**
  4694. * Creates a right-handed orthographic projection matrix
  4695. * @param left defines the viewport left coordinate
  4696. * @param right defines the viewport right coordinate
  4697. * @param bottom defines the viewport bottom coordinate
  4698. * @param top defines the viewport top coordinate
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed orthographic projection matrix
  4702. */
  4703. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed orthographic projection into a given matrix
  4706. * @param left defines the viewport left coordinate
  4707. * @param right defines the viewport right coordinate
  4708. * @param bottom defines the viewport bottom coordinate
  4709. * @param top defines the viewport top coordinate
  4710. * @param znear defines the near clip plane
  4711. * @param zfar defines the far clip plane
  4712. * @param result defines the target matrix
  4713. */
  4714. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4715. /**
  4716. * Creates a left-handed perspective projection matrix
  4717. * @param width defines the viewport width
  4718. * @param height defines the viewport height
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a left-handed perspective projection matrix
  4722. */
  4723. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Creates a left-handed perspective projection matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @returns a new matrix as a left-handed perspective projection matrix
  4731. */
  4732. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4733. /**
  4734. * Stores a left-handed perspective projection into a given matrix
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @param result defines the target matrix
  4740. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4741. */
  4742. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4743. /**
  4744. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4745. * @param fov defines the horizontal field of view
  4746. * @param aspect defines the aspect ratio
  4747. * @param znear defines the near clip plane
  4748. * @param zfar not used as infinity is used as far clip
  4749. * @param result defines the target matrix
  4750. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4751. */
  4752. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4753. /**
  4754. * Creates a right-handed perspective projection matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @returns a new matrix as a right-handed perspective projection matrix
  4760. */
  4761. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4762. /**
  4763. * Stores a right-handed perspective projection into a given matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar defines the far clip plane
  4768. * @param result defines the target matrix
  4769. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4770. */
  4771. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4772. /**
  4773. * Stores a right-handed perspective projection into a given matrix
  4774. * @param fov defines the horizontal field of view
  4775. * @param aspect defines the aspect ratio
  4776. * @param znear defines the near clip plane
  4777. * @param zfar not used as infinity is used as far clip
  4778. * @param result defines the target matrix
  4779. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4780. */
  4781. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4782. /**
  4783. * Stores a perspective projection for WebVR info a given matrix
  4784. * @param fov defines the field of view
  4785. * @param znear defines the near clip plane
  4786. * @param zfar defines the far clip plane
  4787. * @param result defines the target matrix
  4788. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4789. */
  4790. static PerspectiveFovWebVRToRef(fov: {
  4791. upDegrees: number;
  4792. downDegrees: number;
  4793. leftDegrees: number;
  4794. rightDegrees: number;
  4795. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4796. /**
  4797. * Computes a complete transformation matrix
  4798. * @param viewport defines the viewport to use
  4799. * @param world defines the world matrix
  4800. * @param view defines the view matrix
  4801. * @param projection defines the projection matrix
  4802. * @param zmin defines the near clip plane
  4803. * @param zmax defines the far clip plane
  4804. * @returns the transformation matrix
  4805. */
  4806. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4807. /**
  4808. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4809. * @param matrix defines the matrix to use
  4810. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4811. */
  4812. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4813. /**
  4814. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4815. * @param matrix defines the matrix to use
  4816. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4817. */
  4818. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4819. /**
  4820. * Compute the transpose of a given matrix
  4821. * @param matrix defines the matrix to transpose
  4822. * @returns the new matrix
  4823. */
  4824. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4825. /**
  4826. * Compute the transpose of a matrix and store it in a target matrix
  4827. * @param matrix defines the matrix to transpose
  4828. * @param result defines the target matrix
  4829. */
  4830. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4831. /**
  4832. * Computes a reflection matrix from a plane
  4833. * @param plane defines the reflection plane
  4834. * @returns a new matrix
  4835. */
  4836. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4837. /**
  4838. * Computes a reflection matrix from a plane
  4839. * @param plane defines the reflection plane
  4840. * @param result defines the target matrix
  4841. */
  4842. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4843. /**
  4844. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4845. * @param xaxis defines the value of the 1st axis
  4846. * @param yaxis defines the value of the 2nd axis
  4847. * @param zaxis defines the value of the 3rd axis
  4848. * @param result defines the target matrix
  4849. */
  4850. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4851. /**
  4852. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4853. * @param quat defines the quaternion to use
  4854. * @param result defines the target matrix
  4855. */
  4856. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4857. }
  4858. /**
  4859. * @hidden
  4860. */
  4861. export class TmpVectors {
  4862. static Vector2: Vector2[];
  4863. static Vector3: Vector3[];
  4864. static Vector4: Vector4[];
  4865. static Quaternion: Quaternion[];
  4866. static Matrix: Matrix[];
  4867. }
  4868. }
  4869. declare module BABYLON {
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * 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.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * 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)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @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
  5158. * @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
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module BABYLON {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module BABYLON {
  5516. /**
  5517. * Class used to hold a RBG color
  5518. */
  5519. export class Color3 {
  5520. /**
  5521. * Defines the red component (between 0 and 1, default is 0)
  5522. */
  5523. r: number;
  5524. /**
  5525. * Defines the green component (between 0 and 1, default is 0)
  5526. */
  5527. g: number;
  5528. /**
  5529. * Defines the blue component (between 0 and 1, default is 0)
  5530. */
  5531. b: number;
  5532. /**
  5533. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5534. * @param r defines the red component (between 0 and 1, default is 0)
  5535. * @param g defines the green component (between 0 and 1, default is 0)
  5536. * @param b defines the blue component (between 0 and 1, default is 0)
  5537. */
  5538. constructor(
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r?: number,
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g?: number,
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b?: number);
  5551. /**
  5552. * Creates a string with the Color3 current values
  5553. * @returns the string representation of the Color3 object
  5554. */
  5555. toString(): string;
  5556. /**
  5557. * Returns the string "Color3"
  5558. * @returns "Color3"
  5559. */
  5560. getClassName(): string;
  5561. /**
  5562. * Compute the Color3 hash code
  5563. * @returns an unique number that can be used to hash Color3 objects
  5564. */
  5565. getHashCode(): number;
  5566. /**
  5567. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5568. * @param array defines the array where to store the r,g,b components
  5569. * @param index defines an optional index in the target array to define where to start storing values
  5570. * @returns the current Color3 object
  5571. */
  5572. toArray(array: FloatArray, index?: number): Color3;
  5573. /**
  5574. * Update the current color with values stored in an array from the starting index of the given array
  5575. * @param array defines the source array
  5576. * @param offset defines an offset in the source array
  5577. * @returns the current Color3 object
  5578. */
  5579. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5580. /**
  5581. * Returns a new Color4 object from the current Color3 and the given alpha
  5582. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5583. * @returns a new Color4 object
  5584. */
  5585. toColor4(alpha?: number): Color4;
  5586. /**
  5587. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5588. * @returns the new array
  5589. */
  5590. asArray(): number[];
  5591. /**
  5592. * Returns the luminance value
  5593. * @returns a float value
  5594. */
  5595. toLuminance(): number;
  5596. /**
  5597. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5598. * @param otherColor defines the second operand
  5599. * @returns the new Color3 object
  5600. */
  5601. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5602. /**
  5603. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5604. * @param otherColor defines the second operand
  5605. * @param result defines the Color3 object where to store the result
  5606. * @returns the current Color3
  5607. */
  5608. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5609. /**
  5610. * Determines equality between Color3 objects
  5611. * @param otherColor defines the second operand
  5612. * @returns true if the rgb values are equal to the given ones
  5613. */
  5614. equals(otherColor: DeepImmutable<Color3>): boolean;
  5615. /**
  5616. * Determines equality between the current Color3 object and a set of r,b,g values
  5617. * @param r defines the red component to check
  5618. * @param g defines the green component to check
  5619. * @param b defines the blue component to check
  5620. * @returns true if the rgb values are equal to the given ones
  5621. */
  5622. equalsFloats(r: number, g: number, b: number): boolean;
  5623. /**
  5624. * Multiplies in place each rgb value by scale
  5625. * @param scale defines the scaling factor
  5626. * @returns the updated Color3
  5627. */
  5628. scale(scale: number): Color3;
  5629. /**
  5630. * Multiplies the rgb values by scale and stores the result into "result"
  5631. * @param scale defines the scaling factor
  5632. * @param result defines the Color3 object where to store the result
  5633. * @returns the unmodified current Color3
  5634. */
  5635. scaleToRef(scale: number, result: Color3): Color3;
  5636. /**
  5637. * Scale the current Color3 values by a factor and add the result to a given Color3
  5638. * @param scale defines the scale factor
  5639. * @param result defines color to store the result into
  5640. * @returns the unmodified current Color3
  5641. */
  5642. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5643. /**
  5644. * Clamps the rgb values by the min and max values and stores the result into "result"
  5645. * @param min defines minimum clamping value (default is 0)
  5646. * @param max defines maximum clamping value (default is 1)
  5647. * @param result defines color to store the result into
  5648. * @returns the original Color3
  5649. */
  5650. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5651. /**
  5652. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5653. * @param otherColor defines the second operand
  5654. * @returns the new Color3
  5655. */
  5656. add(otherColor: DeepImmutable<Color3>): Color3;
  5657. /**
  5658. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5659. * @param otherColor defines the second operand
  5660. * @param result defines Color3 object to store the result into
  5661. * @returns the unmodified current Color3
  5662. */
  5663. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5664. /**
  5665. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5666. * @param otherColor defines the second operand
  5667. * @returns the new Color3
  5668. */
  5669. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5670. /**
  5671. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5672. * @param otherColor defines the second operand
  5673. * @param result defines Color3 object to store the result into
  5674. * @returns the unmodified current Color3
  5675. */
  5676. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5677. /**
  5678. * Copy the current object
  5679. * @returns a new Color3 copied the current one
  5680. */
  5681. clone(): Color3;
  5682. /**
  5683. * Copies the rgb values from the source in the current Color3
  5684. * @param source defines the source Color3 object
  5685. * @returns the updated Color3 object
  5686. */
  5687. copyFrom(source: DeepImmutable<Color3>): Color3;
  5688. /**
  5689. * Updates the Color3 rgb values from the given floats
  5690. * @param r defines the red component to read from
  5691. * @param g defines the green component to read from
  5692. * @param b defines the blue component to read from
  5693. * @returns the current Color3 object
  5694. */
  5695. copyFromFloats(r: number, g: number, b: number): Color3;
  5696. /**
  5697. * Updates the Color3 rgb values from the given floats
  5698. * @param r defines the red component to read from
  5699. * @param g defines the green component to read from
  5700. * @param b defines the blue component to read from
  5701. * @returns the current Color3 object
  5702. */
  5703. set(r: number, g: number, b: number): Color3;
  5704. /**
  5705. * Compute the Color3 hexadecimal code as a string
  5706. * @returns a string containing the hexadecimal representation of the Color3 object
  5707. */
  5708. toHexString(): string;
  5709. /**
  5710. * Computes a new Color3 converted from the current one to linear space
  5711. * @returns a new Color3 object
  5712. */
  5713. toLinearSpace(): Color3;
  5714. /**
  5715. * Converts current color in rgb space to HSV values
  5716. * @returns a new color3 representing the HSV values
  5717. */
  5718. toHSV(): Color3;
  5719. /**
  5720. * Converts current color in rgb space to HSV values
  5721. * @param result defines the Color3 where to store the HSV values
  5722. */
  5723. toHSVToRef(result: Color3): void;
  5724. /**
  5725. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5726. * @param convertedColor defines the Color3 object where to store the linear space version
  5727. * @returns the unmodified Color3
  5728. */
  5729. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5730. /**
  5731. * Computes a new Color3 converted from the current one to gamma space
  5732. * @returns a new Color3 object
  5733. */
  5734. toGammaSpace(): Color3;
  5735. /**
  5736. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5737. * @param convertedColor defines the Color3 object where to store the gamma space version
  5738. * @returns the unmodified Color3
  5739. */
  5740. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5741. private static _BlackReadOnly;
  5742. /**
  5743. * Convert Hue, saturation and value to a Color3 (RGB)
  5744. * @param hue defines the hue
  5745. * @param saturation defines the saturation
  5746. * @param value defines the value
  5747. * @param result defines the Color3 where to store the RGB values
  5748. */
  5749. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5750. /**
  5751. * Creates a new Color3 from the string containing valid hexadecimal values
  5752. * @param hex defines a string containing valid hexadecimal values
  5753. * @returns a new Color3 object
  5754. */
  5755. static FromHexString(hex: string): Color3;
  5756. /**
  5757. * Creates a new Color3 from the starting index of the given array
  5758. * @param array defines the source array
  5759. * @param offset defines an offset in the source array
  5760. * @returns a new Color3 object
  5761. */
  5762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5763. /**
  5764. * Creates a new Color3 from the starting index element of the given array
  5765. * @param array defines the source array to read from
  5766. * @param offset defines the offset in the source array
  5767. * @param result defines the target Color3 object
  5768. */
  5769. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5770. /**
  5771. * Creates a new Color3 from integer values (< 256)
  5772. * @param r defines the red component to read from (value between 0 and 255)
  5773. * @param g defines the green component to read from (value between 0 and 255)
  5774. * @param b defines the blue component to read from (value between 0 and 255)
  5775. * @returns a new Color3 object
  5776. */
  5777. static FromInts(r: number, g: number, b: number): Color3;
  5778. /**
  5779. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5780. * @param start defines the start Color3 value
  5781. * @param end defines the end Color3 value
  5782. * @param amount defines the gradient value between start and end
  5783. * @returns a new Color3 object
  5784. */
  5785. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5786. /**
  5787. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5788. * @param left defines the start value
  5789. * @param right defines the end value
  5790. * @param amount defines the gradient factor
  5791. * @param result defines the Color3 object where to store the result
  5792. */
  5793. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5794. /**
  5795. * Returns a Color3 value containing a red color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Red(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a green color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Green(): Color3;
  5804. /**
  5805. * Returns a Color3 value containing a blue color
  5806. * @returns a new Color3 object
  5807. */
  5808. static Blue(): Color3;
  5809. /**
  5810. * Returns a Color3 value containing a black color
  5811. * @returns a new Color3 object
  5812. */
  5813. static Black(): Color3;
  5814. /**
  5815. * Gets a Color3 value containing a black color that must not be updated
  5816. */
  5817. static get BlackReadOnly(): DeepImmutable<Color3>;
  5818. /**
  5819. * Returns a Color3 value containing a white color
  5820. * @returns a new Color3 object
  5821. */
  5822. static White(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a purple color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Purple(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a magenta color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Magenta(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a yellow color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Yellow(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a gray color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Gray(): Color3;
  5843. /**
  5844. * Returns a Color3 value containing a teal color
  5845. * @returns a new Color3 object
  5846. */
  5847. static Teal(): Color3;
  5848. /**
  5849. * Returns a Color3 value containing a random color
  5850. * @returns a new Color3 object
  5851. */
  5852. static Random(): Color3;
  5853. }
  5854. /**
  5855. * Class used to hold a RBGA color
  5856. */
  5857. export class Color4 {
  5858. /**
  5859. * Defines the red component (between 0 and 1, default is 0)
  5860. */
  5861. r: number;
  5862. /**
  5863. * Defines the green component (between 0 and 1, default is 0)
  5864. */
  5865. g: number;
  5866. /**
  5867. * Defines the blue component (between 0 and 1, default is 0)
  5868. */
  5869. b: number;
  5870. /**
  5871. * Defines the alpha component (between 0 and 1, default is 1)
  5872. */
  5873. a: number;
  5874. /**
  5875. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5876. * @param r defines the red component (between 0 and 1, default is 0)
  5877. * @param g defines the green component (between 0 and 1, default is 0)
  5878. * @param b defines the blue component (between 0 and 1, default is 0)
  5879. * @param a defines the alpha component (between 0 and 1, default is 1)
  5880. */
  5881. constructor(
  5882. /**
  5883. * Defines the red component (between 0 and 1, default is 0)
  5884. */
  5885. r?: number,
  5886. /**
  5887. * Defines the green component (between 0 and 1, default is 0)
  5888. */
  5889. g?: number,
  5890. /**
  5891. * Defines the blue component (between 0 and 1, default is 0)
  5892. */
  5893. b?: number,
  5894. /**
  5895. * Defines the alpha component (between 0 and 1, default is 1)
  5896. */
  5897. a?: number);
  5898. /**
  5899. * Adds in place the given Color4 values to the current Color4 object
  5900. * @param right defines the second operand
  5901. * @returns the current updated Color4 object
  5902. */
  5903. addInPlace(right: DeepImmutable<Color4>): Color4;
  5904. /**
  5905. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5906. * @returns the new array
  5907. */
  5908. asArray(): number[];
  5909. /**
  5910. * Stores from the starting index in the given array the Color4 successive values
  5911. * @param array defines the array where to store the r,g,b components
  5912. * @param index defines an optional index in the target array to define where to start storing values
  5913. * @returns the current Color4 object
  5914. */
  5915. toArray(array: number[], index?: number): Color4;
  5916. /**
  5917. * Update the current color with values stored in an array from the starting index of the given array
  5918. * @param array defines the source array
  5919. * @param offset defines an offset in the source array
  5920. * @returns the current Color4 object
  5921. */
  5922. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5923. /**
  5924. * Determines equality between Color4 objects
  5925. * @param otherColor defines the second operand
  5926. * @returns true if the rgba values are equal to the given ones
  5927. */
  5928. equals(otherColor: DeepImmutable<Color4>): boolean;
  5929. /**
  5930. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5931. * @param right defines the second operand
  5932. * @returns a new Color4 object
  5933. */
  5934. add(right: DeepImmutable<Color4>): Color4;
  5935. /**
  5936. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5937. * @param right defines the second operand
  5938. * @returns a new Color4 object
  5939. */
  5940. subtract(right: DeepImmutable<Color4>): Color4;
  5941. /**
  5942. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5943. * @param right defines the second operand
  5944. * @param result defines the Color4 object where to store the result
  5945. * @returns the current Color4 object
  5946. */
  5947. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5948. /**
  5949. * Creates a new Color4 with the current Color4 values multiplied by scale
  5950. * @param scale defines the scaling factor to apply
  5951. * @returns a new Color4 object
  5952. */
  5953. scale(scale: number): Color4;
  5954. /**
  5955. * Multiplies the current Color4 values by scale and stores the result in "result"
  5956. * @param scale defines the scaling factor to apply
  5957. * @param result defines the Color4 object where to store the result
  5958. * @returns the current unmodified Color4
  5959. */
  5960. scaleToRef(scale: number, result: Color4): Color4;
  5961. /**
  5962. * Scale the current Color4 values by a factor and add the result to a given Color4
  5963. * @param scale defines the scale factor
  5964. * @param result defines the Color4 object where to store the result
  5965. * @returns the unmodified current Color4
  5966. */
  5967. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5968. /**
  5969. * Clamps the rgb values by the min and max values and stores the result into "result"
  5970. * @param min defines minimum clamping value (default is 0)
  5971. * @param max defines maximum clamping value (default is 1)
  5972. * @param result defines color to store the result into.
  5973. * @returns the cuurent Color4
  5974. */
  5975. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5976. /**
  5977. * Multipy an Color4 value by another and return a new Color4 object
  5978. * @param color defines the Color4 value to multiply by
  5979. * @returns a new Color4 object
  5980. */
  5981. multiply(color: Color4): Color4;
  5982. /**
  5983. * Multipy a Color4 value by another and push the result in a reference value
  5984. * @param color defines the Color4 value to multiply by
  5985. * @param result defines the Color4 to fill the result in
  5986. * @returns the result Color4
  5987. */
  5988. multiplyToRef(color: Color4, result: Color4): Color4;
  5989. /**
  5990. * Creates a string with the Color4 current values
  5991. * @returns the string representation of the Color4 object
  5992. */
  5993. toString(): string;
  5994. /**
  5995. * Returns the string "Color4"
  5996. * @returns "Color4"
  5997. */
  5998. getClassName(): string;
  5999. /**
  6000. * Compute the Color4 hash code
  6001. * @returns an unique number that can be used to hash Color4 objects
  6002. */
  6003. getHashCode(): number;
  6004. /**
  6005. * Creates a new Color4 copied from the current one
  6006. * @returns a new Color4 object
  6007. */
  6008. clone(): Color4;
  6009. /**
  6010. * Copies the given Color4 values into the current one
  6011. * @param source defines the source Color4 object
  6012. * @returns the current updated Color4 object
  6013. */
  6014. copyFrom(source: Color4): Color4;
  6015. /**
  6016. * Copies the given float values into the current one
  6017. * @param r defines the red component to read from
  6018. * @param g defines the green component to read from
  6019. * @param b defines the blue component to read from
  6020. * @param a defines the alpha component to read from
  6021. * @returns the current updated Color4 object
  6022. */
  6023. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6024. /**
  6025. * Copies the given float values into the current one
  6026. * @param r defines the red component to read from
  6027. * @param g defines the green component to read from
  6028. * @param b defines the blue component to read from
  6029. * @param a defines the alpha component to read from
  6030. * @returns the current updated Color4 object
  6031. */
  6032. set(r: number, g: number, b: number, a: number): Color4;
  6033. /**
  6034. * Compute the Color4 hexadecimal code as a string
  6035. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6036. * @returns a string containing the hexadecimal representation of the Color4 object
  6037. */
  6038. toHexString(returnAsColor3?: boolean): string;
  6039. /**
  6040. * Computes a new Color4 converted from the current one to linear space
  6041. * @returns a new Color4 object
  6042. */
  6043. toLinearSpace(): Color4;
  6044. /**
  6045. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6046. * @param convertedColor defines the Color4 object where to store the linear space version
  6047. * @returns the unmodified Color4
  6048. */
  6049. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6050. /**
  6051. * Computes a new Color4 converted from the current one to gamma space
  6052. * @returns a new Color4 object
  6053. */
  6054. toGammaSpace(): Color4;
  6055. /**
  6056. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6057. * @param convertedColor defines the Color4 object where to store the gamma space version
  6058. * @returns the unmodified Color4
  6059. */
  6060. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6061. /**
  6062. * Creates a new Color4 from the string containing valid hexadecimal values
  6063. * @param hex defines a string containing valid hexadecimal values
  6064. * @returns a new Color4 object
  6065. */
  6066. static FromHexString(hex: string): Color4;
  6067. /**
  6068. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6069. * @param left defines the start value
  6070. * @param right defines the end value
  6071. * @param amount defines the gradient factor
  6072. * @returns a new Color4 object
  6073. */
  6074. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6075. /**
  6076. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6077. * @param left defines the start value
  6078. * @param right defines the end value
  6079. * @param amount defines the gradient factor
  6080. * @param result defines the Color4 object where to store data
  6081. */
  6082. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6083. /**
  6084. * Creates a new Color4 from a Color3 and an alpha value
  6085. * @param color3 defines the source Color3 to read from
  6086. * @param alpha defines the alpha component (1.0 by default)
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6090. /**
  6091. * Creates a new Color4 from the starting index element of the given array
  6092. * @param array defines the source array to read from
  6093. * @param offset defines the offset in the source array
  6094. * @returns a new Color4 object
  6095. */
  6096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6097. /**
  6098. * Creates a new Color4 from the starting index element of the given array
  6099. * @param array defines the source array to read from
  6100. * @param offset defines the offset in the source array
  6101. * @param result defines the target Color4 object
  6102. */
  6103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6104. /**
  6105. * Creates a new Color3 from integer values (< 256)
  6106. * @param r defines the red component to read from (value between 0 and 255)
  6107. * @param g defines the green component to read from (value between 0 and 255)
  6108. * @param b defines the blue component to read from (value between 0 and 255)
  6109. * @param a defines the alpha component to read from (value between 0 and 255)
  6110. * @returns a new Color3 object
  6111. */
  6112. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6113. /**
  6114. * Check the content of a given array and convert it to an array containing RGBA data
  6115. * If the original array was already containing count * 4 values then it is returned directly
  6116. * @param colors defines the array to check
  6117. * @param count defines the number of RGBA data to expect
  6118. * @returns an array containing count * 4 values (RGBA)
  6119. */
  6120. static CheckColors4(colors: number[], count: number): number[];
  6121. }
  6122. /**
  6123. * @hidden
  6124. */
  6125. export class TmpColors {
  6126. static Color3: Color3[];
  6127. static Color4: Color4[];
  6128. }
  6129. }
  6130. declare module BABYLON {
  6131. /**
  6132. * Defines an interface which represents an animation key frame
  6133. */
  6134. export interface IAnimationKey {
  6135. /**
  6136. * Frame of the key frame
  6137. */
  6138. frame: number;
  6139. /**
  6140. * Value at the specifies key frame
  6141. */
  6142. value: any;
  6143. /**
  6144. * The input tangent for the cubic hermite spline
  6145. */
  6146. inTangent?: any;
  6147. /**
  6148. * The output tangent for the cubic hermite spline
  6149. */
  6150. outTangent?: any;
  6151. /**
  6152. * The animation interpolation type
  6153. */
  6154. interpolation?: AnimationKeyInterpolation;
  6155. }
  6156. /**
  6157. * Enum for the animation key frame interpolation type
  6158. */
  6159. export enum AnimationKeyInterpolation {
  6160. /**
  6161. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6162. */
  6163. STEP = 1
  6164. }
  6165. }
  6166. declare module BABYLON {
  6167. /**
  6168. * Represents the range of an animation
  6169. */
  6170. export class AnimationRange {
  6171. /**The name of the animation range**/
  6172. name: string;
  6173. /**The starting frame of the animation */
  6174. from: number;
  6175. /**The ending frame of the animation*/
  6176. to: number;
  6177. /**
  6178. * Initializes the range of an animation
  6179. * @param name The name of the animation range
  6180. * @param from The starting frame of the animation
  6181. * @param to The ending frame of the animation
  6182. */
  6183. constructor(
  6184. /**The name of the animation range**/
  6185. name: string,
  6186. /**The starting frame of the animation */
  6187. from: number,
  6188. /**The ending frame of the animation*/
  6189. to: number);
  6190. /**
  6191. * Makes a copy of the animation range
  6192. * @returns A copy of the animation range
  6193. */
  6194. clone(): AnimationRange;
  6195. }
  6196. }
  6197. declare module BABYLON {
  6198. /**
  6199. * Composed of a frame, and an action function
  6200. */
  6201. export class AnimationEvent {
  6202. /** The frame for which the event is triggered **/
  6203. frame: number;
  6204. /** The event to perform when triggered **/
  6205. action: (currentFrame: number) => void;
  6206. /** Specifies if the event should be triggered only once**/
  6207. onlyOnce?: boolean | undefined;
  6208. /**
  6209. * Specifies if the animation event is done
  6210. */
  6211. isDone: boolean;
  6212. /**
  6213. * Initializes the animation event
  6214. * @param frame The frame for which the event is triggered
  6215. * @param action The event to perform when triggered
  6216. * @param onlyOnce Specifies if the event should be triggered only once
  6217. */
  6218. constructor(
  6219. /** The frame for which the event is triggered **/
  6220. frame: number,
  6221. /** The event to perform when triggered **/
  6222. action: (currentFrame: number) => void,
  6223. /** Specifies if the event should be triggered only once**/
  6224. onlyOnce?: boolean | undefined);
  6225. /** @hidden */
  6226. _clone(): AnimationEvent;
  6227. }
  6228. }
  6229. declare module BABYLON {
  6230. /**
  6231. * Interface used to define a behavior
  6232. */
  6233. export interface Behavior<T> {
  6234. /** gets or sets behavior's name */
  6235. name: string;
  6236. /**
  6237. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6238. */
  6239. init(): void;
  6240. /**
  6241. * Called when the behavior is attached to a target
  6242. * @param target defines the target where the behavior is attached to
  6243. */
  6244. attach(target: T): void;
  6245. /**
  6246. * Called when the behavior is detached from its target
  6247. */
  6248. detach(): void;
  6249. }
  6250. /**
  6251. * Interface implemented by classes supporting behaviors
  6252. */
  6253. export interface IBehaviorAware<T> {
  6254. /**
  6255. * Attach a behavior
  6256. * @param behavior defines the behavior to attach
  6257. * @returns the current host
  6258. */
  6259. addBehavior(behavior: Behavior<T>): T;
  6260. /**
  6261. * Remove a behavior from the current object
  6262. * @param behavior defines the behavior to detach
  6263. * @returns the current host
  6264. */
  6265. removeBehavior(behavior: Behavior<T>): T;
  6266. /**
  6267. * Gets a behavior using its name to search
  6268. * @param name defines the name to search
  6269. * @returns the behavior or null if not found
  6270. */
  6271. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. /**
  6276. * Defines an array and its length.
  6277. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6278. */
  6279. export interface ISmartArrayLike<T> {
  6280. /**
  6281. * The data of the array.
  6282. */
  6283. data: Array<T>;
  6284. /**
  6285. * The active length of the array.
  6286. */
  6287. length: number;
  6288. }
  6289. /**
  6290. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6291. */
  6292. export class SmartArray<T> implements ISmartArrayLike<T> {
  6293. /**
  6294. * The full set of data from the array.
  6295. */
  6296. data: Array<T>;
  6297. /**
  6298. * The active length of the array.
  6299. */
  6300. length: number;
  6301. protected _id: number;
  6302. /**
  6303. * Instantiates a Smart Array.
  6304. * @param capacity defines the default capacity of the array.
  6305. */
  6306. constructor(capacity: number);
  6307. /**
  6308. * Pushes a value at the end of the active data.
  6309. * @param value defines the object to push in the array.
  6310. */
  6311. push(value: T): void;
  6312. /**
  6313. * Iterates over the active data and apply the lambda to them.
  6314. * @param func defines the action to apply on each value.
  6315. */
  6316. forEach(func: (content: T) => void): void;
  6317. /**
  6318. * Sorts the full sets of data.
  6319. * @param compareFn defines the comparison function to apply.
  6320. */
  6321. sort(compareFn: (a: T, b: T) => number): void;
  6322. /**
  6323. * Resets the active data to an empty array.
  6324. */
  6325. reset(): void;
  6326. /**
  6327. * Releases all the data from the array as well as the array.
  6328. */
  6329. dispose(): void;
  6330. /**
  6331. * Concats the active data with a given array.
  6332. * @param array defines the data to concatenate with.
  6333. */
  6334. concat(array: any): void;
  6335. /**
  6336. * Returns the position of a value in the active data.
  6337. * @param value defines the value to find the index for
  6338. * @returns the index if found in the active data otherwise -1
  6339. */
  6340. indexOf(value: T): number;
  6341. /**
  6342. * Returns whether an element is part of the active data.
  6343. * @param value defines the value to look for
  6344. * @returns true if found in the active data otherwise false
  6345. */
  6346. contains(value: T): boolean;
  6347. private static _GlobalId;
  6348. }
  6349. /**
  6350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6351. * The data in this array can only be present once
  6352. */
  6353. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6354. private _duplicateId;
  6355. /**
  6356. * Pushes a value at the end of the active data.
  6357. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6358. * @param value defines the object to push in the array.
  6359. */
  6360. push(value: T): void;
  6361. /**
  6362. * Pushes a value at the end of the active data.
  6363. * If the data is already present, it won t be added again
  6364. * @param value defines the object to push in the array.
  6365. * @returns true if added false if it was already present
  6366. */
  6367. pushNoDuplicate(value: T): boolean;
  6368. /**
  6369. * Resets the active data to an empty array.
  6370. */
  6371. reset(): void;
  6372. /**
  6373. * Concats the active data with a given array.
  6374. * This ensures no dupplicate will be present in the result.
  6375. * @param array defines the data to concatenate with.
  6376. */
  6377. concatWithNoDuplicate(array: any): void;
  6378. }
  6379. }
  6380. declare module BABYLON {
  6381. /**
  6382. * @ignore
  6383. * This is a list of all the different input types that are available in the application.
  6384. * Fo instance: ArcRotateCameraGamepadInput...
  6385. */
  6386. export var CameraInputTypes: {};
  6387. /**
  6388. * This is the contract to implement in order to create a new input class.
  6389. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6390. */
  6391. export interface ICameraInput<TCamera extends Camera> {
  6392. /**
  6393. * Defines the camera the input is attached to.
  6394. */
  6395. camera: Nullable<TCamera>;
  6396. /**
  6397. * Gets the class name of the current intput.
  6398. * @returns the class name
  6399. */
  6400. getClassName(): string;
  6401. /**
  6402. * Get the friendly name associated with the input class.
  6403. * @returns the input friendly name
  6404. */
  6405. getSimpleName(): string;
  6406. /**
  6407. * Attach the input controls to a specific dom element to get the input from.
  6408. * @param element Defines the element the controls should be listened from
  6409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6410. */
  6411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6412. /**
  6413. * Detach the current controls from the specified dom element.
  6414. * @param element Defines the element to stop listening the inputs from
  6415. */
  6416. detachControl(element: Nullable<HTMLElement>): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedElement: Nullable<HTMLElement>;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Define options used to create a depth texture
  7783. */
  7784. export class DepthTextureCreationOptions {
  7785. /** Specifies whether or not a stencil should be allocated in the texture */
  7786. generateStencil?: boolean;
  7787. /** Specifies whether or not bilinear filtering is enable on the texture */
  7788. bilinearFiltering?: boolean;
  7789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7790. comparisonFunction?: number;
  7791. /** Specifies if the created texture is a cube texture */
  7792. isCube?: boolean;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. interface ThinEngine {
  7797. /**
  7798. * Creates a depth stencil cube texture.
  7799. * This is only available in WebGL 2.
  7800. * @param size The size of face edge in the cube texture.
  7801. * @param options The options defining the cube texture.
  7802. * @returns The cube texture
  7803. */
  7804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7805. /**
  7806. * Creates a cube texture
  7807. * @param rootUrl defines the url where the files to load is located
  7808. * @param scene defines the current scene
  7809. * @param files defines the list of files to load (1 per face)
  7810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7811. * @param onLoad defines an optional callback raised when the texture is loaded
  7812. * @param onError defines an optional callback raised if there is an issue to load the texture
  7813. * @param format defines the format of the data
  7814. * @param forcedExtension defines the extension to use to pick the right loader
  7815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7819. * @returns the cube texture as an InternalTexture
  7820. */
  7821. 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>): InternalTexture;
  7822. /**
  7823. * Creates a cube texture
  7824. * @param rootUrl defines the url where the files to load is located
  7825. * @param scene defines the current scene
  7826. * @param files defines the list of files to load (1 per face)
  7827. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7828. * @param onLoad defines an optional callback raised when the texture is loaded
  7829. * @param onError defines an optional callback raised if there is an issue to load the texture
  7830. * @param format defines the format of the data
  7831. * @param forcedExtension defines the extension to use to pick the right loader
  7832. * @returns the cube texture as an InternalTexture
  7833. */
  7834. 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;
  7835. /**
  7836. * Creates a cube texture
  7837. * @param rootUrl defines the url where the files to load is located
  7838. * @param scene defines the current scene
  7839. * @param files defines the list of files to load (1 per face)
  7840. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7841. * @param onLoad defines an optional callback raised when the texture is loaded
  7842. * @param onError defines an optional callback raised if there is an issue to load the texture
  7843. * @param format defines the format of the data
  7844. * @param forcedExtension defines the extension to use to pick the right loader
  7845. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7846. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7847. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7851. /** @hidden */
  7852. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7853. /** @hidden */
  7854. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7855. /** @hidden */
  7856. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7857. /** @hidden */
  7858. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7859. /**
  7860. * @hidden
  7861. */
  7862. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7863. }
  7864. }
  7865. declare module BABYLON {
  7866. /**
  7867. * Class for creating a cube texture
  7868. */
  7869. export class CubeTexture extends BaseTexture {
  7870. private _delayedOnLoad;
  7871. /**
  7872. * Observable triggered once the texture has been loaded.
  7873. */
  7874. onLoadObservable: Observable<CubeTexture>;
  7875. /**
  7876. * The url of the texture
  7877. */
  7878. url: string;
  7879. /**
  7880. * Gets or sets the center of the bounding box associated with the cube texture.
  7881. * It must define where the camera used to render the texture was set
  7882. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7883. */
  7884. boundingBoxPosition: Vector3;
  7885. private _boundingBoxSize;
  7886. /**
  7887. * Gets or sets the size of the bounding box associated with the cube texture
  7888. * When defined, the cubemap will switch to local mode
  7889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7890. * @example https://www.babylonjs-playground.com/#RNASML
  7891. */
  7892. set boundingBoxSize(value: Vector3);
  7893. /**
  7894. * Returns the bounding box size
  7895. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7896. */
  7897. get boundingBoxSize(): Vector3;
  7898. protected _rotationY: number;
  7899. /**
  7900. * Sets texture matrix rotation angle around Y axis in radians.
  7901. */
  7902. set rotationY(value: number);
  7903. /**
  7904. * Gets texture matrix rotation angle around Y axis radians.
  7905. */
  7906. get rotationY(): number;
  7907. /**
  7908. * Are mip maps generated for this texture or not.
  7909. */
  7910. get noMipmap(): boolean;
  7911. private _noMipmap;
  7912. private _files;
  7913. protected _forcedExtension: Nullable<string>;
  7914. private _extensions;
  7915. private _textureMatrix;
  7916. private _format;
  7917. private _createPolynomials;
  7918. /**
  7919. * Creates a cube texture from an array of image urls
  7920. * @param files defines an array of image urls
  7921. * @param scene defines the hosting scene
  7922. * @param noMipmap specifies if mip maps are not used
  7923. * @returns a cube texture
  7924. */
  7925. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7926. /**
  7927. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7928. * @param url defines the url of the prefiltered texture
  7929. * @param scene defines the scene the texture is attached to
  7930. * @param forcedExtension defines the extension of the file if different from the url
  7931. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7932. * @return the prefiltered texture
  7933. */
  7934. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7935. /**
  7936. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7937. * as prefiltered data.
  7938. * @param rootUrl defines the url of the texture or the root name of the six images
  7939. * @param null defines the scene or engine the texture is attached to
  7940. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7941. * @param noMipmap defines if mipmaps should be created or not
  7942. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7943. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7944. * @param onError defines a callback triggered in case of error during load
  7945. * @param format defines the internal format to use for the texture once loaded
  7946. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7947. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7950. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7951. * @return the cube texture
  7952. */
  7953. 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);
  7954. /**
  7955. * Get the current class name of the texture useful for serialization or dynamic coding.
  7956. * @returns "CubeTexture"
  7957. */
  7958. getClassName(): string;
  7959. /**
  7960. * Update the url (and optional buffer) of this texture if url was null during construction.
  7961. * @param url the url of the texture
  7962. * @param forcedExtension defines the extension to use
  7963. * @param onLoad callback called when the texture is loaded (defaults to null)
  7964. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7965. */
  7966. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7967. /**
  7968. * Delays loading of the cube texture
  7969. * @param forcedExtension defines the extension to use
  7970. */
  7971. delayLoad(forcedExtension?: string): void;
  7972. /**
  7973. * Returns the reflection texture matrix
  7974. * @returns the reflection texture matrix
  7975. */
  7976. getReflectionTextureMatrix(): Matrix;
  7977. /**
  7978. * Sets the reflection texture matrix
  7979. * @param value Reflection texture matrix
  7980. */
  7981. setReflectionTextureMatrix(value: Matrix): void;
  7982. /**
  7983. * Parses text to create a cube texture
  7984. * @param parsedTexture define the serialized text to read from
  7985. * @param scene defines the hosting scene
  7986. * @param rootUrl defines the root url of the cube texture
  7987. * @returns a cube texture
  7988. */
  7989. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7990. /**
  7991. * Makes a clone, or deep copy, of the cube texture
  7992. * @returns a new cube texture
  7993. */
  7994. clone(): CubeTexture;
  7995. }
  7996. }
  7997. declare module BABYLON {
  7998. /**
  7999. * Manages the defines for the Material
  8000. */
  8001. export class MaterialDefines {
  8002. /** @hidden */
  8003. protected _keys: string[];
  8004. private _isDirty;
  8005. /** @hidden */
  8006. _renderId: number;
  8007. /** @hidden */
  8008. _areLightsDirty: boolean;
  8009. /** @hidden */
  8010. _areLightsDisposed: boolean;
  8011. /** @hidden */
  8012. _areAttributesDirty: boolean;
  8013. /** @hidden */
  8014. _areTexturesDirty: boolean;
  8015. /** @hidden */
  8016. _areFresnelDirty: boolean;
  8017. /** @hidden */
  8018. _areMiscDirty: boolean;
  8019. /** @hidden */
  8020. _arePrePassDirty: boolean;
  8021. /** @hidden */
  8022. _areImageProcessingDirty: boolean;
  8023. /** @hidden */
  8024. _normals: boolean;
  8025. /** @hidden */
  8026. _uvs: boolean;
  8027. /** @hidden */
  8028. _needNormals: boolean;
  8029. /** @hidden */
  8030. _needUVs: boolean;
  8031. [id: string]: any;
  8032. /**
  8033. * Specifies if the material needs to be re-calculated
  8034. */
  8035. get isDirty(): boolean;
  8036. /**
  8037. * Marks the material to indicate that it has been re-calculated
  8038. */
  8039. markAsProcessed(): void;
  8040. /**
  8041. * Marks the material to indicate that it needs to be re-calculated
  8042. */
  8043. markAsUnprocessed(): void;
  8044. /**
  8045. * Marks the material to indicate all of its defines need to be re-calculated
  8046. */
  8047. markAllAsDirty(): void;
  8048. /**
  8049. * Marks the material to indicate that image processing needs to be re-calculated
  8050. */
  8051. markAsImageProcessingDirty(): void;
  8052. /**
  8053. * Marks the material to indicate the lights need to be re-calculated
  8054. * @param disposed Defines whether the light is dirty due to dispose or not
  8055. */
  8056. markAsLightDirty(disposed?: boolean): void;
  8057. /**
  8058. * Marks the attribute state as changed
  8059. */
  8060. markAsAttributesDirty(): void;
  8061. /**
  8062. * Marks the texture state as changed
  8063. */
  8064. markAsTexturesDirty(): void;
  8065. /**
  8066. * Marks the fresnel state as changed
  8067. */
  8068. markAsFresnelDirty(): void;
  8069. /**
  8070. * Marks the misc state as changed
  8071. */
  8072. markAsMiscDirty(): void;
  8073. /**
  8074. * Marks the prepass state as changed
  8075. */
  8076. markAsPrePassDirty(): void;
  8077. /**
  8078. * Rebuilds the material defines
  8079. */
  8080. rebuild(): void;
  8081. /**
  8082. * Specifies if two material defines are equal
  8083. * @param other - A material define instance to compare to
  8084. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8085. */
  8086. isEqual(other: MaterialDefines): boolean;
  8087. /**
  8088. * Clones this instance's defines to another instance
  8089. * @param other - material defines to clone values to
  8090. */
  8091. cloneTo(other: MaterialDefines): void;
  8092. /**
  8093. * Resets the material define values
  8094. */
  8095. reset(): void;
  8096. /**
  8097. * Converts the material define values to a string
  8098. * @returns - String of material define information
  8099. */
  8100. toString(): string;
  8101. }
  8102. }
  8103. declare module BABYLON {
  8104. /**
  8105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8107. * 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;
  8108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8109. */
  8110. export class ColorCurves {
  8111. private _dirty;
  8112. private _tempColor;
  8113. private _globalCurve;
  8114. private _highlightsCurve;
  8115. private _midtonesCurve;
  8116. private _shadowsCurve;
  8117. private _positiveCurve;
  8118. private _negativeCurve;
  8119. private _globalHue;
  8120. private _globalDensity;
  8121. private _globalSaturation;
  8122. private _globalExposure;
  8123. /**
  8124. * Gets the global Hue value.
  8125. * 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).
  8126. */
  8127. get globalHue(): number;
  8128. /**
  8129. * Sets the global Hue value.
  8130. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8131. */
  8132. set globalHue(value: number);
  8133. /**
  8134. * Gets the global Density value.
  8135. * 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.
  8136. * Values less than zero provide a filter of opposite hue.
  8137. */
  8138. get globalDensity(): number;
  8139. /**
  8140. * Sets the global Density value.
  8141. * 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.
  8142. * Values less than zero provide a filter of opposite hue.
  8143. */
  8144. set globalDensity(value: number);
  8145. /**
  8146. * Gets the global Saturation value.
  8147. * 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.
  8148. */
  8149. get globalSaturation(): number;
  8150. /**
  8151. * Sets the global Saturation value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8153. */
  8154. set globalSaturation(value: number);
  8155. /**
  8156. * Gets the global Exposure value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8158. */
  8159. get globalExposure(): number;
  8160. /**
  8161. * Sets the global Exposure value.
  8162. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8163. */
  8164. set globalExposure(value: number);
  8165. private _highlightsHue;
  8166. private _highlightsDensity;
  8167. private _highlightsSaturation;
  8168. private _highlightsExposure;
  8169. /**
  8170. * Gets the highlights Hue value.
  8171. * 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).
  8172. */
  8173. get highlightsHue(): number;
  8174. /**
  8175. * Sets the highlights Hue value.
  8176. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8177. */
  8178. set highlightsHue(value: number);
  8179. /**
  8180. * Gets the highlights Density value.
  8181. * 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.
  8182. * Values less than zero provide a filter of opposite hue.
  8183. */
  8184. get highlightsDensity(): number;
  8185. /**
  8186. * Sets the highlights Density value.
  8187. * 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.
  8188. * Values less than zero provide a filter of opposite hue.
  8189. */
  8190. set highlightsDensity(value: number);
  8191. /**
  8192. * Gets the highlights Saturation value.
  8193. * 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.
  8194. */
  8195. get highlightsSaturation(): number;
  8196. /**
  8197. * Sets the highlights Saturation value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8199. */
  8200. set highlightsSaturation(value: number);
  8201. /**
  8202. * Gets the highlights Exposure value.
  8203. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8204. */
  8205. get highlightsExposure(): number;
  8206. /**
  8207. * Sets the highlights Exposure value.
  8208. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8209. */
  8210. set highlightsExposure(value: number);
  8211. private _midtonesHue;
  8212. private _midtonesDensity;
  8213. private _midtonesSaturation;
  8214. private _midtonesExposure;
  8215. /**
  8216. * Gets the midtones Hue value.
  8217. * 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).
  8218. */
  8219. get midtonesHue(): number;
  8220. /**
  8221. * Sets the midtones Hue value.
  8222. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8223. */
  8224. set midtonesHue(value: number);
  8225. /**
  8226. * Gets the midtones Density value.
  8227. * 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.
  8228. * Values less than zero provide a filter of opposite hue.
  8229. */
  8230. get midtonesDensity(): number;
  8231. /**
  8232. * Sets the midtones Density value.
  8233. * 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.
  8234. * Values less than zero provide a filter of opposite hue.
  8235. */
  8236. set midtonesDensity(value: number);
  8237. /**
  8238. * Gets the midtones Saturation value.
  8239. * 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.
  8240. */
  8241. get midtonesSaturation(): number;
  8242. /**
  8243. * Sets the midtones Saturation value.
  8244. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8245. */
  8246. set midtonesSaturation(value: number);
  8247. /**
  8248. * Gets the midtones Exposure value.
  8249. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8250. */
  8251. get midtonesExposure(): number;
  8252. /**
  8253. * Sets the midtones Exposure value.
  8254. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8255. */
  8256. set midtonesExposure(value: number);
  8257. private _shadowsHue;
  8258. private _shadowsDensity;
  8259. private _shadowsSaturation;
  8260. private _shadowsExposure;
  8261. /**
  8262. * Gets the shadows Hue value.
  8263. * 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).
  8264. */
  8265. get shadowsHue(): number;
  8266. /**
  8267. * Sets the shadows Hue value.
  8268. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8269. */
  8270. set shadowsHue(value: number);
  8271. /**
  8272. * Gets the shadows Density value.
  8273. * 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.
  8274. * Values less than zero provide a filter of opposite hue.
  8275. */
  8276. get shadowsDensity(): number;
  8277. /**
  8278. * Sets the shadows Density value.
  8279. * 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.
  8280. * Values less than zero provide a filter of opposite hue.
  8281. */
  8282. set shadowsDensity(value: number);
  8283. /**
  8284. * Gets the shadows Saturation value.
  8285. * 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.
  8286. */
  8287. get shadowsSaturation(): number;
  8288. /**
  8289. * Sets the shadows Saturation value.
  8290. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8291. */
  8292. set shadowsSaturation(value: number);
  8293. /**
  8294. * Gets the shadows Exposure value.
  8295. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8296. */
  8297. get shadowsExposure(): number;
  8298. /**
  8299. * Sets the shadows Exposure value.
  8300. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8301. */
  8302. set shadowsExposure(value: number);
  8303. /**
  8304. * Returns the class name
  8305. * @returns The class name
  8306. */
  8307. getClassName(): string;
  8308. /**
  8309. * Binds the color curves to the shader.
  8310. * @param colorCurves The color curve to bind
  8311. * @param effect The effect to bind to
  8312. * @param positiveUniform The positive uniform shader parameter
  8313. * @param neutralUniform The neutral uniform shader parameter
  8314. * @param negativeUniform The negative uniform shader parameter
  8315. */
  8316. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8317. /**
  8318. * Prepare the list of uniforms associated with the ColorCurves effects.
  8319. * @param uniformsList The list of uniforms used in the effect
  8320. */
  8321. static PrepareUniforms(uniformsList: string[]): void;
  8322. /**
  8323. * Returns color grading data based on a hue, density, saturation and exposure value.
  8324. * @param filterHue The hue of the color filter.
  8325. * @param filterDensity The density of the color filter.
  8326. * @param saturation The saturation.
  8327. * @param exposure The exposure.
  8328. * @param result The result data container.
  8329. */
  8330. private getColorGradingDataToRef;
  8331. /**
  8332. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8333. * @param value The input slider value in range [-100,100].
  8334. * @returns Adjusted value.
  8335. */
  8336. private static applyColorGradingSliderNonlinear;
  8337. /**
  8338. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8339. * @param hue The hue (H) input.
  8340. * @param saturation The saturation (S) input.
  8341. * @param brightness The brightness (B) input.
  8342. * @result An RGBA color represented as Vector4.
  8343. */
  8344. private static fromHSBToRef;
  8345. /**
  8346. * Returns a value clamped between min and max
  8347. * @param value The value to clamp
  8348. * @param min The minimum of value
  8349. * @param max The maximum of value
  8350. * @returns The clamped value.
  8351. */
  8352. private static clamp;
  8353. /**
  8354. * Clones the current color curve instance.
  8355. * @return The cloned curves
  8356. */
  8357. clone(): ColorCurves;
  8358. /**
  8359. * Serializes the current color curve instance to a json representation.
  8360. * @return a JSON representation
  8361. */
  8362. serialize(): any;
  8363. /**
  8364. * Parses the color curve from a json representation.
  8365. * @param source the JSON source to parse
  8366. * @return The parsed curves
  8367. */
  8368. static Parse(source: any): ColorCurves;
  8369. }
  8370. }
  8371. declare module BABYLON {
  8372. /**
  8373. * Interface to follow in your material defines to integrate easily the
  8374. * Image proccessing functions.
  8375. * @hidden
  8376. */
  8377. export interface IImageProcessingConfigurationDefines {
  8378. IMAGEPROCESSING: boolean;
  8379. VIGNETTE: boolean;
  8380. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8381. VIGNETTEBLENDMODEOPAQUE: boolean;
  8382. TONEMAPPING: boolean;
  8383. TONEMAPPING_ACES: boolean;
  8384. CONTRAST: boolean;
  8385. EXPOSURE: boolean;
  8386. COLORCURVES: boolean;
  8387. COLORGRADING: boolean;
  8388. COLORGRADING3D: boolean;
  8389. SAMPLER3DGREENDEPTH: boolean;
  8390. SAMPLER3DBGRMAP: boolean;
  8391. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8392. }
  8393. /**
  8394. * @hidden
  8395. */
  8396. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. EXPOSURE: boolean;
  8411. constructor();
  8412. }
  8413. /**
  8414. * This groups together the common properties used for image processing either in direct forward pass
  8415. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8416. * or not.
  8417. */
  8418. export class ImageProcessingConfiguration {
  8419. /**
  8420. * Default tone mapping applied in BabylonJS.
  8421. */
  8422. static readonly TONEMAPPING_STANDARD: number;
  8423. /**
  8424. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8425. * to other engines rendering to increase portability.
  8426. */
  8427. static readonly TONEMAPPING_ACES: number;
  8428. /**
  8429. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8430. */
  8431. colorCurves: Nullable<ColorCurves>;
  8432. private _colorCurvesEnabled;
  8433. /**
  8434. * Gets wether the color curves effect is enabled.
  8435. */
  8436. get colorCurvesEnabled(): boolean;
  8437. /**
  8438. * Sets wether the color curves effect is enabled.
  8439. */
  8440. set colorCurvesEnabled(value: boolean);
  8441. private _colorGradingTexture;
  8442. /**
  8443. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8444. */
  8445. get colorGradingTexture(): Nullable<BaseTexture>;
  8446. /**
  8447. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8448. */
  8449. set colorGradingTexture(value: Nullable<BaseTexture>);
  8450. private _colorGradingEnabled;
  8451. /**
  8452. * Gets wether the color grading effect is enabled.
  8453. */
  8454. get colorGradingEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color grading effect is enabled.
  8457. */
  8458. set colorGradingEnabled(value: boolean);
  8459. private _colorGradingWithGreenDepth;
  8460. /**
  8461. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8462. */
  8463. get colorGradingWithGreenDepth(): boolean;
  8464. /**
  8465. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8466. */
  8467. set colorGradingWithGreenDepth(value: boolean);
  8468. private _colorGradingBGR;
  8469. /**
  8470. * Gets wether the color grading texture contains BGR values.
  8471. */
  8472. get colorGradingBGR(): boolean;
  8473. /**
  8474. * Sets wether the color grading texture contains BGR values.
  8475. */
  8476. set colorGradingBGR(value: boolean);
  8477. /** @hidden */
  8478. _exposure: number;
  8479. /**
  8480. * Gets the Exposure used in the effect.
  8481. */
  8482. get exposure(): number;
  8483. /**
  8484. * Sets the Exposure used in the effect.
  8485. */
  8486. set exposure(value: number);
  8487. private _toneMappingEnabled;
  8488. /**
  8489. * Gets wether the tone mapping effect is enabled.
  8490. */
  8491. get toneMappingEnabled(): boolean;
  8492. /**
  8493. * Sets wether the tone mapping effect is enabled.
  8494. */
  8495. set toneMappingEnabled(value: boolean);
  8496. private _toneMappingType;
  8497. /**
  8498. * Gets the type of tone mapping effect.
  8499. */
  8500. get toneMappingType(): number;
  8501. /**
  8502. * Sets the type of tone mapping effect used in BabylonJS.
  8503. */
  8504. set toneMappingType(value: number);
  8505. protected _contrast: number;
  8506. /**
  8507. * Gets the contrast used in the effect.
  8508. */
  8509. get contrast(): number;
  8510. /**
  8511. * Sets the contrast used in the effect.
  8512. */
  8513. set contrast(value: number);
  8514. /**
  8515. * Vignette stretch size.
  8516. */
  8517. vignetteStretch: number;
  8518. /**
  8519. * Vignette centre X Offset.
  8520. */
  8521. vignetteCentreX: number;
  8522. /**
  8523. * Vignette centre Y Offset.
  8524. */
  8525. vignetteCentreY: number;
  8526. /**
  8527. * Vignette weight or intensity of the vignette effect.
  8528. */
  8529. vignetteWeight: number;
  8530. /**
  8531. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8532. * if vignetteEnabled is set to true.
  8533. */
  8534. vignetteColor: Color4;
  8535. /**
  8536. * Camera field of view used by the Vignette effect.
  8537. */
  8538. vignetteCameraFov: number;
  8539. private _vignetteBlendMode;
  8540. /**
  8541. * Gets the vignette blend mode allowing different kind of effect.
  8542. */
  8543. get vignetteBlendMode(): number;
  8544. /**
  8545. * Sets the vignette blend mode allowing different kind of effect.
  8546. */
  8547. set vignetteBlendMode(value: number);
  8548. private _vignetteEnabled;
  8549. /**
  8550. * Gets wether the vignette effect is enabled.
  8551. */
  8552. get vignetteEnabled(): boolean;
  8553. /**
  8554. * Sets wether the vignette effect is enabled.
  8555. */
  8556. set vignetteEnabled(value: boolean);
  8557. private _applyByPostProcess;
  8558. /**
  8559. * Gets wether the image processing is applied through a post process or not.
  8560. */
  8561. get applyByPostProcess(): boolean;
  8562. /**
  8563. * Sets wether the image processing is applied through a post process or not.
  8564. */
  8565. set applyByPostProcess(value: boolean);
  8566. private _isEnabled;
  8567. /**
  8568. * Gets wether the image processing is enabled or not.
  8569. */
  8570. get isEnabled(): boolean;
  8571. /**
  8572. * Sets wether the image processing is enabled or not.
  8573. */
  8574. set isEnabled(value: boolean);
  8575. /**
  8576. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8577. */
  8578. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8579. /**
  8580. * Method called each time the image processing information changes requires to recompile the effect.
  8581. */
  8582. protected _updateParameters(): void;
  8583. /**
  8584. * Gets the current class name.
  8585. * @return "ImageProcessingConfiguration"
  8586. */
  8587. getClassName(): string;
  8588. /**
  8589. * Prepare the list of uniforms associated with the Image Processing effects.
  8590. * @param uniforms The list of uniforms used in the effect
  8591. * @param defines the list of defines currently in use
  8592. */
  8593. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8594. /**
  8595. * Prepare the list of samplers associated with the Image Processing effects.
  8596. * @param samplersList The list of uniforms used in the effect
  8597. * @param defines the list of defines currently in use
  8598. */
  8599. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8600. /**
  8601. * Prepare the list of defines associated to the shader.
  8602. * @param defines the list of defines to complete
  8603. * @param forPostProcess Define if we are currently in post process mode or not
  8604. */
  8605. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8606. /**
  8607. * Returns true if all the image processing information are ready.
  8608. * @returns True if ready, otherwise, false
  8609. */
  8610. isReady(): boolean;
  8611. /**
  8612. * Binds the image processing to the shader.
  8613. * @param effect The effect to bind to
  8614. * @param overrideAspectRatio Override the aspect ratio of the effect
  8615. */
  8616. bind(effect: Effect, overrideAspectRatio?: number): void;
  8617. /**
  8618. * Clones the current image processing instance.
  8619. * @return The cloned image processing
  8620. */
  8621. clone(): ImageProcessingConfiguration;
  8622. /**
  8623. * Serializes the current image processing instance to a json representation.
  8624. * @return a JSON representation
  8625. */
  8626. serialize(): any;
  8627. /**
  8628. * Parses the image processing from a json representation.
  8629. * @param source the JSON source to parse
  8630. * @return The parsed image processing
  8631. */
  8632. static Parse(source: any): ImageProcessingConfiguration;
  8633. private static _VIGNETTEMODE_MULTIPLY;
  8634. private static _VIGNETTEMODE_OPAQUE;
  8635. /**
  8636. * Used to apply the vignette as a mix with the pixel color.
  8637. */
  8638. static get VIGNETTEMODE_MULTIPLY(): number;
  8639. /**
  8640. * Used to apply the vignette as a replacement of the pixel color.
  8641. */
  8642. static get VIGNETTEMODE_OPAQUE(): number;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /** @hidden */
  8647. export var postprocessVertexShader: {
  8648. name: string;
  8649. shader: string;
  8650. };
  8651. }
  8652. declare module BABYLON {
  8653. /**
  8654. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8655. */
  8656. export type RenderTargetTextureSize = number | {
  8657. width: number;
  8658. height: number;
  8659. layers?: number;
  8660. };
  8661. interface ThinEngine {
  8662. /**
  8663. * Creates a new render target texture
  8664. * @param size defines the size of the texture
  8665. * @param options defines the options used to create the texture
  8666. * @returns a new render target texture stored in an InternalTexture
  8667. */
  8668. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8669. /**
  8670. * Creates a depth stencil texture.
  8671. * This is only available in WebGL 2 or with the depth texture extension available.
  8672. * @param size The size of face edge in the texture.
  8673. * @param options The options defining the texture.
  8674. * @returns The texture
  8675. */
  8676. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8677. /** @hidden */
  8678. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8679. }
  8680. }
  8681. declare module BABYLON {
  8682. /**
  8683. * Defines the kind of connection point for node based material
  8684. */
  8685. export enum NodeMaterialBlockConnectionPointTypes {
  8686. /** Float */
  8687. Float = 1,
  8688. /** Int */
  8689. Int = 2,
  8690. /** Vector2 */
  8691. Vector2 = 4,
  8692. /** Vector3 */
  8693. Vector3 = 8,
  8694. /** Vector4 */
  8695. Vector4 = 16,
  8696. /** Color3 */
  8697. Color3 = 32,
  8698. /** Color4 */
  8699. Color4 = 64,
  8700. /** Matrix */
  8701. Matrix = 128,
  8702. /** Custom object */
  8703. Object = 256,
  8704. /** Detect type based on connection */
  8705. AutoDetect = 1024,
  8706. /** Output type that will be defined by input type */
  8707. BasedOnInput = 2048
  8708. }
  8709. }
  8710. declare module BABYLON {
  8711. /**
  8712. * Enum used to define the target of a block
  8713. */
  8714. export enum NodeMaterialBlockTargets {
  8715. /** Vertex shader */
  8716. Vertex = 1,
  8717. /** Fragment shader */
  8718. Fragment = 2,
  8719. /** Neutral */
  8720. Neutral = 4,
  8721. /** Vertex and Fragment */
  8722. VertexAndFragment = 3
  8723. }
  8724. }
  8725. declare module BABYLON {
  8726. /**
  8727. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8728. */
  8729. export enum NodeMaterialBlockConnectionPointMode {
  8730. /** Value is an uniform */
  8731. Uniform = 0,
  8732. /** Value is a mesh attribute */
  8733. Attribute = 1,
  8734. /** Value is a varying between vertex and fragment shaders */
  8735. Varying = 2,
  8736. /** Mode is undefined */
  8737. Undefined = 3
  8738. }
  8739. }
  8740. declare module BABYLON {
  8741. /**
  8742. * Enum used to define system values e.g. values automatically provided by the system
  8743. */
  8744. export enum NodeMaterialSystemValues {
  8745. /** World */
  8746. World = 1,
  8747. /** View */
  8748. View = 2,
  8749. /** Projection */
  8750. Projection = 3,
  8751. /** ViewProjection */
  8752. ViewProjection = 4,
  8753. /** WorldView */
  8754. WorldView = 5,
  8755. /** WorldViewProjection */
  8756. WorldViewProjection = 6,
  8757. /** CameraPosition */
  8758. CameraPosition = 7,
  8759. /** Fog Color */
  8760. FogColor = 8,
  8761. /** Delta time */
  8762. DeltaTime = 9
  8763. }
  8764. }
  8765. declare module BABYLON {
  8766. /** Defines supported spaces */
  8767. export enum Space {
  8768. /** Local (object) space */
  8769. LOCAL = 0,
  8770. /** World space */
  8771. WORLD = 1,
  8772. /** Bone space */
  8773. BONE = 2
  8774. }
  8775. /** Defines the 3 main axes */
  8776. export class Axis {
  8777. /** X axis */
  8778. static X: Vector3;
  8779. /** Y axis */
  8780. static Y: Vector3;
  8781. /** Z axis */
  8782. static Z: Vector3;
  8783. }
  8784. }
  8785. declare module BABYLON {
  8786. /**
  8787. * Represents a camera frustum
  8788. */
  8789. export class Frustum {
  8790. /**
  8791. * Gets the planes representing the frustum
  8792. * @param transform matrix to be applied to the returned planes
  8793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8794. */
  8795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8796. /**
  8797. * Gets the near frustum plane transformed by the transform matrix
  8798. * @param transform transformation matrix to be applied to the resulting frustum plane
  8799. * @param frustumPlane the resuling frustum plane
  8800. */
  8801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8802. /**
  8803. * Gets the far frustum plane transformed by the transform matrix
  8804. * @param transform transformation matrix to be applied to the resulting frustum plane
  8805. * @param frustumPlane the resuling frustum plane
  8806. */
  8807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8808. /**
  8809. * Gets the left frustum plane transformed by the transform matrix
  8810. * @param transform transformation matrix to be applied to the resulting frustum plane
  8811. * @param frustumPlane the resuling frustum plane
  8812. */
  8813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8814. /**
  8815. * Gets the right frustum plane transformed by the transform matrix
  8816. * @param transform transformation matrix to be applied to the resulting frustum plane
  8817. * @param frustumPlane the resuling frustum plane
  8818. */
  8819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8820. /**
  8821. * Gets the top frustum plane transformed by the transform matrix
  8822. * @param transform transformation matrix to be applied to the resulting frustum plane
  8823. * @param frustumPlane the resuling frustum plane
  8824. */
  8825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8826. /**
  8827. * Gets the bottom frustum plane transformed by the transform matrix
  8828. * @param transform transformation matrix to be applied to the resulting frustum plane
  8829. * @param frustumPlane the resuling frustum plane
  8830. */
  8831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8832. /**
  8833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8834. * @param transform transformation matrix to be applied to the resulting frustum planes
  8835. * @param frustumPlanes the resuling frustum planes
  8836. */
  8837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. /**
  8842. * Interface for the size containing width and height
  8843. */
  8844. export interface ISize {
  8845. /**
  8846. * Width
  8847. */
  8848. width: number;
  8849. /**
  8850. * Heighht
  8851. */
  8852. height: number;
  8853. }
  8854. /**
  8855. * Size containing widht and height
  8856. */
  8857. export class Size implements ISize {
  8858. /**
  8859. * Width
  8860. */
  8861. width: number;
  8862. /**
  8863. * Height
  8864. */
  8865. height: number;
  8866. /**
  8867. * Creates a Size object from the given width and height (floats).
  8868. * @param width width of the new size
  8869. * @param height height of the new size
  8870. */
  8871. constructor(width: number, height: number);
  8872. /**
  8873. * Returns a string with the Size width and height
  8874. * @returns a string with the Size width and height
  8875. */
  8876. toString(): string;
  8877. /**
  8878. * "Size"
  8879. * @returns the string "Size"
  8880. */
  8881. getClassName(): string;
  8882. /**
  8883. * Returns the Size hash code.
  8884. * @returns a hash code for a unique width and height
  8885. */
  8886. getHashCode(): number;
  8887. /**
  8888. * Updates the current size from the given one.
  8889. * @param src the given size
  8890. */
  8891. copyFrom(src: Size): void;
  8892. /**
  8893. * Updates in place the current Size from the given floats.
  8894. * @param width width of the new size
  8895. * @param height height of the new size
  8896. * @returns the updated Size.
  8897. */
  8898. copyFromFloats(width: number, height: number): Size;
  8899. /**
  8900. * Updates in place the current Size from the given floats.
  8901. * @param width width to set
  8902. * @param height height to set
  8903. * @returns the updated Size.
  8904. */
  8905. set(width: number, height: number): Size;
  8906. /**
  8907. * Multiplies the width and height by numbers
  8908. * @param w factor to multiple the width by
  8909. * @param h factor to multiple the height by
  8910. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8911. */
  8912. multiplyByFloats(w: number, h: number): Size;
  8913. /**
  8914. * Clones the size
  8915. * @returns a new Size copied from the given one.
  8916. */
  8917. clone(): Size;
  8918. /**
  8919. * True if the current Size and the given one width and height are strictly equal.
  8920. * @param other the other size to compare against
  8921. * @returns True if the current Size and the given one width and height are strictly equal.
  8922. */
  8923. equals(other: Size): boolean;
  8924. /**
  8925. * The surface of the Size : width * height (float).
  8926. */
  8927. get surface(): number;
  8928. /**
  8929. * Create a new size of zero
  8930. * @returns a new Size set to (0.0, 0.0)
  8931. */
  8932. static Zero(): Size;
  8933. /**
  8934. * Sums the width and height of two sizes
  8935. * @param otherSize size to add to this size
  8936. * @returns a new Size set as the addition result of the current Size and the given one.
  8937. */
  8938. add(otherSize: Size): Size;
  8939. /**
  8940. * Subtracts the width and height of two
  8941. * @param otherSize size to subtract to this size
  8942. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8943. */
  8944. subtract(otherSize: Size): Size;
  8945. /**
  8946. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8947. * @param start starting size to lerp between
  8948. * @param end end size to lerp between
  8949. * @param amount amount to lerp between the start and end values
  8950. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8951. */
  8952. static Lerp(start: Size, end: Size, amount: number): Size;
  8953. }
  8954. }
  8955. declare module BABYLON {
  8956. /**
  8957. * Contains position and normal vectors for a vertex
  8958. */
  8959. export class PositionNormalVertex {
  8960. /** the position of the vertex (defaut: 0,0,0) */
  8961. position: Vector3;
  8962. /** the normal of the vertex (defaut: 0,1,0) */
  8963. normal: Vector3;
  8964. /**
  8965. * Creates a PositionNormalVertex
  8966. * @param position the position of the vertex (defaut: 0,0,0)
  8967. * @param normal the normal of the vertex (defaut: 0,1,0)
  8968. */
  8969. constructor(
  8970. /** the position of the vertex (defaut: 0,0,0) */
  8971. position?: Vector3,
  8972. /** the normal of the vertex (defaut: 0,1,0) */
  8973. normal?: Vector3);
  8974. /**
  8975. * Clones the PositionNormalVertex
  8976. * @returns the cloned PositionNormalVertex
  8977. */
  8978. clone(): PositionNormalVertex;
  8979. }
  8980. /**
  8981. * Contains position, normal and uv vectors for a vertex
  8982. */
  8983. export class PositionNormalTextureVertex {
  8984. /** the position of the vertex (defaut: 0,0,0) */
  8985. position: Vector3;
  8986. /** the normal of the vertex (defaut: 0,1,0) */
  8987. normal: Vector3;
  8988. /** the uv of the vertex (default: 0,0) */
  8989. uv: Vector2;
  8990. /**
  8991. * Creates a PositionNormalTextureVertex
  8992. * @param position the position of the vertex (defaut: 0,0,0)
  8993. * @param normal the normal of the vertex (defaut: 0,1,0)
  8994. * @param uv the uv of the vertex (default: 0,0)
  8995. */
  8996. constructor(
  8997. /** the position of the vertex (defaut: 0,0,0) */
  8998. position?: Vector3,
  8999. /** the normal of the vertex (defaut: 0,1,0) */
  9000. normal?: Vector3,
  9001. /** the uv of the vertex (default: 0,0) */
  9002. uv?: Vector2);
  9003. /**
  9004. * Clones the PositionNormalTextureVertex
  9005. * @returns the cloned PositionNormalTextureVertex
  9006. */
  9007. clone(): PositionNormalTextureVertex;
  9008. }
  9009. }
  9010. declare module BABYLON {
  9011. /**
  9012. * Enum defining the type of animations supported by InputBlock
  9013. */
  9014. export enum AnimatedInputBlockTypes {
  9015. /** No animation */
  9016. None = 0,
  9017. /** Time based animation. Will only work for floats */
  9018. Time = 1
  9019. }
  9020. }
  9021. declare module BABYLON {
  9022. /**
  9023. * Interface describing all the common properties and methods a shadow light needs to implement.
  9024. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9025. * as well as binding the different shadow properties to the effects.
  9026. */
  9027. export interface IShadowLight extends Light {
  9028. /**
  9029. * The light id in the scene (used in scene.findLighById for instance)
  9030. */
  9031. id: string;
  9032. /**
  9033. * The position the shdow will be casted from.
  9034. */
  9035. position: Vector3;
  9036. /**
  9037. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9038. */
  9039. direction: Vector3;
  9040. /**
  9041. * The transformed position. Position of the light in world space taking parenting in account.
  9042. */
  9043. transformedPosition: Vector3;
  9044. /**
  9045. * The transformed direction. Direction of the light in world space taking parenting in account.
  9046. */
  9047. transformedDirection: Vector3;
  9048. /**
  9049. * The friendly name of the light in the scene.
  9050. */
  9051. name: string;
  9052. /**
  9053. * Defines the shadow projection clipping minimum z value.
  9054. */
  9055. shadowMinZ: number;
  9056. /**
  9057. * Defines the shadow projection clipping maximum z value.
  9058. */
  9059. shadowMaxZ: number;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Gets the scene the light belongs to.
  9067. * @returns The scene
  9068. */
  9069. getScene(): Scene;
  9070. /**
  9071. * Callback defining a custom Projection Matrix Builder.
  9072. * This can be used to override the default projection matrix computation.
  9073. */
  9074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9075. /**
  9076. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9077. * @param matrix The materix to updated with the projection information
  9078. * @param viewMatrix The transform matrix of the light
  9079. * @param renderList The list of mesh to render in the map
  9080. * @returns The current light
  9081. */
  9082. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9083. /**
  9084. * Gets the current depth scale used in ESM.
  9085. * @returns The scale
  9086. */
  9087. getDepthScale(): number;
  9088. /**
  9089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9090. * @returns true if a cube texture needs to be use
  9091. */
  9092. needCube(): boolean;
  9093. /**
  9094. * Detects if the projection matrix requires to be recomputed this frame.
  9095. * @returns true if it requires to be recomputed otherwise, false.
  9096. */
  9097. needProjectionMatrixCompute(): boolean;
  9098. /**
  9099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9100. */
  9101. forceProjectionMatrixCompute(): void;
  9102. /**
  9103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9106. */
  9107. getShadowDirection(faceIndex?: number): Vector3;
  9108. /**
  9109. * Gets the minZ used for shadow according to both the scene and the light.
  9110. * @param activeCamera The camera we are returning the min for
  9111. * @returns the depth min z
  9112. */
  9113. getDepthMinZ(activeCamera: Camera): number;
  9114. /**
  9115. * Gets the maxZ used for shadow according to both the scene and the light.
  9116. * @param activeCamera The camera we are returning the max for
  9117. * @returns the depth max z
  9118. */
  9119. getDepthMaxZ(activeCamera: Camera): number;
  9120. }
  9121. /**
  9122. * Base implementation IShadowLight
  9123. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9124. */
  9125. export abstract class ShadowLight extends Light implements IShadowLight {
  9126. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9127. protected _position: Vector3;
  9128. protected _setPosition(value: Vector3): void;
  9129. /**
  9130. * Sets the position the shadow will be casted from. Also use as the light position for both
  9131. * point and spot lights.
  9132. */
  9133. get position(): Vector3;
  9134. /**
  9135. * Sets the position the shadow will be casted from. Also use as the light position for both
  9136. * point and spot lights.
  9137. */
  9138. set position(value: Vector3);
  9139. protected _direction: Vector3;
  9140. protected _setDirection(value: Vector3): void;
  9141. /**
  9142. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9143. * Also use as the light direction on spot and directional lights.
  9144. */
  9145. get direction(): Vector3;
  9146. /**
  9147. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9148. * Also use as the light direction on spot and directional lights.
  9149. */
  9150. set direction(value: Vector3);
  9151. protected _shadowMinZ: number;
  9152. /**
  9153. * Gets the shadow projection clipping minimum z value.
  9154. */
  9155. get shadowMinZ(): number;
  9156. /**
  9157. * Sets the shadow projection clipping minimum z value.
  9158. */
  9159. set shadowMinZ(value: number);
  9160. protected _shadowMaxZ: number;
  9161. /**
  9162. * Sets the shadow projection clipping maximum z value.
  9163. */
  9164. get shadowMaxZ(): number;
  9165. /**
  9166. * Gets the shadow projection clipping maximum z value.
  9167. */
  9168. set shadowMaxZ(value: number);
  9169. /**
  9170. * Callback defining a custom Projection Matrix Builder.
  9171. * This can be used to override the default projection matrix computation.
  9172. */
  9173. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9174. /**
  9175. * The transformed position. Position of the light in world space taking parenting in account.
  9176. */
  9177. transformedPosition: Vector3;
  9178. /**
  9179. * The transformed direction. Direction of the light in world space taking parenting in account.
  9180. */
  9181. transformedDirection: Vector3;
  9182. private _needProjectionMatrixCompute;
  9183. /**
  9184. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9185. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9186. */
  9187. computeTransformedInformation(): boolean;
  9188. /**
  9189. * Return the depth scale used for the shadow map.
  9190. * @returns the depth scale.
  9191. */
  9192. getDepthScale(): number;
  9193. /**
  9194. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9197. */
  9198. getShadowDirection(faceIndex?: number): Vector3;
  9199. /**
  9200. * Returns the ShadowLight absolute position in the World.
  9201. * @returns the position vector in world space
  9202. */
  9203. getAbsolutePosition(): Vector3;
  9204. /**
  9205. * Sets the ShadowLight direction toward the passed target.
  9206. * @param target The point to target in local space
  9207. * @returns the updated ShadowLight direction
  9208. */
  9209. setDirectionToTarget(target: Vector3): Vector3;
  9210. /**
  9211. * Returns the light rotation in euler definition.
  9212. * @returns the x y z rotation in local space.
  9213. */
  9214. getRotation(): Vector3;
  9215. /**
  9216. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9217. * @returns true if a cube texture needs to be use
  9218. */
  9219. needCube(): boolean;
  9220. /**
  9221. * Detects if the projection matrix requires to be recomputed this frame.
  9222. * @returns true if it requires to be recomputed otherwise, false.
  9223. */
  9224. needProjectionMatrixCompute(): boolean;
  9225. /**
  9226. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9227. */
  9228. forceProjectionMatrixCompute(): void;
  9229. /** @hidden */
  9230. _initCache(): void;
  9231. /** @hidden */
  9232. _isSynchronized(): boolean;
  9233. /**
  9234. * Computes the world matrix of the node
  9235. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9236. * @returns the world matrix
  9237. */
  9238. computeWorldMatrix(force?: boolean): Matrix;
  9239. /**
  9240. * Gets the minZ used for shadow according to both the scene and the light.
  9241. * @param activeCamera The camera we are returning the min for
  9242. * @returns the depth min z
  9243. */
  9244. getDepthMinZ(activeCamera: Camera): number;
  9245. /**
  9246. * Gets the maxZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the max for
  9248. * @returns the depth max z
  9249. */
  9250. getDepthMaxZ(activeCamera: Camera): number;
  9251. /**
  9252. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9253. * @param matrix The materix to updated with the projection information
  9254. * @param viewMatrix The transform matrix of the light
  9255. * @param renderList The list of mesh to render in the map
  9256. * @returns The current light
  9257. */
  9258. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9259. }
  9260. }
  9261. declare module BABYLON {
  9262. /** @hidden */
  9263. export var packingFunctions: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module BABYLON {
  9269. /** @hidden */
  9270. export var bayerDitherFunctions: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var shadowMapFragmentDeclaration: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var clipPlaneFragmentDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var clipPlaneFragment: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var shadowMapFragment: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var shadowMapPixelShader: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var bonesDeclaration: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var morphTargetsVertexGlobalDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var morphTargetsVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var instancesDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var helperFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var shadowMapVertexDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var morphTargetsVertex: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var instancesVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var bonesVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var shadowMapVertexNormalBias: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var shadowMapVertexMetric: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var clipPlaneVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var shadowMapVertexShader: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var depthBoxBlurPixelShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapFragmentSoftTransparentShadow: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9425. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9426. */
  9427. export class EffectFallbacks implements IEffectFallbacks {
  9428. private _defines;
  9429. private _currentRank;
  9430. private _maxRank;
  9431. private _mesh;
  9432. /**
  9433. * Removes the fallback from the bound mesh.
  9434. */
  9435. unBindMesh(): void;
  9436. /**
  9437. * Adds a fallback on the specified property.
  9438. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9439. * @param define The name of the define in the shader
  9440. */
  9441. addFallback(rank: number, define: string): void;
  9442. /**
  9443. * Sets the mesh to use CPU skinning when needing to fallback.
  9444. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9445. * @param mesh The mesh to use the fallbacks.
  9446. */
  9447. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9448. /**
  9449. * Checks to see if more fallbacks are still availible.
  9450. */
  9451. get hasMoreFallbacks(): boolean;
  9452. /**
  9453. * Removes the defines that should be removed when falling back.
  9454. * @param currentDefines defines the current define statements for the shader.
  9455. * @param effect defines the current effect we try to compile
  9456. * @returns The resulting defines with defines of the current rank removed.
  9457. */
  9458. reduce(currentDefines: string, effect: Effect): string;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. /**
  9463. * Interface used to define Action
  9464. */
  9465. export interface IAction {
  9466. /**
  9467. * Trigger for the action
  9468. */
  9469. trigger: number;
  9470. /** Options of the trigger */
  9471. triggerOptions: any;
  9472. /**
  9473. * Gets the trigger parameters
  9474. * @returns the trigger parameters
  9475. */
  9476. getTriggerParameter(): any;
  9477. /**
  9478. * Internal only - executes current action event
  9479. * @hidden
  9480. */
  9481. _executeCurrent(evt?: ActionEvent): void;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @param parent of child
  9485. * @returns the serialized object
  9486. */
  9487. serialize(parent: any): any;
  9488. /**
  9489. * Internal only
  9490. * @hidden
  9491. */
  9492. _prepare(): void;
  9493. /**
  9494. * Internal only - manager for action
  9495. * @hidden
  9496. */
  9497. _actionManager: Nullable<AbstractActionManager>;
  9498. /**
  9499. * Adds action to chain of actions, may be a DoNothingAction
  9500. * @param action defines the next action to execute
  9501. * @returns The action passed in
  9502. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9503. */
  9504. then(action: IAction): IAction;
  9505. }
  9506. /**
  9507. * The action to be carried out following a trigger
  9508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9509. */
  9510. export class Action implements IAction {
  9511. /** the trigger, with or without parameters, for the action */
  9512. triggerOptions: any;
  9513. /**
  9514. * Trigger for the action
  9515. */
  9516. trigger: number;
  9517. /**
  9518. * Internal only - manager for action
  9519. * @hidden
  9520. */
  9521. _actionManager: ActionManager;
  9522. private _nextActiveAction;
  9523. private _child;
  9524. private _condition?;
  9525. private _triggerParameter;
  9526. /**
  9527. * An event triggered prior to action being executed.
  9528. */
  9529. onBeforeExecuteObservable: Observable<Action>;
  9530. /**
  9531. * Creates a new Action
  9532. * @param triggerOptions the trigger, with or without parameters, for the action
  9533. * @param condition an optional determinant of action
  9534. */
  9535. constructor(
  9536. /** the trigger, with or without parameters, for the action */
  9537. triggerOptions: any, condition?: Condition);
  9538. /**
  9539. * Internal only
  9540. * @hidden
  9541. */
  9542. _prepare(): void;
  9543. /**
  9544. * Gets the trigger parameters
  9545. * @returns the trigger parameters
  9546. */
  9547. getTriggerParameter(): any;
  9548. /**
  9549. * Internal only - executes current action event
  9550. * @hidden
  9551. */
  9552. _executeCurrent(evt?: ActionEvent): void;
  9553. /**
  9554. * Execute placeholder for child classes
  9555. * @param evt optional action event
  9556. */
  9557. execute(evt?: ActionEvent): void;
  9558. /**
  9559. * Skips to next active action
  9560. */
  9561. skipToNextActiveAction(): void;
  9562. /**
  9563. * Adds action to chain of actions, may be a DoNothingAction
  9564. * @param action defines the next action to execute
  9565. * @returns The action passed in
  9566. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9567. */
  9568. then(action: Action): Action;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. _getProperty(propertyPath: string): string;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. _getEffectiveTarget(target: any, propertyPath: string): any;
  9579. /**
  9580. * Serialize placeholder for child classes
  9581. * @param parent of child
  9582. * @returns the serialized object
  9583. */
  9584. serialize(parent: any): any;
  9585. /**
  9586. * Internal only called by serialize
  9587. * @hidden
  9588. */
  9589. protected _serialize(serializedAction: any, parent?: any): any;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. static _SerializeValueAsString: (value: any) => string;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. static _GetTargetProperty: (target: Scene | Node) => {
  9600. name: string;
  9601. targetType: string;
  9602. value: string;
  9603. };
  9604. }
  9605. }
  9606. declare module BABYLON {
  9607. /**
  9608. * A Condition applied to an Action
  9609. */
  9610. export class Condition {
  9611. /**
  9612. * Internal only - manager for action
  9613. * @hidden
  9614. */
  9615. _actionManager: ActionManager;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _evaluationId: number;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. _currentResult: boolean;
  9626. /**
  9627. * Creates a new Condition
  9628. * @param actionManager the manager of the action the condition is applied to
  9629. */
  9630. constructor(actionManager: ActionManager);
  9631. /**
  9632. * Check if the current condition is valid
  9633. * @returns a boolean
  9634. */
  9635. isValid(): boolean;
  9636. /**
  9637. * Internal only
  9638. * @hidden
  9639. */
  9640. _getProperty(propertyPath: string): string;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. _getEffectiveTarget(target: any, propertyPath: string): any;
  9646. /**
  9647. * Serialize placeholder for child classes
  9648. * @returns the serialized object
  9649. */
  9650. serialize(): any;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. protected _serialize(serializedCondition: any): any;
  9656. }
  9657. /**
  9658. * Defines specific conditional operators as extensions of Condition
  9659. */
  9660. export class ValueCondition extends Condition {
  9661. /** path to specify the property of the target the conditional operator uses */
  9662. propertyPath: string;
  9663. /** the value compared by the conditional operator against the current value of the property */
  9664. value: any;
  9665. /** the conditional operator, default ValueCondition.IsEqual */
  9666. operator: number;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. private static _IsEqual;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsDifferent;
  9677. /**
  9678. * Internal only
  9679. * @hidden
  9680. */
  9681. private static _IsGreater;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private static _IsLesser;
  9687. /**
  9688. * returns the number for IsEqual
  9689. */
  9690. static get IsEqual(): number;
  9691. /**
  9692. * Returns the number for IsDifferent
  9693. */
  9694. static get IsDifferent(): number;
  9695. /**
  9696. * Returns the number for IsGreater
  9697. */
  9698. static get IsGreater(): number;
  9699. /**
  9700. * Returns the number for IsLesser
  9701. */
  9702. static get IsLesser(): number;
  9703. /**
  9704. * Internal only The action manager for the condition
  9705. * @hidden
  9706. */
  9707. _actionManager: ActionManager;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private _target;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private _effectiveTarget;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. private _property;
  9723. /**
  9724. * Creates a new ValueCondition
  9725. * @param actionManager manager for the action the condition applies to
  9726. * @param target for the action
  9727. * @param propertyPath path to specify the property of the target the conditional operator uses
  9728. * @param value the value compared by the conditional operator against the current value of the property
  9729. * @param operator the conditional operator, default ValueCondition.IsEqual
  9730. */
  9731. constructor(actionManager: ActionManager, target: any,
  9732. /** path to specify the property of the target the conditional operator uses */
  9733. propertyPath: string,
  9734. /** the value compared by the conditional operator against the current value of the property */
  9735. value: any,
  9736. /** the conditional operator, default ValueCondition.IsEqual */
  9737. operator?: number);
  9738. /**
  9739. * Compares the given value with the property value for the specified conditional operator
  9740. * @returns the result of the comparison
  9741. */
  9742. isValid(): boolean;
  9743. /**
  9744. * Serialize the ValueCondition into a JSON compatible object
  9745. * @returns serialization object
  9746. */
  9747. serialize(): any;
  9748. /**
  9749. * Gets the name of the conditional operator for the ValueCondition
  9750. * @param operator the conditional operator
  9751. * @returns the name
  9752. */
  9753. static GetOperatorName(operator: number): string;
  9754. }
  9755. /**
  9756. * Defines a predicate condition as an extension of Condition
  9757. */
  9758. export class PredicateCondition extends Condition {
  9759. /** defines the predicate function used to validate the condition */
  9760. predicate: () => boolean;
  9761. /**
  9762. * Internal only - manager for action
  9763. * @hidden
  9764. */
  9765. _actionManager: ActionManager;
  9766. /**
  9767. * Creates a new PredicateCondition
  9768. * @param actionManager manager for the action the condition applies to
  9769. * @param predicate defines the predicate function used to validate the condition
  9770. */
  9771. constructor(actionManager: ActionManager,
  9772. /** defines the predicate function used to validate the condition */
  9773. predicate: () => boolean);
  9774. /**
  9775. * @returns the validity of the predicate condition
  9776. */
  9777. isValid(): boolean;
  9778. }
  9779. /**
  9780. * Defines a state condition as an extension of Condition
  9781. */
  9782. export class StateCondition extends Condition {
  9783. /** Value to compare with target state */
  9784. value: string;
  9785. /**
  9786. * Internal only - manager for action
  9787. * @hidden
  9788. */
  9789. _actionManager: ActionManager;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _target;
  9795. /**
  9796. * Creates a new StateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param target of the condition
  9799. * @param value to compare with target state
  9800. */
  9801. constructor(actionManager: ActionManager, target: any,
  9802. /** Value to compare with target state */
  9803. value: string);
  9804. /**
  9805. * Gets a boolean indicating if the current condition is met
  9806. * @returns the validity of the state
  9807. */
  9808. isValid(): boolean;
  9809. /**
  9810. * Serialize the StateCondition into a JSON compatible object
  9811. * @returns serialization object
  9812. */
  9813. serialize(): any;
  9814. }
  9815. }
  9816. declare module BABYLON {
  9817. /**
  9818. * This defines an action responsible to toggle a boolean once triggered.
  9819. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9820. */
  9821. export class SwitchBooleanAction extends Action {
  9822. /**
  9823. * The path to the boolean property in the target object
  9824. */
  9825. propertyPath: string;
  9826. private _target;
  9827. private _effectiveTarget;
  9828. private _property;
  9829. /**
  9830. * Instantiate the action
  9831. * @param triggerOptions defines the trigger options
  9832. * @param target defines the object containing the boolean
  9833. * @param propertyPath defines the path to the boolean property in the target object
  9834. * @param condition defines the trigger related conditions
  9835. */
  9836. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9837. /** @hidden */
  9838. _prepare(): void;
  9839. /**
  9840. * Execute the action toggle the boolean value.
  9841. */
  9842. execute(): void;
  9843. /**
  9844. * Serializes the actions and its related information.
  9845. * @param parent defines the object to serialize in
  9846. * @returns the serialized object
  9847. */
  9848. serialize(parent: any): any;
  9849. }
  9850. /**
  9851. * This defines an action responsible to set a the state field of the target
  9852. * to a desired value once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class SetStateAction extends Action {
  9856. /**
  9857. * The value to store in the state field.
  9858. */
  9859. value: string;
  9860. private _target;
  9861. /**
  9862. * Instantiate the action
  9863. * @param triggerOptions defines the trigger options
  9864. * @param target defines the object containing the state property
  9865. * @param value defines the value to store in the state field
  9866. * @param condition defines the trigger related conditions
  9867. */
  9868. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9869. /**
  9870. * Execute the action and store the value on the target state property.
  9871. */
  9872. execute(): void;
  9873. /**
  9874. * Serializes the actions and its related information.
  9875. * @param parent defines the object to serialize in
  9876. * @returns the serialized object
  9877. */
  9878. serialize(parent: any): any;
  9879. }
  9880. /**
  9881. * This defines an action responsible to set a property of the target
  9882. * to a desired value once triggered.
  9883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9884. */
  9885. export class SetValueAction extends Action {
  9886. /**
  9887. * The path of the property to set in the target.
  9888. */
  9889. propertyPath: string;
  9890. /**
  9891. * The value to set in the property
  9892. */
  9893. value: any;
  9894. private _target;
  9895. private _effectiveTarget;
  9896. private _property;
  9897. /**
  9898. * Instantiate the action
  9899. * @param triggerOptions defines the trigger options
  9900. * @param target defines the object containing the property
  9901. * @param propertyPath defines the path of the property to set in the target
  9902. * @param value defines the value to set in the property
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and set the targetted property to the desired value.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to increment the target value
  9921. * to a desired value once triggered.
  9922. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9923. */
  9924. export class IncrementValueAction extends Action {
  9925. /**
  9926. * The path of the property to increment in the target.
  9927. */
  9928. propertyPath: string;
  9929. /**
  9930. * The value we should increment the property by.
  9931. */
  9932. value: any;
  9933. private _target;
  9934. private _effectiveTarget;
  9935. private _property;
  9936. /**
  9937. * Instantiate the action
  9938. * @param triggerOptions defines the trigger options
  9939. * @param target defines the object containing the property
  9940. * @param propertyPath defines the path of the property to increment in the target
  9941. * @param value defines the value value we should increment the property by
  9942. * @param condition defines the trigger related conditions
  9943. */
  9944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9945. /** @hidden */
  9946. _prepare(): void;
  9947. /**
  9948. * Execute the action and increment the target of the value amount.
  9949. */
  9950. execute(): void;
  9951. /**
  9952. * Serializes the actions and its related information.
  9953. * @param parent defines the object to serialize in
  9954. * @returns the serialized object
  9955. */
  9956. serialize(parent: any): any;
  9957. }
  9958. /**
  9959. * This defines an action responsible to start an animation once triggered.
  9960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9961. */
  9962. export class PlayAnimationAction extends Action {
  9963. /**
  9964. * Where the animation should start (animation frame)
  9965. */
  9966. from: number;
  9967. /**
  9968. * Where the animation should stop (animation frame)
  9969. */
  9970. to: number;
  9971. /**
  9972. * Define if the animation should loop or stop after the first play.
  9973. */
  9974. loop?: boolean;
  9975. private _target;
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param target defines the target animation or animation name
  9980. * @param from defines from where the animation should start (animation frame)
  9981. * @param end defines where the animation should stop (animation frame)
  9982. * @param loop defines if the animation should loop or stop after the first play
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and play the animation.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible to stop an animation once triggered.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class StopAnimationAction extends Action {
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, target: any, condition?: Condition);
  10012. /** @hidden */
  10013. _prepare(): void;
  10014. /**
  10015. * Execute the action and stop the animation.
  10016. */
  10017. execute(): void;
  10018. /**
  10019. * Serializes the actions and its related information.
  10020. * @param parent defines the object to serialize in
  10021. * @returns the serialized object
  10022. */
  10023. serialize(parent: any): any;
  10024. }
  10025. /**
  10026. * This defines an action responsible that does nothing once triggered.
  10027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10028. */
  10029. export class DoNothingAction extends Action {
  10030. /**
  10031. * Instantiate the action
  10032. * @param triggerOptions defines the trigger options
  10033. * @param condition defines the trigger related conditions
  10034. */
  10035. constructor(triggerOptions?: any, condition?: Condition);
  10036. /**
  10037. * Execute the action and do nothing.
  10038. */
  10039. execute(): void;
  10040. /**
  10041. * Serializes the actions and its related information.
  10042. * @param parent defines the object to serialize in
  10043. * @returns the serialized object
  10044. */
  10045. serialize(parent: any): any;
  10046. }
  10047. /**
  10048. * This defines an action responsible to trigger several actions once triggered.
  10049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10050. */
  10051. export class CombineAction extends Action {
  10052. /**
  10053. * The list of aggregated animations to run.
  10054. */
  10055. children: Action[];
  10056. /**
  10057. * Instantiate the action
  10058. * @param triggerOptions defines the trigger options
  10059. * @param children defines the list of aggregated animations to run
  10060. * @param condition defines the trigger related conditions
  10061. */
  10062. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10063. /** @hidden */
  10064. _prepare(): void;
  10065. /**
  10066. * Execute the action and executes all the aggregated actions.
  10067. */
  10068. execute(evt: ActionEvent): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to run code (external event) once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class ExecuteCodeAction extends Action {
  10081. /**
  10082. * The callback function to run.
  10083. */
  10084. func: (evt: ActionEvent) => void;
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param func defines the callback function to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10092. /**
  10093. * Execute the action and run the attached code.
  10094. */
  10095. execute(evt: ActionEvent): void;
  10096. }
  10097. /**
  10098. * This defines an action responsible to set the parent property of the target once triggered.
  10099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10100. */
  10101. export class SetParentAction extends Action {
  10102. private _parent;
  10103. private _target;
  10104. /**
  10105. * Instantiate the action
  10106. * @param triggerOptions defines the trigger options
  10107. * @param target defines the target containing the parent property
  10108. * @param parent defines from where the animation should start (animation frame)
  10109. * @param condition defines the trigger related conditions
  10110. */
  10111. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10112. /** @hidden */
  10113. _prepare(): void;
  10114. /**
  10115. * Execute the action and set the parent property.
  10116. */
  10117. execute(): void;
  10118. /**
  10119. * Serializes the actions and its related information.
  10120. * @param parent defines the object to serialize in
  10121. * @returns the serialized object
  10122. */
  10123. serialize(parent: any): any;
  10124. }
  10125. }
  10126. declare module BABYLON {
  10127. /**
  10128. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10129. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10131. */
  10132. export class ActionManager extends AbstractActionManager {
  10133. /**
  10134. * Nothing
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly NothingTrigger: number;
  10138. /**
  10139. * On pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnPickTrigger: number;
  10143. /**
  10144. * On left pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnLeftPickTrigger: number;
  10148. /**
  10149. * On right pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnRightPickTrigger: number;
  10153. /**
  10154. * On center pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnCenterPickTrigger: number;
  10158. /**
  10159. * On pick down
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickDownTrigger: number;
  10163. /**
  10164. * On double pick
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnDoublePickTrigger: number;
  10168. /**
  10169. * On pick up
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnPickUpTrigger: number;
  10173. /**
  10174. * On pick out.
  10175. * This trigger will only be raised if you also declared a OnPickDown
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnPickOutTrigger: number;
  10179. /**
  10180. * On long press
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnLongPressTrigger: number;
  10184. /**
  10185. * On pointer over
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnPointerOverTrigger: number;
  10189. /**
  10190. * On pointer out
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOutTrigger: number;
  10194. /**
  10195. * On every frame
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnEveryFrameTrigger: number;
  10199. /**
  10200. * On intersection enter
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnIntersectionEnterTrigger: number;
  10204. /**
  10205. * On intersection exit
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionExitTrigger: number;
  10209. /**
  10210. * On key down
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnKeyDownTrigger: number;
  10214. /**
  10215. * On key up
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyUpTrigger: number;
  10219. private _scene;
  10220. /**
  10221. * Creates a new action manager
  10222. * @param scene defines the hosting scene
  10223. */
  10224. constructor(scene: Scene);
  10225. /**
  10226. * Releases all associated resources
  10227. */
  10228. dispose(): void;
  10229. /**
  10230. * Gets hosting scene
  10231. * @returns the hosting scene
  10232. */
  10233. getScene(): Scene;
  10234. /**
  10235. * Does this action manager handles actions of any of the given triggers
  10236. * @param triggers defines the triggers to be tested
  10237. * @return a boolean indicating whether one (or more) of the triggers is handled
  10238. */
  10239. hasSpecificTriggers(triggers: number[]): boolean;
  10240. /**
  10241. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10242. * speed.
  10243. * @param triggerA defines the trigger to be tested
  10244. * @param triggerB defines the trigger to be tested
  10245. * @return a boolean indicating whether one (or more) of the triggers is handled
  10246. */
  10247. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10248. /**
  10249. * Does this action manager handles actions of a given trigger
  10250. * @param trigger defines the trigger to be tested
  10251. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10252. * @return whether the trigger is handled
  10253. */
  10254. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10255. /**
  10256. * Does this action manager has pointer triggers
  10257. */
  10258. get hasPointerTriggers(): boolean;
  10259. /**
  10260. * Does this action manager has pick triggers
  10261. */
  10262. get hasPickTriggers(): boolean;
  10263. /**
  10264. * Registers an action to this action manager
  10265. * @param action defines the action to be registered
  10266. * @return the action amended (prepared) after registration
  10267. */
  10268. registerAction(action: IAction): Nullable<IAction>;
  10269. /**
  10270. * Unregisters an action to this action manager
  10271. * @param action defines the action to be unregistered
  10272. * @return a boolean indicating whether the action has been unregistered
  10273. */
  10274. unregisterAction(action: IAction): Boolean;
  10275. /**
  10276. * Process a specific trigger
  10277. * @param trigger defines the trigger to process
  10278. * @param evt defines the event details to be processed
  10279. */
  10280. processTrigger(trigger: number, evt?: IActionEvent): void;
  10281. /** @hidden */
  10282. _getEffectiveTarget(target: any, propertyPath: string): any;
  10283. /** @hidden */
  10284. _getProperty(propertyPath: string): string;
  10285. /**
  10286. * Serialize this manager to a JSON object
  10287. * @param name defines the property name to store this manager
  10288. * @returns a JSON representation of this manager
  10289. */
  10290. serialize(name: string): any;
  10291. /**
  10292. * Creates a new ActionManager from a JSON data
  10293. * @param parsedActions defines the JSON data to read from
  10294. * @param object defines the hosting mesh
  10295. * @param scene defines the hosting scene
  10296. */
  10297. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10298. /**
  10299. * Get a trigger name by index
  10300. * @param trigger defines the trigger index
  10301. * @returns a trigger name
  10302. */
  10303. static GetTriggerName(trigger: number): string;
  10304. }
  10305. }
  10306. declare module BABYLON {
  10307. /**
  10308. * Class used to represent a sprite
  10309. * @see https://doc.babylonjs.com/babylon101/sprites
  10310. */
  10311. export class Sprite implements IAnimatable {
  10312. /** defines the name */
  10313. name: string;
  10314. /** Gets or sets the current world position */
  10315. position: Vector3;
  10316. /** Gets or sets the main color */
  10317. color: Color4;
  10318. /** Gets or sets the width */
  10319. width: number;
  10320. /** Gets or sets the height */
  10321. height: number;
  10322. /** Gets or sets rotation angle */
  10323. angle: number;
  10324. /** Gets or sets the cell index in the sprite sheet */
  10325. cellIndex: number;
  10326. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10327. cellRef: string;
  10328. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10329. invertU: boolean;
  10330. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10331. invertV: boolean;
  10332. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10333. disposeWhenFinishedAnimating: boolean;
  10334. /** Gets the list of attached animations */
  10335. animations: Nullable<Array<Animation>>;
  10336. /** Gets or sets a boolean indicating if the sprite can be picked */
  10337. isPickable: boolean;
  10338. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10339. useAlphaForPicking: boolean;
  10340. /** @hidden */
  10341. _xOffset: number;
  10342. /** @hidden */
  10343. _yOffset: number;
  10344. /** @hidden */
  10345. _xSize: number;
  10346. /** @hidden */
  10347. _ySize: number;
  10348. /**
  10349. * Gets or sets the associated action manager
  10350. */
  10351. actionManager: Nullable<ActionManager>;
  10352. /**
  10353. * An event triggered when the control has been disposed
  10354. */
  10355. onDisposeObservable: Observable<Sprite>;
  10356. private _animationStarted;
  10357. private _loopAnimation;
  10358. private _fromIndex;
  10359. private _toIndex;
  10360. private _delay;
  10361. private _direction;
  10362. private _manager;
  10363. private _time;
  10364. private _onAnimationEnd;
  10365. /**
  10366. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10367. */
  10368. isVisible: boolean;
  10369. /**
  10370. * Gets or sets the sprite size
  10371. */
  10372. get size(): number;
  10373. set size(value: number);
  10374. /**
  10375. * Returns a boolean indicating if the animation is started
  10376. */
  10377. get animationStarted(): boolean;
  10378. /**
  10379. * Gets or sets the unique id of the sprite
  10380. */
  10381. uniqueId: number;
  10382. /**
  10383. * Gets the manager of this sprite
  10384. */
  10385. get manager(): ISpriteManager;
  10386. /**
  10387. * Creates a new Sprite
  10388. * @param name defines the name
  10389. * @param manager defines the manager
  10390. */
  10391. constructor(
  10392. /** defines the name */
  10393. name: string, manager: ISpriteManager);
  10394. /**
  10395. * Returns the string "Sprite"
  10396. * @returns "Sprite"
  10397. */
  10398. getClassName(): string;
  10399. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10400. get fromIndex(): number;
  10401. set fromIndex(value: number);
  10402. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10403. get toIndex(): number;
  10404. set toIndex(value: number);
  10405. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10406. get loopAnimation(): boolean;
  10407. set loopAnimation(value: boolean);
  10408. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10409. get delay(): number;
  10410. set delay(value: number);
  10411. /**
  10412. * Starts an animation
  10413. * @param from defines the initial key
  10414. * @param to defines the end key
  10415. * @param loop defines if the animation must loop
  10416. * @param delay defines the start delay (in ms)
  10417. * @param onAnimationEnd defines a callback to call when animation ends
  10418. */
  10419. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10420. /** Stops current animation (if any) */
  10421. stopAnimation(): void;
  10422. /** @hidden */
  10423. _animate(deltaTime: number): void;
  10424. /** Release associated resources */
  10425. dispose(): void;
  10426. /**
  10427. * Serializes the sprite to a JSON object
  10428. * @returns the JSON object
  10429. */
  10430. serialize(): any;
  10431. /**
  10432. * Parses a JSON object to create a new sprite
  10433. * @param parsedSprite The JSON object to parse
  10434. * @param manager defines the hosting manager
  10435. * @returns the new sprite
  10436. */
  10437. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10438. }
  10439. }
  10440. declare module BABYLON {
  10441. /**
  10442. * Information about the result of picking within a scene
  10443. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10444. */
  10445. export class PickingInfo {
  10446. /** @hidden */
  10447. _pickingUnavailable: boolean;
  10448. /**
  10449. * If the pick collided with an object
  10450. */
  10451. hit: boolean;
  10452. /**
  10453. * Distance away where the pick collided
  10454. */
  10455. distance: number;
  10456. /**
  10457. * The location of pick collision
  10458. */
  10459. pickedPoint: Nullable<Vector3>;
  10460. /**
  10461. * The mesh corresponding the the pick collision
  10462. */
  10463. pickedMesh: Nullable<AbstractMesh>;
  10464. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10465. bu: number;
  10466. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10467. bv: number;
  10468. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10469. faceId: number;
  10470. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10471. subMeshFaceId: number;
  10472. /** Id of the the submesh that was picked */
  10473. subMeshId: number;
  10474. /** If a sprite was picked, this will be the sprite the pick collided with */
  10475. pickedSprite: Nullable<Sprite>;
  10476. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10477. thinInstanceIndex: number;
  10478. /**
  10479. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10480. */
  10481. originMesh: Nullable<AbstractMesh>;
  10482. /**
  10483. * The ray that was used to perform the picking.
  10484. */
  10485. ray: Nullable<Ray>;
  10486. /**
  10487. * Gets the normal correspodning to the face the pick collided with
  10488. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10489. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10490. * @returns The normal correspodning to the face the pick collided with
  10491. */
  10492. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10493. /**
  10494. * Gets the texture coordinates of where the pick occured
  10495. * @returns the vector containing the coordnates of the texture
  10496. */
  10497. getTextureCoordinates(): Nullable<Vector2>;
  10498. }
  10499. }
  10500. declare module BABYLON {
  10501. /**
  10502. * Class representing a ray with position and direction
  10503. */
  10504. export class Ray {
  10505. /** origin point */
  10506. origin: Vector3;
  10507. /** direction */
  10508. direction: Vector3;
  10509. /** length of the ray */
  10510. length: number;
  10511. private static readonly _TmpVector3;
  10512. private _tmpRay;
  10513. /**
  10514. * Creates a new ray
  10515. * @param origin origin point
  10516. * @param direction direction
  10517. * @param length length of the ray
  10518. */
  10519. constructor(
  10520. /** origin point */
  10521. origin: Vector3,
  10522. /** direction */
  10523. direction: Vector3,
  10524. /** length of the ray */
  10525. length?: number);
  10526. /**
  10527. * Checks if the ray intersects a box
  10528. * This does not account for the ray lenght by design to improve perfs.
  10529. * @param minimum bound of the box
  10530. * @param maximum bound of the box
  10531. * @param intersectionTreshold extra extend to be added to the box in all direction
  10532. * @returns if the box was hit
  10533. */
  10534. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10535. /**
  10536. * Checks if the ray intersects a box
  10537. * This does not account for the ray lenght by design to improve perfs.
  10538. * @param box the bounding box to check
  10539. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10540. * @returns if the box was hit
  10541. */
  10542. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10543. /**
  10544. * If the ray hits a sphere
  10545. * @param sphere the bounding sphere to check
  10546. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10547. * @returns true if it hits the sphere
  10548. */
  10549. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10550. /**
  10551. * If the ray hits a triange
  10552. * @param vertex0 triangle vertex
  10553. * @param vertex1 triangle vertex
  10554. * @param vertex2 triangle vertex
  10555. * @returns intersection information if hit
  10556. */
  10557. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10558. /**
  10559. * Checks if ray intersects a plane
  10560. * @param plane the plane to check
  10561. * @returns the distance away it was hit
  10562. */
  10563. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10564. /**
  10565. * Calculate the intercept of a ray on a given axis
  10566. * @param axis to check 'x' | 'y' | 'z'
  10567. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10568. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10569. */
  10570. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10571. /**
  10572. * Checks if ray intersects a mesh
  10573. * @param mesh the mesh to check
  10574. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10575. * @returns picking info of the intersecton
  10576. */
  10577. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10578. /**
  10579. * Checks if ray intersects a mesh
  10580. * @param meshes the meshes to check
  10581. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10582. * @param results array to store result in
  10583. * @returns Array of picking infos
  10584. */
  10585. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10586. private _comparePickingInfo;
  10587. private static smallnum;
  10588. private static rayl;
  10589. /**
  10590. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10591. * @param sega the first point of the segment to test the intersection against
  10592. * @param segb the second point of the segment to test the intersection against
  10593. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10594. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10595. */
  10596. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10597. /**
  10598. * Update the ray from viewport position
  10599. * @param x position
  10600. * @param y y position
  10601. * @param viewportWidth viewport width
  10602. * @param viewportHeight viewport height
  10603. * @param world world matrix
  10604. * @param view view matrix
  10605. * @param projection projection matrix
  10606. * @returns this ray updated
  10607. */
  10608. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10609. /**
  10610. * Creates a ray with origin and direction of 0,0,0
  10611. * @returns the new ray
  10612. */
  10613. static Zero(): Ray;
  10614. /**
  10615. * Creates a new ray from screen space and viewport
  10616. * @param x position
  10617. * @param y y position
  10618. * @param viewportWidth viewport width
  10619. * @param viewportHeight viewport height
  10620. * @param world world matrix
  10621. * @param view view matrix
  10622. * @param projection projection matrix
  10623. * @returns new ray
  10624. */
  10625. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10626. /**
  10627. * 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
  10628. * transformed to the given world matrix.
  10629. * @param origin The origin point
  10630. * @param end The end point
  10631. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10632. * @returns the new ray
  10633. */
  10634. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10635. /**
  10636. * Transforms a ray by a matrix
  10637. * @param ray ray to transform
  10638. * @param matrix matrix to apply
  10639. * @returns the resulting new ray
  10640. */
  10641. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10642. /**
  10643. * Transforms a ray by a matrix
  10644. * @param ray ray to transform
  10645. * @param matrix matrix to apply
  10646. * @param result ray to store result in
  10647. */
  10648. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10649. /**
  10650. * Unproject a ray from screen space to object space
  10651. * @param sourceX defines the screen space x coordinate to use
  10652. * @param sourceY defines the screen space y coordinate to use
  10653. * @param viewportWidth defines the current width of the viewport
  10654. * @param viewportHeight defines the current height of the viewport
  10655. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10656. * @param view defines the view matrix to use
  10657. * @param projection defines the projection matrix to use
  10658. */
  10659. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10660. }
  10661. /**
  10662. * Type used to define predicate used to select faces when a mesh intersection is detected
  10663. */
  10664. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10665. interface Scene {
  10666. /** @hidden */
  10667. _tempPickingRay: Nullable<Ray>;
  10668. /** @hidden */
  10669. _cachedRayForTransform: Ray;
  10670. /** @hidden */
  10671. _pickWithRayInverseMatrix: Matrix;
  10672. /** @hidden */
  10673. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10674. /** @hidden */
  10675. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10676. /** @hidden */
  10677. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10678. }
  10679. }
  10680. declare module BABYLON {
  10681. /**
  10682. * Groups all the scene component constants in one place to ease maintenance.
  10683. * @hidden
  10684. */
  10685. export class SceneComponentConstants {
  10686. static readonly NAME_EFFECTLAYER: string;
  10687. static readonly NAME_LAYER: string;
  10688. static readonly NAME_LENSFLARESYSTEM: string;
  10689. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10690. static readonly NAME_PARTICLESYSTEM: string;
  10691. static readonly NAME_GAMEPAD: string;
  10692. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10693. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10694. static readonly NAME_PREPASSRENDERER: string;
  10695. static readonly NAME_DEPTHRENDERER: string;
  10696. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10697. static readonly NAME_SPRITE: string;
  10698. static readonly NAME_SUBSURFACE: string;
  10699. static readonly NAME_OUTLINERENDERER: string;
  10700. static readonly NAME_PROCEDURALTEXTURE: string;
  10701. static readonly NAME_SHADOWGENERATOR: string;
  10702. static readonly NAME_OCTREE: string;
  10703. static readonly NAME_PHYSICSENGINE: string;
  10704. static readonly NAME_AUDIO: string;
  10705. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10706. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10707. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10708. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10709. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10710. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10711. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10712. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10713. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10714. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10715. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10716. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10717. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10718. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10719. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10720. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10721. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10722. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10723. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10724. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10725. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10726. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10727. static readonly STEP_AFTERRENDER_AUDIO: number;
  10728. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10729. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10730. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10731. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10732. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10733. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10734. static readonly STEP_POINTERMOVE_SPRITE: number;
  10735. static readonly STEP_POINTERDOWN_SPRITE: number;
  10736. static readonly STEP_POINTERUP_SPRITE: number;
  10737. }
  10738. /**
  10739. * This represents a scene component.
  10740. *
  10741. * This is used to decouple the dependency the scene is having on the different workloads like
  10742. * layers, post processes...
  10743. */
  10744. export interface ISceneComponent {
  10745. /**
  10746. * The name of the component. Each component must have a unique name.
  10747. */
  10748. name: string;
  10749. /**
  10750. * The scene the component belongs to.
  10751. */
  10752. scene: Scene;
  10753. /**
  10754. * Register the component to one instance of a scene.
  10755. */
  10756. register(): void;
  10757. /**
  10758. * Rebuilds the elements related to this component in case of
  10759. * context lost for instance.
  10760. */
  10761. rebuild(): void;
  10762. /**
  10763. * Disposes the component and the associated ressources.
  10764. */
  10765. dispose(): void;
  10766. }
  10767. /**
  10768. * This represents a SERIALIZABLE scene component.
  10769. *
  10770. * This extends Scene Component to add Serialization methods on top.
  10771. */
  10772. export interface ISceneSerializableComponent extends ISceneComponent {
  10773. /**
  10774. * Adds all the elements from the container to the scene
  10775. * @param container the container holding the elements
  10776. */
  10777. addFromContainer(container: AbstractScene): void;
  10778. /**
  10779. * Removes all the elements in the container from the scene
  10780. * @param container contains the elements to remove
  10781. * @param dispose if the removed element should be disposed (default: false)
  10782. */
  10783. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10784. /**
  10785. * Serializes the component data to the specified json object
  10786. * @param serializationObject The object to serialize to
  10787. */
  10788. serialize(serializationObject: any): void;
  10789. }
  10790. /**
  10791. * Strong typing of a Mesh related stage step action
  10792. */
  10793. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10794. /**
  10795. * Strong typing of a Evaluate Sub Mesh related stage step action
  10796. */
  10797. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10798. /**
  10799. * Strong typing of a Active Mesh related stage step action
  10800. */
  10801. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10802. /**
  10803. * Strong typing of a Camera related stage step action
  10804. */
  10805. export type CameraStageAction = (camera: Camera) => void;
  10806. /**
  10807. * Strong typing of a Camera Frame buffer related stage step action
  10808. */
  10809. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10810. /**
  10811. * Strong typing of a Render Target related stage step action
  10812. */
  10813. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10814. /**
  10815. * Strong typing of a RenderingGroup related stage step action
  10816. */
  10817. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10818. /**
  10819. * Strong typing of a Mesh Render related stage step action
  10820. */
  10821. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10822. /**
  10823. * Strong typing of a simple stage step action
  10824. */
  10825. export type SimpleStageAction = () => void;
  10826. /**
  10827. * Strong typing of a render target action.
  10828. */
  10829. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10830. /**
  10831. * Strong typing of a pointer move action.
  10832. */
  10833. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10834. /**
  10835. * Strong typing of a pointer up/down action.
  10836. */
  10837. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10838. /**
  10839. * Representation of a stage in the scene (Basically a list of ordered steps)
  10840. * @hidden
  10841. */
  10842. export class Stage<T extends Function> extends Array<{
  10843. index: number;
  10844. component: ISceneComponent;
  10845. action: T;
  10846. }> {
  10847. /**
  10848. * Hide ctor from the rest of the world.
  10849. * @param items The items to add.
  10850. */
  10851. private constructor();
  10852. /**
  10853. * Creates a new Stage.
  10854. * @returns A new instance of a Stage
  10855. */
  10856. static Create<T extends Function>(): Stage<T>;
  10857. /**
  10858. * Registers a step in an ordered way in the targeted stage.
  10859. * @param index Defines the position to register the step in
  10860. * @param component Defines the component attached to the step
  10861. * @param action Defines the action to launch during the step
  10862. */
  10863. registerStep(index: number, component: ISceneComponent, action: T): void;
  10864. /**
  10865. * Clears all the steps from the stage.
  10866. */
  10867. clear(): void;
  10868. }
  10869. }
  10870. declare module BABYLON {
  10871. interface Scene {
  10872. /** @hidden */
  10873. _pointerOverSprite: Nullable<Sprite>;
  10874. /** @hidden */
  10875. _pickedDownSprite: Nullable<Sprite>;
  10876. /** @hidden */
  10877. _tempSpritePickingRay: Nullable<Ray>;
  10878. /**
  10879. * All of the sprite managers added to this scene
  10880. * @see https://doc.babylonjs.com/babylon101/sprites
  10881. */
  10882. spriteManagers: Array<ISpriteManager>;
  10883. /**
  10884. * An event triggered when sprites rendering is about to start
  10885. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10886. */
  10887. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10888. /**
  10889. * An event triggered when sprites rendering is done
  10890. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10891. */
  10892. onAfterSpritesRenderingObservable: Observable<Scene>;
  10893. /** @hidden */
  10894. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10895. /** Launch a ray to try to pick a sprite in the scene
  10896. * @param x position on screen
  10897. * @param y position on screen
  10898. * @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
  10899. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10900. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10901. * @returns a PickingInfo
  10902. */
  10903. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10904. /** Use the given ray to pick a sprite in the scene
  10905. * @param ray The ray (in world space) to use to pick meshes
  10906. * @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
  10907. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10908. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10909. * @returns a PickingInfo
  10910. */
  10911. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10912. /** @hidden */
  10913. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10914. /** Launch a ray to try to pick sprites in the scene
  10915. * @param x position on screen
  10916. * @param y position on screen
  10917. * @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
  10918. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10919. * @returns a PickingInfo array
  10920. */
  10921. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10922. /** Use the given ray to pick sprites in the scene
  10923. * @param ray The ray (in world space) to use to pick meshes
  10924. * @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
  10925. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10926. * @returns a PickingInfo array
  10927. */
  10928. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10929. /**
  10930. * Force the sprite under the pointer
  10931. * @param sprite defines the sprite to use
  10932. */
  10933. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10934. /**
  10935. * Gets the sprite under the pointer
  10936. * @returns a Sprite or null if no sprite is under the pointer
  10937. */
  10938. getPointerOverSprite(): Nullable<Sprite>;
  10939. }
  10940. /**
  10941. * Defines the sprite scene component responsible to manage sprites
  10942. * in a given scene.
  10943. */
  10944. export class SpriteSceneComponent implements ISceneComponent {
  10945. /**
  10946. * The component name helpfull to identify the component in the list of scene components.
  10947. */
  10948. readonly name: string;
  10949. /**
  10950. * The scene the component belongs to.
  10951. */
  10952. scene: Scene;
  10953. /** @hidden */
  10954. private _spritePredicate;
  10955. /**
  10956. * Creates a new instance of the component for the given scene
  10957. * @param scene Defines the scene to register the component in
  10958. */
  10959. constructor(scene: Scene);
  10960. /**
  10961. * Registers the component in a given scene
  10962. */
  10963. register(): void;
  10964. /**
  10965. * Rebuilds the elements related to this component in case of
  10966. * context lost for instance.
  10967. */
  10968. rebuild(): void;
  10969. /**
  10970. * Disposes the component and the associated ressources.
  10971. */
  10972. dispose(): void;
  10973. private _pickSpriteButKeepRay;
  10974. private _pointerMove;
  10975. private _pointerDown;
  10976. private _pointerUp;
  10977. }
  10978. }
  10979. declare module BABYLON {
  10980. /** @hidden */
  10981. export var fogFragmentDeclaration: {
  10982. name: string;
  10983. shader: string;
  10984. };
  10985. }
  10986. declare module BABYLON {
  10987. /** @hidden */
  10988. export var fogFragment: {
  10989. name: string;
  10990. shader: string;
  10991. };
  10992. }
  10993. declare module BABYLON {
  10994. /** @hidden */
  10995. export var imageProcessingCompatibility: {
  10996. name: string;
  10997. shader: string;
  10998. };
  10999. }
  11000. declare module BABYLON {
  11001. /** @hidden */
  11002. export var spritesPixelShader: {
  11003. name: string;
  11004. shader: string;
  11005. };
  11006. }
  11007. declare module BABYLON {
  11008. /** @hidden */
  11009. export var fogVertexDeclaration: {
  11010. name: string;
  11011. shader: string;
  11012. };
  11013. }
  11014. declare module BABYLON {
  11015. /** @hidden */
  11016. export var spritesVertexShader: {
  11017. name: string;
  11018. shader: string;
  11019. };
  11020. }
  11021. declare module BABYLON {
  11022. /**
  11023. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11024. */
  11025. export interface ISpriteManager extends IDisposable {
  11026. /**
  11027. * Gets manager's name
  11028. */
  11029. name: string;
  11030. /**
  11031. * Restricts the camera to viewing objects with the same layerMask.
  11032. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11033. */
  11034. layerMask: number;
  11035. /**
  11036. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11037. */
  11038. isPickable: boolean;
  11039. /**
  11040. * Gets the hosting scene
  11041. */
  11042. scene: Scene;
  11043. /**
  11044. * Specifies the rendering group id for this mesh (0 by default)
  11045. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11046. */
  11047. renderingGroupId: number;
  11048. /**
  11049. * Defines the list of sprites managed by the manager.
  11050. */
  11051. sprites: Array<Sprite>;
  11052. /**
  11053. * Gets or sets the spritesheet texture
  11054. */
  11055. texture: Texture;
  11056. /** Defines the default width of a cell in the spritesheet */
  11057. cellWidth: number;
  11058. /** Defines the default height of a cell in the spritesheet */
  11059. cellHeight: number;
  11060. /**
  11061. * Tests the intersection of a sprite with a specific ray.
  11062. * @param ray The ray we are sending to test the collision
  11063. * @param camera The camera space we are sending rays in
  11064. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11065. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11066. * @returns picking info or null.
  11067. */
  11068. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11069. /**
  11070. * Intersects the sprites with a ray
  11071. * @param ray defines the ray to intersect with
  11072. * @param camera defines the current active camera
  11073. * @param predicate defines a predicate used to select candidate sprites
  11074. * @returns null if no hit or a PickingInfo array
  11075. */
  11076. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11077. /**
  11078. * Renders the list of sprites on screen.
  11079. */
  11080. render(): void;
  11081. }
  11082. /**
  11083. * Class used to manage multiple sprites on the same spritesheet
  11084. * @see https://doc.babylonjs.com/babylon101/sprites
  11085. */
  11086. export class SpriteManager implements ISpriteManager {
  11087. /** defines the manager's name */
  11088. name: string;
  11089. /** Define the Url to load snippets */
  11090. static SnippetUrl: string;
  11091. /** Snippet ID if the manager was created from the snippet server */
  11092. snippetId: string;
  11093. /** Gets the list of sprites */
  11094. sprites: Sprite[];
  11095. /** Gets or sets the rendering group id (0 by default) */
  11096. renderingGroupId: number;
  11097. /** Gets or sets camera layer mask */
  11098. layerMask: number;
  11099. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11100. fogEnabled: boolean;
  11101. /** Gets or sets a boolean indicating if the sprites are pickable */
  11102. isPickable: boolean;
  11103. /** Defines the default width of a cell in the spritesheet */
  11104. cellWidth: number;
  11105. /** Defines the default height of a cell in the spritesheet */
  11106. cellHeight: number;
  11107. /** Associative array from JSON sprite data file */
  11108. private _cellData;
  11109. /** Array of sprite names from JSON sprite data file */
  11110. private _spriteMap;
  11111. /** True when packed cell data from JSON file is ready*/
  11112. private _packedAndReady;
  11113. private _textureContent;
  11114. private _useInstancing;
  11115. /**
  11116. * An event triggered when the manager is disposed.
  11117. */
  11118. onDisposeObservable: Observable<SpriteManager>;
  11119. private _onDisposeObserver;
  11120. /**
  11121. * Callback called when the manager is disposed
  11122. */
  11123. set onDispose(callback: () => void);
  11124. private _capacity;
  11125. private _fromPacked;
  11126. private _spriteTexture;
  11127. private _epsilon;
  11128. private _scene;
  11129. private _vertexData;
  11130. private _buffer;
  11131. private _vertexBuffers;
  11132. private _spriteBuffer;
  11133. private _indexBuffer;
  11134. private _effectBase;
  11135. private _effectFog;
  11136. private _vertexBufferSize;
  11137. /**
  11138. * Gets or sets the unique id of the sprite
  11139. */
  11140. uniqueId: number;
  11141. /**
  11142. * Gets the array of sprites
  11143. */
  11144. get children(): Sprite[];
  11145. /**
  11146. * Gets the hosting scene
  11147. */
  11148. get scene(): Scene;
  11149. /**
  11150. * Gets the capacity of the manager
  11151. */
  11152. get capacity(): number;
  11153. /**
  11154. * Gets or sets the spritesheet texture
  11155. */
  11156. get texture(): Texture;
  11157. set texture(value: Texture);
  11158. private _blendMode;
  11159. /**
  11160. * Blend mode use to render the particle, it can be any of
  11161. * the static Constants.ALPHA_x properties provided in this class.
  11162. * Default value is Constants.ALPHA_COMBINE
  11163. */
  11164. get blendMode(): number;
  11165. set blendMode(blendMode: number);
  11166. /** Disables writing to the depth buffer when rendering the sprites.
  11167. * It can be handy to disable depth writing when using textures without alpha channel
  11168. * and setting some specific blend modes.
  11169. */
  11170. disableDepthWrite: boolean;
  11171. /**
  11172. * Creates a new sprite manager
  11173. * @param name defines the manager's name
  11174. * @param imgUrl defines the sprite sheet url
  11175. * @param capacity defines the maximum allowed number of sprites
  11176. * @param cellSize defines the size of a sprite cell
  11177. * @param scene defines the hosting scene
  11178. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11179. * @param samplingMode defines the smapling mode to use with spritesheet
  11180. * @param fromPacked set to false; do not alter
  11181. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11182. */
  11183. constructor(
  11184. /** defines the manager's name */
  11185. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11186. /**
  11187. * Returns the string "SpriteManager"
  11188. * @returns "SpriteManager"
  11189. */
  11190. getClassName(): string;
  11191. private _makePacked;
  11192. private _appendSpriteVertex;
  11193. private _checkTextureAlpha;
  11194. /**
  11195. * Intersects the sprites with a ray
  11196. * @param ray defines the ray to intersect with
  11197. * @param camera defines the current active camera
  11198. * @param predicate defines a predicate used to select candidate sprites
  11199. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11200. * @returns null if no hit or a PickingInfo
  11201. */
  11202. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11203. /**
  11204. * Intersects the sprites with a ray
  11205. * @param ray defines the ray to intersect with
  11206. * @param camera defines the current active camera
  11207. * @param predicate defines a predicate used to select candidate sprites
  11208. * @returns null if no hit or a PickingInfo array
  11209. */
  11210. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11211. /**
  11212. * Render all child sprites
  11213. */
  11214. render(): void;
  11215. /**
  11216. * Release associated resources
  11217. */
  11218. dispose(): void;
  11219. /**
  11220. * Serializes the sprite manager to a JSON object
  11221. * @param serializeTexture defines if the texture must be serialized as well
  11222. * @returns the JSON object
  11223. */
  11224. serialize(serializeTexture?: boolean): any;
  11225. /**
  11226. * Parses a JSON object to create a new sprite manager.
  11227. * @param parsedManager The JSON object to parse
  11228. * @param scene The scene to create the sprite managerin
  11229. * @param rootUrl The root url to use to load external dependencies like texture
  11230. * @returns the new sprite manager
  11231. */
  11232. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11233. /**
  11234. * Creates a sprite manager from a snippet saved in a remote file
  11235. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11236. * @param url defines the url to load from
  11237. * @param scene defines the hosting scene
  11238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11239. * @returns a promise that will resolve to the new sprite manager
  11240. */
  11241. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11242. /**
  11243. * Creates a sprite manager from a snippet saved by the sprite editor
  11244. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11245. * @param scene defines the hosting scene
  11246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11247. * @returns a promise that will resolve to the new sprite manager
  11248. */
  11249. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11250. }
  11251. }
  11252. declare module BABYLON {
  11253. /** Interface used by value gradients (color, factor, ...) */
  11254. export interface IValueGradient {
  11255. /**
  11256. * Gets or sets the gradient value (between 0 and 1)
  11257. */
  11258. gradient: number;
  11259. }
  11260. /** Class used to store color4 gradient */
  11261. export class ColorGradient implements IValueGradient {
  11262. /**
  11263. * Gets or sets the gradient value (between 0 and 1)
  11264. */
  11265. gradient: number;
  11266. /**
  11267. * Gets or sets first associated color
  11268. */
  11269. color1: Color4;
  11270. /**
  11271. * Gets or sets second associated color
  11272. */
  11273. color2?: Color4 | undefined;
  11274. /**
  11275. * Creates a new color4 gradient
  11276. * @param gradient gets or sets the gradient value (between 0 and 1)
  11277. * @param color1 gets or sets first associated color
  11278. * @param color2 gets or sets first second color
  11279. */
  11280. constructor(
  11281. /**
  11282. * Gets or sets the gradient value (between 0 and 1)
  11283. */
  11284. gradient: number,
  11285. /**
  11286. * Gets or sets first associated color
  11287. */
  11288. color1: Color4,
  11289. /**
  11290. * Gets or sets second associated color
  11291. */
  11292. color2?: Color4 | undefined);
  11293. /**
  11294. * Will get a color picked randomly between color1 and color2.
  11295. * If color2 is undefined then color1 will be used
  11296. * @param result defines the target Color4 to store the result in
  11297. */
  11298. getColorToRef(result: Color4): void;
  11299. }
  11300. /** Class used to store color 3 gradient */
  11301. export class Color3Gradient implements IValueGradient {
  11302. /**
  11303. * Gets or sets the gradient value (between 0 and 1)
  11304. */
  11305. gradient: number;
  11306. /**
  11307. * Gets or sets the associated color
  11308. */
  11309. color: Color3;
  11310. /**
  11311. * Creates a new color3 gradient
  11312. * @param gradient gets or sets the gradient value (between 0 and 1)
  11313. * @param color gets or sets associated color
  11314. */
  11315. constructor(
  11316. /**
  11317. * Gets or sets the gradient value (between 0 and 1)
  11318. */
  11319. gradient: number,
  11320. /**
  11321. * Gets or sets the associated color
  11322. */
  11323. color: Color3);
  11324. }
  11325. /** Class used to store factor gradient */
  11326. export class FactorGradient implements IValueGradient {
  11327. /**
  11328. * Gets or sets the gradient value (between 0 and 1)
  11329. */
  11330. gradient: number;
  11331. /**
  11332. * Gets or sets first associated factor
  11333. */
  11334. factor1: number;
  11335. /**
  11336. * Gets or sets second associated factor
  11337. */
  11338. factor2?: number | undefined;
  11339. /**
  11340. * Creates a new factor gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param factor1 gets or sets first associated factor
  11343. * @param factor2 gets or sets second associated factor
  11344. */
  11345. constructor(
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number,
  11350. /**
  11351. * Gets or sets first associated factor
  11352. */
  11353. factor1: number,
  11354. /**
  11355. * Gets or sets second associated factor
  11356. */
  11357. factor2?: number | undefined);
  11358. /**
  11359. * Will get a number picked randomly between factor1 and factor2.
  11360. * If factor2 is undefined then factor1 will be used
  11361. * @returns the picked number
  11362. */
  11363. getFactor(): number;
  11364. }
  11365. /**
  11366. * Helper used to simplify some generic gradient tasks
  11367. */
  11368. export class GradientHelper {
  11369. /**
  11370. * Gets the current gradient from an array of IValueGradient
  11371. * @param ratio defines the current ratio to get
  11372. * @param gradients defines the array of IValueGradient
  11373. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11374. */
  11375. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11376. }
  11377. }
  11378. declare module BABYLON {
  11379. interface ThinEngine {
  11380. /**
  11381. * Creates a raw texture
  11382. * @param data defines the data to store in the texture
  11383. * @param width defines the width of the texture
  11384. * @param height defines the height of the texture
  11385. * @param format defines the format of the data
  11386. * @param generateMipMaps defines if the engine should generate the mip levels
  11387. * @param invertY defines if data must be stored with Y axis inverted
  11388. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11389. * @param compression defines the compression used (null by default)
  11390. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11391. * @returns the raw texture inside an InternalTexture
  11392. */
  11393. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11394. /**
  11395. * Update a raw texture
  11396. * @param texture defines the texture to update
  11397. * @param data defines the data to store in the texture
  11398. * @param format defines the format of the data
  11399. * @param invertY defines if data must be stored with Y axis inverted
  11400. */
  11401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11402. /**
  11403. * Update a raw texture
  11404. * @param texture defines the texture to update
  11405. * @param data defines the data to store in the texture
  11406. * @param format defines the format of the data
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param compression defines the compression used (null by default)
  11409. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11410. */
  11411. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11412. /**
  11413. * Creates a new raw cube texture
  11414. * @param data defines the array of data to use to create each face
  11415. * @param size defines the size of the textures
  11416. * @param format defines the format of the data
  11417. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11418. * @param generateMipMaps defines if the engine should generate the mip levels
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11421. * @param compression defines the compression used (null by default)
  11422. * @returns the cube texture as an InternalTexture
  11423. */
  11424. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11425. /**
  11426. * Update a raw cube texture
  11427. * @param texture defines the texture to udpdate
  11428. * @param data defines the data to store
  11429. * @param format defines the data format
  11430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. */
  11433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11434. /**
  11435. * Update a raw cube texture
  11436. * @param texture defines the texture to udpdate
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param compression defines the compression used (null by default)
  11442. */
  11443. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11444. /**
  11445. * Update a raw cube texture
  11446. * @param texture defines the texture to udpdate
  11447. * @param data defines the data to store
  11448. * @param format defines the data format
  11449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the compression used (null by default)
  11452. * @param level defines which level of the texture to update
  11453. */
  11454. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11455. /**
  11456. * Creates a new raw cube texture from a specified url
  11457. * @param url defines the url where the data is located
  11458. * @param scene defines the current scene
  11459. * @param size defines the size of the textures
  11460. * @param format defines the format of the data
  11461. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11462. * @param noMipmap defines if the engine should avoid generating the mip levels
  11463. * @param callback defines a callback used to extract texture data from loaded data
  11464. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11465. * @param onLoad defines a callback called when texture is loaded
  11466. * @param onError defines a callback called if there is an error
  11467. * @returns the cube texture as an InternalTexture
  11468. */
  11469. 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;
  11470. /**
  11471. * Creates a new raw cube texture from a specified url
  11472. * @param url defines the url where the data is located
  11473. * @param scene defines the current scene
  11474. * @param size defines the size of the textures
  11475. * @param format defines the format of the data
  11476. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11477. * @param noMipmap defines if the engine should avoid generating the mip levels
  11478. * @param callback defines a callback used to extract texture data from loaded data
  11479. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11480. * @param onLoad defines a callback called when texture is loaded
  11481. * @param onError defines a callback called if there is an error
  11482. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @returns the cube texture as an InternalTexture
  11485. */
  11486. 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;
  11487. /**
  11488. * Creates a new raw 3D texture
  11489. * @param data defines the data used to create the texture
  11490. * @param width defines the width of the texture
  11491. * @param height defines the height of the texture
  11492. * @param depth defines the depth of the texture
  11493. * @param format defines the format of the texture
  11494. * @param generateMipMaps defines if the engine must generate mip levels
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param compression defines the compressed used (can be null)
  11498. * @param textureType defines the compressed used (can be null)
  11499. * @returns a new raw 3D texture (stored in an InternalTexture)
  11500. */
  11501. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11502. /**
  11503. * Update a raw 3D texture
  11504. * @param texture defines the texture to update
  11505. * @param data defines the data to store
  11506. * @param format defines the data format
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. */
  11509. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11510. /**
  11511. * Update a raw 3D texture
  11512. * @param texture defines the texture to update
  11513. * @param data defines the data to store
  11514. * @param format defines the data format
  11515. * @param invertY defines if data must be stored with Y axis inverted
  11516. * @param compression defines the used compression (can be null)
  11517. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11518. */
  11519. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11520. /**
  11521. * Creates a new raw 2D array texture
  11522. * @param data defines the data used to create the texture
  11523. * @param width defines the width of the texture
  11524. * @param height defines the height of the texture
  11525. * @param depth defines the number of layers of the texture
  11526. * @param format defines the format of the texture
  11527. * @param generateMipMaps defines if the engine must generate mip levels
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11530. * @param compression defines the compressed used (can be null)
  11531. * @param textureType defines the compressed used (can be null)
  11532. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11533. */
  11534. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11535. /**
  11536. * Update a raw 2D array texture
  11537. * @param texture defines the texture to update
  11538. * @param data defines the data to store
  11539. * @param format defines the data format
  11540. * @param invertY defines if data must be stored with Y axis inverted
  11541. */
  11542. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11543. /**
  11544. * Update a raw 2D array texture
  11545. * @param texture defines the texture to update
  11546. * @param data defines the data to store
  11547. * @param format defines the data format
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param compression defines the used compression (can be null)
  11550. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11551. */
  11552. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11553. }
  11554. }
  11555. declare module BABYLON {
  11556. /**
  11557. * Raw texture can help creating a texture directly from an array of data.
  11558. * This can be super useful if you either get the data from an uncompressed source or
  11559. * if you wish to create your texture pixel by pixel.
  11560. */
  11561. export class RawTexture extends Texture {
  11562. /**
  11563. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11564. */
  11565. format: number;
  11566. /**
  11567. * Instantiates a new RawTexture.
  11568. * Raw texture can help creating a texture directly from an array of data.
  11569. * This can be super useful if you either get the data from an uncompressed source or
  11570. * if you wish to create your texture pixel by pixel.
  11571. * @param data define the array of data to use to create the texture
  11572. * @param width define the width of the texture
  11573. * @param height define the height of the texture
  11574. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11575. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11576. * @param generateMipMaps define whether mip maps should be generated or not
  11577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11579. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11580. */
  11581. constructor(data: ArrayBufferView, width: number, height: number,
  11582. /**
  11583. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11584. */
  11585. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11586. /**
  11587. * Updates the texture underlying data.
  11588. * @param data Define the new data of the texture
  11589. */
  11590. update(data: ArrayBufferView): void;
  11591. /**
  11592. * Creates a luminance texture from some data.
  11593. * @param data Define the texture data
  11594. * @param width Define the width of the texture
  11595. * @param height Define the height of the texture
  11596. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11597. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11598. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11599. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11600. * @returns the luminance texture
  11601. */
  11602. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11603. /**
  11604. * Creates a luminance alpha texture from some data.
  11605. * @param data Define the texture data
  11606. * @param width Define the width of the texture
  11607. * @param height Define the height of the texture
  11608. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11609. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11610. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11611. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11612. * @returns the luminance alpha texture
  11613. */
  11614. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11615. /**
  11616. * Creates an alpha texture from some data.
  11617. * @param data Define the texture data
  11618. * @param width Define the width of the texture
  11619. * @param height Define the height of the texture
  11620. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11621. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11624. * @returns the alpha texture
  11625. */
  11626. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11627. /**
  11628. * Creates a RGB texture from some data.
  11629. * @param data Define the texture data
  11630. * @param width Define the width of the texture
  11631. * @param height Define the height of the texture
  11632. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11633. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11637. * @returns the RGB alpha texture
  11638. */
  11639. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11640. /**
  11641. * Creates a RGBA texture from some data.
  11642. * @param data Define the texture data
  11643. * @param width Define the width of the texture
  11644. * @param height Define the height of the texture
  11645. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11646. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11647. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11648. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11649. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11650. * @returns the RGBA texture
  11651. */
  11652. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11653. /**
  11654. * Creates a R texture from some data.
  11655. * @param data Define the texture data
  11656. * @param width Define the width of the texture
  11657. * @param height Define the height of the texture
  11658. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11659. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11663. * @returns the R texture
  11664. */
  11665. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11666. }
  11667. }
  11668. declare module BABYLON {
  11669. interface ThinEngine {
  11670. /**
  11671. * Update a dynamic index buffer
  11672. * @param indexBuffer defines the target index buffer
  11673. * @param indices defines the data to update
  11674. * @param offset defines the offset in the target index buffer where update should start
  11675. */
  11676. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11677. /**
  11678. * Updates a dynamic vertex buffer.
  11679. * @param vertexBuffer the vertex buffer to update
  11680. * @param data the data used to update the vertex buffer
  11681. * @param byteOffset the byte offset of the data
  11682. * @param byteLength the byte length of the data
  11683. */
  11684. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11685. }
  11686. }
  11687. declare module BABYLON {
  11688. interface AbstractScene {
  11689. /**
  11690. * The list of procedural textures added to the scene
  11691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11692. */
  11693. proceduralTextures: Array<ProceduralTexture>;
  11694. }
  11695. /**
  11696. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11697. * in a given scene.
  11698. */
  11699. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11700. /**
  11701. * The component name helpfull to identify the component in the list of scene components.
  11702. */
  11703. readonly name: string;
  11704. /**
  11705. * The scene the component belongs to.
  11706. */
  11707. scene: Scene;
  11708. /**
  11709. * Creates a new instance of the component for the given scene
  11710. * @param scene Defines the scene to register the component in
  11711. */
  11712. constructor(scene: Scene);
  11713. /**
  11714. * Registers the component in a given scene
  11715. */
  11716. register(): void;
  11717. /**
  11718. * Rebuilds the elements related to this component in case of
  11719. * context lost for instance.
  11720. */
  11721. rebuild(): void;
  11722. /**
  11723. * Disposes the component and the associated ressources.
  11724. */
  11725. dispose(): void;
  11726. private _beforeClear;
  11727. }
  11728. }
  11729. declare module BABYLON {
  11730. interface ThinEngine {
  11731. /**
  11732. * Creates a new render target cube texture
  11733. * @param size defines the size of the texture
  11734. * @param options defines the options used to create the texture
  11735. * @returns a new render target cube texture stored in an InternalTexture
  11736. */
  11737. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11738. }
  11739. }
  11740. declare module BABYLON {
  11741. /** @hidden */
  11742. export var proceduralVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module BABYLON {
  11748. /**
  11749. * 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.
  11750. * This is the base class of any Procedural texture and contains most of the shareable code.
  11751. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11752. */
  11753. export class ProceduralTexture extends Texture {
  11754. /**
  11755. * Define if the texture is enabled or not (disabled texture will not render)
  11756. */
  11757. isEnabled: boolean;
  11758. /**
  11759. * Define if the texture must be cleared before rendering (default is true)
  11760. */
  11761. autoClear: boolean;
  11762. /**
  11763. * Callback called when the texture is generated
  11764. */
  11765. onGenerated: () => void;
  11766. /**
  11767. * Event raised when the texture is generated
  11768. */
  11769. onGeneratedObservable: Observable<ProceduralTexture>;
  11770. /**
  11771. * Event raised before the texture is generated
  11772. */
  11773. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11774. /**
  11775. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11776. */
  11777. nodeMaterialSource: Nullable<NodeMaterial>;
  11778. /** @hidden */
  11779. _generateMipMaps: boolean;
  11780. /** @hidden **/
  11781. _effect: Effect;
  11782. /** @hidden */
  11783. _textures: {
  11784. [key: string]: Texture;
  11785. };
  11786. /** @hidden */
  11787. protected _fallbackTexture: Nullable<Texture>;
  11788. private _size;
  11789. private _currentRefreshId;
  11790. private _frameId;
  11791. private _refreshRate;
  11792. private _vertexBuffers;
  11793. private _indexBuffer;
  11794. private _uniforms;
  11795. private _samplers;
  11796. private _fragment;
  11797. private _floats;
  11798. private _ints;
  11799. private _floatsArrays;
  11800. private _colors3;
  11801. private _colors4;
  11802. private _vectors2;
  11803. private _vectors3;
  11804. private _matrices;
  11805. private _fallbackTextureUsed;
  11806. private _fullEngine;
  11807. private _cachedDefines;
  11808. private _contentUpdateId;
  11809. private _contentData;
  11810. /**
  11811. * Instantiates a new procedural texture.
  11812. * 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.
  11813. * This is the base class of any Procedural texture and contains most of the shareable code.
  11814. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11815. * @param name Define the name of the texture
  11816. * @param size Define the size of the texture to create
  11817. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11818. * @param scene Define the scene the texture belongs to
  11819. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11820. * @param generateMipMaps Define if the texture should creates mip maps or not
  11821. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11822. * @param textureType The FBO internal texture type
  11823. */
  11824. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11825. /**
  11826. * The effect that is created when initializing the post process.
  11827. * @returns The created effect corresponding the the postprocess.
  11828. */
  11829. getEffect(): Effect;
  11830. /**
  11831. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11832. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11833. */
  11834. getContent(): Nullable<ArrayBufferView>;
  11835. private _createIndexBuffer;
  11836. /** @hidden */
  11837. _rebuild(): void;
  11838. /**
  11839. * Resets the texture in order to recreate its associated resources.
  11840. * This can be called in case of context loss
  11841. */
  11842. reset(): void;
  11843. protected _getDefines(): string;
  11844. /**
  11845. * Is the texture ready to be used ? (rendered at least once)
  11846. * @returns true if ready, otherwise, false.
  11847. */
  11848. isReady(): boolean;
  11849. /**
  11850. * Resets the refresh counter of the texture and start bak from scratch.
  11851. * Could be useful to regenerate the texture if it is setup to render only once.
  11852. */
  11853. resetRefreshCounter(): void;
  11854. /**
  11855. * Set the fragment shader to use in order to render the texture.
  11856. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11857. */
  11858. setFragment(fragment: any): void;
  11859. /**
  11860. * Define the refresh rate of the texture or the rendering frequency.
  11861. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11862. */
  11863. get refreshRate(): number;
  11864. set refreshRate(value: number);
  11865. /** @hidden */
  11866. _shouldRender(): boolean;
  11867. /**
  11868. * Get the size the texture is rendering at.
  11869. * @returns the size (on cube texture it is always squared)
  11870. */
  11871. getRenderSize(): RenderTargetTextureSize;
  11872. /**
  11873. * Resize the texture to new value.
  11874. * @param size Define the new size the texture should have
  11875. * @param generateMipMaps Define whether the new texture should create mip maps
  11876. */
  11877. resize(size: number, generateMipMaps: boolean): void;
  11878. private _checkUniform;
  11879. /**
  11880. * Set a texture in the shader program used to render.
  11881. * @param name Define the name of the uniform samplers as defined in the shader
  11882. * @param texture Define the texture to bind to this sampler
  11883. * @return the texture itself allowing "fluent" like uniform updates
  11884. */
  11885. setTexture(name: string, texture: Texture): ProceduralTexture;
  11886. /**
  11887. * Set a float in the shader.
  11888. * @param name Define the name of the uniform as defined in the shader
  11889. * @param value Define the value to give to the uniform
  11890. * @return the texture itself allowing "fluent" like uniform updates
  11891. */
  11892. setFloat(name: string, value: number): ProceduralTexture;
  11893. /**
  11894. * Set a int in the shader.
  11895. * @param name Define the name of the uniform as defined in the shader
  11896. * @param value Define the value to give to the uniform
  11897. * @return the texture itself allowing "fluent" like uniform updates
  11898. */
  11899. setInt(name: string, value: number): ProceduralTexture;
  11900. /**
  11901. * Set an array of floats in the shader.
  11902. * @param name Define the name of the uniform as defined in the shader
  11903. * @param value Define the value to give to the uniform
  11904. * @return the texture itself allowing "fluent" like uniform updates
  11905. */
  11906. setFloats(name: string, value: number[]): ProceduralTexture;
  11907. /**
  11908. * Set a vec3 in the shader from a Color3.
  11909. * @param name Define the name of the uniform as defined in the shader
  11910. * @param value Define the value to give to the uniform
  11911. * @return the texture itself allowing "fluent" like uniform updates
  11912. */
  11913. setColor3(name: string, value: Color3): ProceduralTexture;
  11914. /**
  11915. * Set a vec4 in the shader from a Color4.
  11916. * @param name Define the name of the uniform as defined in the shader
  11917. * @param value Define the value to give to the uniform
  11918. * @return the texture itself allowing "fluent" like uniform updates
  11919. */
  11920. setColor4(name: string, value: Color4): ProceduralTexture;
  11921. /**
  11922. * Set a vec2 in the shader from a Vector2.
  11923. * @param name Define the name of the uniform as defined in the shader
  11924. * @param value Define the value to give to the uniform
  11925. * @return the texture itself allowing "fluent" like uniform updates
  11926. */
  11927. setVector2(name: string, value: Vector2): ProceduralTexture;
  11928. /**
  11929. * Set a vec3 in the shader from a Vector3.
  11930. * @param name Define the name of the uniform as defined in the shader
  11931. * @param value Define the value to give to the uniform
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setVector3(name: string, value: Vector3): ProceduralTexture;
  11935. /**
  11936. * Set a mat4 in the shader from a MAtrix.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11942. /**
  11943. * Render the texture to its associated render target.
  11944. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11945. */
  11946. render(useCameraPostProcess?: boolean): void;
  11947. /**
  11948. * Clone the texture.
  11949. * @returns the cloned texture
  11950. */
  11951. clone(): ProceduralTexture;
  11952. /**
  11953. * Dispose the texture and release its asoociated resources.
  11954. */
  11955. dispose(): void;
  11956. }
  11957. }
  11958. declare module BABYLON {
  11959. /**
  11960. * This represents the base class for particle system in Babylon.
  11961. * 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.
  11962. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11963. * @example https://doc.babylonjs.com/babylon101/particles
  11964. */
  11965. export class BaseParticleSystem {
  11966. /**
  11967. * Source color is added to the destination color without alpha affecting the result
  11968. */
  11969. static BLENDMODE_ONEONE: number;
  11970. /**
  11971. * Blend current color and particle color using particle’s alpha
  11972. */
  11973. static BLENDMODE_STANDARD: number;
  11974. /**
  11975. * Add current color and particle color multiplied by particle’s alpha
  11976. */
  11977. static BLENDMODE_ADD: number;
  11978. /**
  11979. * Multiply current color with particle color
  11980. */
  11981. static BLENDMODE_MULTIPLY: number;
  11982. /**
  11983. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11984. */
  11985. static BLENDMODE_MULTIPLYADD: number;
  11986. /**
  11987. * List of animations used by the particle system.
  11988. */
  11989. animations: Animation[];
  11990. /**
  11991. * Gets or sets the unique id of the particle system
  11992. */
  11993. uniqueId: number;
  11994. /**
  11995. * The id of the Particle system.
  11996. */
  11997. id: string;
  11998. /**
  11999. * The friendly name of the Particle system.
  12000. */
  12001. name: string;
  12002. /**
  12003. * Snippet ID if the particle system was created from the snippet server
  12004. */
  12005. snippetId: string;
  12006. /**
  12007. * The rendering group used by the Particle system to chose when to render.
  12008. */
  12009. renderingGroupId: number;
  12010. /**
  12011. * The emitter represents the Mesh or position we are attaching the particle system to.
  12012. */
  12013. emitter: Nullable<AbstractMesh | Vector3>;
  12014. /**
  12015. * The maximum number of particles to emit per frame
  12016. */
  12017. emitRate: number;
  12018. /**
  12019. * If you want to launch only a few particles at once, that can be done, as well.
  12020. */
  12021. manualEmitCount: number;
  12022. /**
  12023. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12024. */
  12025. updateSpeed: number;
  12026. /**
  12027. * The amount of time the particle system is running (depends of the overall update speed).
  12028. */
  12029. targetStopDuration: number;
  12030. /**
  12031. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12032. */
  12033. disposeOnStop: boolean;
  12034. /**
  12035. * Minimum power of emitting particles.
  12036. */
  12037. minEmitPower: number;
  12038. /**
  12039. * Maximum power of emitting particles.
  12040. */
  12041. maxEmitPower: number;
  12042. /**
  12043. * Minimum life time of emitting particles.
  12044. */
  12045. minLifeTime: number;
  12046. /**
  12047. * Maximum life time of emitting particles.
  12048. */
  12049. maxLifeTime: number;
  12050. /**
  12051. * Minimum Size of emitting particles.
  12052. */
  12053. minSize: number;
  12054. /**
  12055. * Maximum Size of emitting particles.
  12056. */
  12057. maxSize: number;
  12058. /**
  12059. * Minimum scale of emitting particles on X axis.
  12060. */
  12061. minScaleX: number;
  12062. /**
  12063. * Maximum scale of emitting particles on X axis.
  12064. */
  12065. maxScaleX: number;
  12066. /**
  12067. * Minimum scale of emitting particles on Y axis.
  12068. */
  12069. minScaleY: number;
  12070. /**
  12071. * Maximum scale of emitting particles on Y axis.
  12072. */
  12073. maxScaleY: number;
  12074. /**
  12075. * Gets or sets the minimal initial rotation in radians.
  12076. */
  12077. minInitialRotation: number;
  12078. /**
  12079. * Gets or sets the maximal initial rotation in radians.
  12080. */
  12081. maxInitialRotation: number;
  12082. /**
  12083. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12084. */
  12085. minAngularSpeed: number;
  12086. /**
  12087. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12088. */
  12089. maxAngularSpeed: number;
  12090. /**
  12091. * The texture used to render each particle. (this can be a spritesheet)
  12092. */
  12093. particleTexture: Nullable<BaseTexture>;
  12094. /**
  12095. * The layer mask we are rendering the particles through.
  12096. */
  12097. layerMask: number;
  12098. /**
  12099. * This can help using your own shader to render the particle system.
  12100. * The according effect will be created
  12101. */
  12102. customShader: any;
  12103. /**
  12104. * By default particle system starts as soon as they are created. This prevents the
  12105. * automatic start to happen and let you decide when to start emitting particles.
  12106. */
  12107. preventAutoStart: boolean;
  12108. private _noiseTexture;
  12109. /**
  12110. * Gets or sets a texture used to add random noise to particle positions
  12111. */
  12112. get noiseTexture(): Nullable<ProceduralTexture>;
  12113. set noiseTexture(value: Nullable<ProceduralTexture>);
  12114. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12115. noiseStrength: Vector3;
  12116. /**
  12117. * Callback triggered when the particle animation is ending.
  12118. */
  12119. onAnimationEnd: Nullable<() => void>;
  12120. /**
  12121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12122. */
  12123. blendMode: number;
  12124. /**
  12125. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12126. * to override the particles.
  12127. */
  12128. forceDepthWrite: boolean;
  12129. /** 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 */
  12130. preWarmCycles: number;
  12131. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12132. preWarmStepOffset: number;
  12133. /**
  12134. * 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)
  12135. */
  12136. spriteCellChangeSpeed: number;
  12137. /**
  12138. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12139. */
  12140. startSpriteCellID: number;
  12141. /**
  12142. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12143. */
  12144. endSpriteCellID: number;
  12145. /**
  12146. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12147. */
  12148. spriteCellWidth: number;
  12149. /**
  12150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12151. */
  12152. spriteCellHeight: number;
  12153. /**
  12154. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12155. */
  12156. spriteRandomStartCell: boolean;
  12157. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12158. translationPivot: Vector2;
  12159. /** @hidden */
  12160. protected _isAnimationSheetEnabled: boolean;
  12161. /**
  12162. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12163. */
  12164. beginAnimationOnStart: boolean;
  12165. /**
  12166. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12167. */
  12168. beginAnimationFrom: number;
  12169. /**
  12170. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12171. */
  12172. beginAnimationTo: number;
  12173. /**
  12174. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12175. */
  12176. beginAnimationLoop: boolean;
  12177. /**
  12178. * Gets or sets a world offset applied to all particles
  12179. */
  12180. worldOffset: Vector3;
  12181. /**
  12182. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12183. */
  12184. get isAnimationSheetEnabled(): boolean;
  12185. set isAnimationSheetEnabled(value: boolean);
  12186. /**
  12187. * Get hosting scene
  12188. * @returns the scene
  12189. */
  12190. getScene(): Nullable<Scene>;
  12191. /**
  12192. * You can use gravity if you want to give an orientation to your particles.
  12193. */
  12194. gravity: Vector3;
  12195. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12196. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12197. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12198. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12199. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12200. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12201. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12202. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12203. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12204. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12205. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12206. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12207. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12208. /**
  12209. * Defines the delay in milliseconds before starting the system (0 by default)
  12210. */
  12211. startDelay: number;
  12212. /**
  12213. * Gets the current list of drag gradients.
  12214. * You must use addDragGradient and removeDragGradient to udpate this list
  12215. * @returns the list of drag gradients
  12216. */
  12217. getDragGradients(): Nullable<Array<FactorGradient>>;
  12218. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12219. limitVelocityDamping: number;
  12220. /**
  12221. * Gets the current list of limit velocity gradients.
  12222. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12223. * @returns the list of limit velocity gradients
  12224. */
  12225. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12226. /**
  12227. * Gets the current list of color gradients.
  12228. * You must use addColorGradient and removeColorGradient to udpate this list
  12229. * @returns the list of color gradients
  12230. */
  12231. getColorGradients(): Nullable<Array<ColorGradient>>;
  12232. /**
  12233. * Gets the current list of size gradients.
  12234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12235. * @returns the list of size gradients
  12236. */
  12237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12238. /**
  12239. * Gets the current list of color remap gradients.
  12240. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12241. * @returns the list of color remap gradients
  12242. */
  12243. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12244. /**
  12245. * Gets the current list of alpha remap gradients.
  12246. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12247. * @returns the list of alpha remap gradients
  12248. */
  12249. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12250. /**
  12251. * Gets the current list of life time gradients.
  12252. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12253. * @returns the list of life time gradients
  12254. */
  12255. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12256. /**
  12257. * Gets the current list of angular speed gradients.
  12258. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12259. * @returns the list of angular speed gradients
  12260. */
  12261. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12262. /**
  12263. * Gets the current list of velocity gradients.
  12264. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12265. * @returns the list of velocity gradients
  12266. */
  12267. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12268. /**
  12269. * Gets the current list of start size gradients.
  12270. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12271. * @returns the list of start size gradients
  12272. */
  12273. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12274. /**
  12275. * Gets the current list of emit rate gradients.
  12276. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12277. * @returns the list of emit rate gradients
  12278. */
  12279. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12280. /**
  12281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12283. */
  12284. get direction1(): Vector3;
  12285. set direction1(value: Vector3);
  12286. /**
  12287. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12289. */
  12290. get direction2(): Vector3;
  12291. set direction2(value: Vector3);
  12292. /**
  12293. * 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.
  12294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12295. */
  12296. get minEmitBox(): Vector3;
  12297. set minEmitBox(value: Vector3);
  12298. /**
  12299. * 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.
  12300. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12301. */
  12302. get maxEmitBox(): Vector3;
  12303. set maxEmitBox(value: Vector3);
  12304. /**
  12305. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12306. */
  12307. color1: Color4;
  12308. /**
  12309. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12310. */
  12311. color2: Color4;
  12312. /**
  12313. * Color the particle will have at the end of its lifetime
  12314. */
  12315. colorDead: Color4;
  12316. /**
  12317. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12318. */
  12319. textureMask: Color4;
  12320. /**
  12321. * The particle emitter type defines the emitter used by the particle system.
  12322. * It can be for example box, sphere, or cone...
  12323. */
  12324. particleEmitterType: IParticleEmitterType;
  12325. /** @hidden */
  12326. _isSubEmitter: boolean;
  12327. /**
  12328. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12329. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12330. */
  12331. billboardMode: number;
  12332. protected _isBillboardBased: boolean;
  12333. /**
  12334. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12335. */
  12336. get isBillboardBased(): boolean;
  12337. set isBillboardBased(value: boolean);
  12338. /**
  12339. * The scene the particle system belongs to.
  12340. */
  12341. protected _scene: Nullable<Scene>;
  12342. /**
  12343. * The engine the particle system belongs to.
  12344. */
  12345. protected _engine: ThinEngine;
  12346. /**
  12347. * Local cache of defines for image processing.
  12348. */
  12349. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12350. /**
  12351. * Default configuration related to image processing available in the standard Material.
  12352. */
  12353. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12354. /**
  12355. * Gets the image processing configuration used either in this material.
  12356. */
  12357. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12358. /**
  12359. * Sets the Default image processing configuration used either in the this material.
  12360. *
  12361. * If sets to null, the scene one is in use.
  12362. */
  12363. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12364. /**
  12365. * Attaches a new image processing configuration to the Standard Material.
  12366. * @param configuration
  12367. */
  12368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12369. /** @hidden */
  12370. protected _reset(): void;
  12371. /** @hidden */
  12372. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12373. /**
  12374. * Instantiates a particle system.
  12375. * 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.
  12376. * @param name The name of the particle system
  12377. */
  12378. constructor(name: string);
  12379. /**
  12380. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12383. * @returns the emitter
  12384. */
  12385. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12386. /**
  12387. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12388. * @param radius The radius of the hemisphere to emit from
  12389. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12390. * @returns the emitter
  12391. */
  12392. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12393. /**
  12394. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12395. * @param radius The radius of the sphere to emit from
  12396. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12397. * @returns the emitter
  12398. */
  12399. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12400. /**
  12401. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12402. * @param radius The radius of the sphere to emit from
  12403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12405. * @returns the emitter
  12406. */
  12407. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12408. /**
  12409. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12410. * @param radius The radius of the emission cylinder
  12411. * @param height The height of the emission cylinder
  12412. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12413. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12414. * @returns the emitter
  12415. */
  12416. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12417. /**
  12418. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12419. * @param radius The radius of the cylinder to emit from
  12420. * @param height The height of the emission cylinder
  12421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12424. * @returns the emitter
  12425. */
  12426. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12427. /**
  12428. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12429. * @param radius The radius of the cone to emit from
  12430. * @param angle The base angle of the cone
  12431. * @returns the emitter
  12432. */
  12433. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12434. /**
  12435. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12438. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12439. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12440. * @returns the emitter
  12441. */
  12442. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12443. }
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Type of sub emitter
  12448. */
  12449. export enum SubEmitterType {
  12450. /**
  12451. * Attached to the particle over it's lifetime
  12452. */
  12453. ATTACHED = 0,
  12454. /**
  12455. * Created when the particle dies
  12456. */
  12457. END = 1
  12458. }
  12459. /**
  12460. * Sub emitter class used to emit particles from an existing particle
  12461. */
  12462. export class SubEmitter {
  12463. /**
  12464. * the particle system to be used by the sub emitter
  12465. */
  12466. particleSystem: ParticleSystem;
  12467. /**
  12468. * Type of the submitter (Default: END)
  12469. */
  12470. type: SubEmitterType;
  12471. /**
  12472. * 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)
  12473. * Note: This only is supported when using an emitter of type Mesh
  12474. */
  12475. inheritDirection: boolean;
  12476. /**
  12477. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12478. */
  12479. inheritedVelocityAmount: number;
  12480. /**
  12481. * Creates a sub emitter
  12482. * @param particleSystem the particle system to be used by the sub emitter
  12483. */
  12484. constructor(
  12485. /**
  12486. * the particle system to be used by the sub emitter
  12487. */
  12488. particleSystem: ParticleSystem);
  12489. /**
  12490. * Clones the sub emitter
  12491. * @returns the cloned sub emitter
  12492. */
  12493. clone(): SubEmitter;
  12494. /**
  12495. * Serialize current object to a JSON object
  12496. * @returns the serialized object
  12497. */
  12498. serialize(): any;
  12499. /** @hidden */
  12500. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12501. /**
  12502. * Creates a new SubEmitter from a serialized JSON version
  12503. * @param serializationObject defines the JSON object to read from
  12504. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12505. * @param rootUrl defines the rootUrl for data loading
  12506. * @returns a new SubEmitter
  12507. */
  12508. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12509. /** Release associated resources */
  12510. dispose(): void;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. /** @hidden */
  12515. export var imageProcessingDeclaration: {
  12516. name: string;
  12517. shader: string;
  12518. };
  12519. }
  12520. declare module BABYLON {
  12521. /** @hidden */
  12522. export var imageProcessingFunctions: {
  12523. name: string;
  12524. shader: string;
  12525. };
  12526. }
  12527. declare module BABYLON {
  12528. /** @hidden */
  12529. export var particlesPixelShader: {
  12530. name: string;
  12531. shader: string;
  12532. };
  12533. }
  12534. declare module BABYLON {
  12535. /** @hidden */
  12536. export var particlesVertexShader: {
  12537. name: string;
  12538. shader: string;
  12539. };
  12540. }
  12541. declare module BABYLON {
  12542. /**
  12543. * Interface used to define entities containing multiple clip planes
  12544. */
  12545. export interface IClipPlanesHolder {
  12546. /**
  12547. * Gets or sets the active clipplane 1
  12548. */
  12549. clipPlane: Nullable<Plane>;
  12550. /**
  12551. * Gets or sets the active clipplane 2
  12552. */
  12553. clipPlane2: Nullable<Plane>;
  12554. /**
  12555. * Gets or sets the active clipplane 3
  12556. */
  12557. clipPlane3: Nullable<Plane>;
  12558. /**
  12559. * Gets or sets the active clipplane 4
  12560. */
  12561. clipPlane4: Nullable<Plane>;
  12562. /**
  12563. * Gets or sets the active clipplane 5
  12564. */
  12565. clipPlane5: Nullable<Plane>;
  12566. /**
  12567. * Gets or sets the active clipplane 6
  12568. */
  12569. clipPlane6: Nullable<Plane>;
  12570. }
  12571. }
  12572. declare module BABYLON {
  12573. /**
  12574. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12575. *
  12576. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12577. *
  12578. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12579. */
  12580. export class ThinMaterialHelper {
  12581. /**
  12582. * Binds the clip plane information from the holder to the effect.
  12583. * @param effect The effect we are binding the data to
  12584. * @param holder The entity containing the clip plane information
  12585. */
  12586. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. interface ThinEngine {
  12591. /**
  12592. * Sets alpha constants used by some alpha blending modes
  12593. * @param r defines the red component
  12594. * @param g defines the green component
  12595. * @param b defines the blue component
  12596. * @param a defines the alpha component
  12597. */
  12598. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12599. /**
  12600. * Sets the current alpha mode
  12601. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12602. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12603. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12604. */
  12605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12606. /**
  12607. * Gets the current alpha mode
  12608. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12609. * @returns the current alpha mode
  12610. */
  12611. getAlphaMode(): number;
  12612. /**
  12613. * Sets the current alpha equation
  12614. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12615. */
  12616. setAlphaEquation(equation: number): void;
  12617. /**
  12618. * Gets the current alpha equation.
  12619. * @returns the current alpha equation
  12620. */
  12621. getAlphaEquation(): number;
  12622. }
  12623. }
  12624. declare module BABYLON {
  12625. /**
  12626. * This represents a particle system in Babylon.
  12627. * 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.
  12628. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12629. * @example https://doc.babylonjs.com/babylon101/particles
  12630. */
  12631. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12632. /**
  12633. * Billboard mode will only apply to Y axis
  12634. */
  12635. static readonly BILLBOARDMODE_Y: number;
  12636. /**
  12637. * Billboard mode will apply to all axes
  12638. */
  12639. static readonly BILLBOARDMODE_ALL: number;
  12640. /**
  12641. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12642. */
  12643. static readonly BILLBOARDMODE_STRETCHED: number;
  12644. /**
  12645. * This function can be defined to provide custom update for active particles.
  12646. * This function will be called instead of regular update (age, position, color, etc.).
  12647. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12648. */
  12649. updateFunction: (particles: Particle[]) => void;
  12650. private _emitterWorldMatrix;
  12651. /**
  12652. * This function can be defined to specify initial direction for every new particle.
  12653. * It by default use the emitterType defined function
  12654. */
  12655. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12656. /**
  12657. * This function can be defined to specify initial position for every new particle.
  12658. * It by default use the emitterType defined function
  12659. */
  12660. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12661. /**
  12662. * @hidden
  12663. */
  12664. _inheritedVelocityOffset: Vector3;
  12665. /**
  12666. * An event triggered when the system is disposed
  12667. */
  12668. onDisposeObservable: Observable<IParticleSystem>;
  12669. /**
  12670. * An event triggered when the system is stopped
  12671. */
  12672. onStoppedObservable: Observable<IParticleSystem>;
  12673. private _onDisposeObserver;
  12674. /**
  12675. * Sets a callback that will be triggered when the system is disposed
  12676. */
  12677. set onDispose(callback: () => void);
  12678. private _particles;
  12679. private _epsilon;
  12680. private _capacity;
  12681. private _stockParticles;
  12682. private _newPartsExcess;
  12683. private _vertexData;
  12684. private _vertexBuffer;
  12685. private _vertexBuffers;
  12686. private _spriteBuffer;
  12687. private _indexBuffer;
  12688. private _effect;
  12689. private _customEffect;
  12690. private _cachedDefines;
  12691. private _scaledColorStep;
  12692. private _colorDiff;
  12693. private _scaledDirection;
  12694. private _scaledGravity;
  12695. private _currentRenderId;
  12696. private _alive;
  12697. private _useInstancing;
  12698. private _vertexArrayObject;
  12699. private _started;
  12700. private _stopped;
  12701. private _actualFrame;
  12702. private _scaledUpdateSpeed;
  12703. private _vertexBufferSize;
  12704. /** @hidden */
  12705. _currentEmitRateGradient: Nullable<FactorGradient>;
  12706. /** @hidden */
  12707. _currentEmitRate1: number;
  12708. /** @hidden */
  12709. _currentEmitRate2: number;
  12710. /** @hidden */
  12711. _currentStartSizeGradient: Nullable<FactorGradient>;
  12712. /** @hidden */
  12713. _currentStartSize1: number;
  12714. /** @hidden */
  12715. _currentStartSize2: number;
  12716. private readonly _rawTextureWidth;
  12717. private _rampGradientsTexture;
  12718. private _useRampGradients;
  12719. /** Gets or sets a matrix to use to compute projection */
  12720. defaultProjectionMatrix: Matrix;
  12721. /** Gets or sets a matrix to use to compute view */
  12722. defaultViewMatrix: Matrix;
  12723. /** Gets or sets a boolean indicating that ramp gradients must be used
  12724. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12725. */
  12726. get useRampGradients(): boolean;
  12727. set useRampGradients(value: boolean);
  12728. /**
  12729. * 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.
  12730. * 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: [])
  12731. */
  12732. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12733. private _subEmitters;
  12734. /**
  12735. * @hidden
  12736. * If the particle systems emitter should be disposed when the particle system is disposed
  12737. */
  12738. _disposeEmitterOnDispose: boolean;
  12739. /**
  12740. * The current active Sub-systems, this property is used by the root particle system only.
  12741. */
  12742. activeSubSystems: Array<ParticleSystem>;
  12743. /**
  12744. * Specifies if the particles are updated in emitter local space or world space
  12745. */
  12746. isLocal: boolean;
  12747. private _rootParticleSystem;
  12748. /**
  12749. * Gets the current list of active particles
  12750. */
  12751. get particles(): Particle[];
  12752. /**
  12753. * Gets the number of particles active at the same time.
  12754. * @returns The number of active particles.
  12755. */
  12756. getActiveCount(): number;
  12757. /**
  12758. * Returns the string "ParticleSystem"
  12759. * @returns a string containing the class name
  12760. */
  12761. getClassName(): string;
  12762. /**
  12763. * Gets a boolean indicating that the system is stopping
  12764. * @returns true if the system is currently stopping
  12765. */
  12766. isStopping(): boolean;
  12767. /**
  12768. * Gets the custom effect used to render the particles
  12769. * @param blendMode Blend mode for which the effect should be retrieved
  12770. * @returns The effect
  12771. */
  12772. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12773. /**
  12774. * Sets the custom effect used to render the particles
  12775. * @param effect The effect to set
  12776. * @param blendMode Blend mode for which the effect should be set
  12777. */
  12778. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12779. /** @hidden */
  12780. private _onBeforeDrawParticlesObservable;
  12781. /**
  12782. * Observable that will be called just before the particles are drawn
  12783. */
  12784. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12785. /**
  12786. * Gets the name of the particle vertex shader
  12787. */
  12788. get vertexShaderName(): string;
  12789. /**
  12790. * Instantiates a particle system.
  12791. * 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.
  12792. * @param name The name of the particle system
  12793. * @param capacity The max number of particles alive at the same time
  12794. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12795. * @param customEffect a custom effect used to change the way particles are rendered by default
  12796. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12797. * @param epsilon Offset used to render the particles
  12798. */
  12799. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12800. private _addFactorGradient;
  12801. private _removeFactorGradient;
  12802. /**
  12803. * Adds a new life time gradient
  12804. * @param gradient defines the gradient to use (between 0 and 1)
  12805. * @param factor defines the life time factor to affect to the specified gradient
  12806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12807. * @returns the current particle system
  12808. */
  12809. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12810. /**
  12811. * Remove a specific life time gradient
  12812. * @param gradient defines the gradient to remove
  12813. * @returns the current particle system
  12814. */
  12815. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12816. /**
  12817. * Adds a new size gradient
  12818. * @param gradient defines the gradient to use (between 0 and 1)
  12819. * @param factor defines the size factor to affect to the specified gradient
  12820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12821. * @returns the current particle system
  12822. */
  12823. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12824. /**
  12825. * Remove a specific size gradient
  12826. * @param gradient defines the gradient to remove
  12827. * @returns the current particle system
  12828. */
  12829. removeSizeGradient(gradient: number): IParticleSystem;
  12830. /**
  12831. * Adds a new color remap gradient
  12832. * @param gradient defines the gradient to use (between 0 and 1)
  12833. * @param min defines the color remap minimal range
  12834. * @param max defines the color remap maximal range
  12835. * @returns the current particle system
  12836. */
  12837. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12838. /**
  12839. * Remove a specific color remap gradient
  12840. * @param gradient defines the gradient to remove
  12841. * @returns the current particle system
  12842. */
  12843. removeColorRemapGradient(gradient: number): IParticleSystem;
  12844. /**
  12845. * Adds a new alpha remap gradient
  12846. * @param gradient defines the gradient to use (between 0 and 1)
  12847. * @param min defines the alpha remap minimal range
  12848. * @param max defines the alpha remap maximal range
  12849. * @returns the current particle system
  12850. */
  12851. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12852. /**
  12853. * Remove a specific alpha remap gradient
  12854. * @param gradient defines the gradient to remove
  12855. * @returns the current particle system
  12856. */
  12857. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12858. /**
  12859. * Adds a new angular speed gradient
  12860. * @param gradient defines the gradient to use (between 0 and 1)
  12861. * @param factor defines the angular speed to affect to the specified gradient
  12862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12863. * @returns the current particle system
  12864. */
  12865. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12866. /**
  12867. * Remove a specific angular speed gradient
  12868. * @param gradient defines the gradient to remove
  12869. * @returns the current particle system
  12870. */
  12871. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12872. /**
  12873. * Adds a new velocity gradient
  12874. * @param gradient defines the gradient to use (between 0 and 1)
  12875. * @param factor defines the velocity to affect to the specified gradient
  12876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12877. * @returns the current particle system
  12878. */
  12879. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12880. /**
  12881. * Remove a specific velocity gradient
  12882. * @param gradient defines the gradient to remove
  12883. * @returns the current particle system
  12884. */
  12885. removeVelocityGradient(gradient: number): IParticleSystem;
  12886. /**
  12887. * Adds a new limit velocity gradient
  12888. * @param gradient defines the gradient to use (between 0 and 1)
  12889. * @param factor defines the limit velocity value to affect to the specified gradient
  12890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12891. * @returns the current particle system
  12892. */
  12893. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12894. /**
  12895. * Remove a specific limit velocity gradient
  12896. * @param gradient defines the gradient to remove
  12897. * @returns the current particle system
  12898. */
  12899. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12900. /**
  12901. * Adds a new drag gradient
  12902. * @param gradient defines the gradient to use (between 0 and 1)
  12903. * @param factor defines the drag value to affect to the specified gradient
  12904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12905. * @returns the current particle system
  12906. */
  12907. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12908. /**
  12909. * Remove a specific drag gradient
  12910. * @param gradient defines the gradient to remove
  12911. * @returns the current particle system
  12912. */
  12913. removeDragGradient(gradient: number): IParticleSystem;
  12914. /**
  12915. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12916. * @param gradient defines the gradient to use (between 0 and 1)
  12917. * @param factor defines the emit rate value to affect to the specified gradient
  12918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12919. * @returns the current particle system
  12920. */
  12921. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12922. /**
  12923. * Remove a specific emit rate gradient
  12924. * @param gradient defines the gradient to remove
  12925. * @returns the current particle system
  12926. */
  12927. removeEmitRateGradient(gradient: number): IParticleSystem;
  12928. /**
  12929. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12930. * @param gradient defines the gradient to use (between 0 and 1)
  12931. * @param factor defines the start size value to affect to the specified gradient
  12932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12933. * @returns the current particle system
  12934. */
  12935. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12936. /**
  12937. * Remove a specific start size gradient
  12938. * @param gradient defines the gradient to remove
  12939. * @returns the current particle system
  12940. */
  12941. removeStartSizeGradient(gradient: number): IParticleSystem;
  12942. private _createRampGradientTexture;
  12943. /**
  12944. * Gets the current list of ramp gradients.
  12945. * You must use addRampGradient and removeRampGradient to udpate this list
  12946. * @returns the list of ramp gradients
  12947. */
  12948. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12949. /** Force the system to rebuild all gradients that need to be resync */
  12950. forceRefreshGradients(): void;
  12951. private _syncRampGradientTexture;
  12952. /**
  12953. * Adds a new ramp gradient used to remap particle colors
  12954. * @param gradient defines the gradient to use (between 0 and 1)
  12955. * @param color defines the color to affect to the specified gradient
  12956. * @returns the current particle system
  12957. */
  12958. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12959. /**
  12960. * Remove a specific ramp gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeRampGradient(gradient: number): ParticleSystem;
  12965. /**
  12966. * Adds a new color gradient
  12967. * @param gradient defines the gradient to use (between 0 and 1)
  12968. * @param color1 defines the color to affect to the specified gradient
  12969. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12970. * @returns this particle system
  12971. */
  12972. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12973. /**
  12974. * Remove a specific color gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns this particle system
  12977. */
  12978. removeColorGradient(gradient: number): IParticleSystem;
  12979. private _fetchR;
  12980. protected _reset(): void;
  12981. private _resetEffect;
  12982. private _createVertexBuffers;
  12983. private _createIndexBuffer;
  12984. /**
  12985. * Gets the maximum number of particles active at the same time.
  12986. * @returns The max number of active particles.
  12987. */
  12988. getCapacity(): number;
  12989. /**
  12990. * Gets whether there are still active particles in the system.
  12991. * @returns True if it is alive, otherwise false.
  12992. */
  12993. isAlive(): boolean;
  12994. /**
  12995. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12996. * @returns True if it has been started, otherwise false.
  12997. */
  12998. isStarted(): boolean;
  12999. private _prepareSubEmitterInternalArray;
  13000. /**
  13001. * Starts the particle system and begins to emit
  13002. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13003. */
  13004. start(delay?: number): void;
  13005. /**
  13006. * Stops the particle system.
  13007. * @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.
  13008. */
  13009. stop(stopSubEmitters?: boolean): void;
  13010. /**
  13011. * Remove all active particles
  13012. */
  13013. reset(): void;
  13014. /**
  13015. * @hidden (for internal use only)
  13016. */
  13017. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13018. /**
  13019. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13020. * Its lifetime will start back at 0.
  13021. */
  13022. recycleParticle: (particle: Particle) => void;
  13023. private _stopSubEmitters;
  13024. private _createParticle;
  13025. private _removeFromRoot;
  13026. private _emitFromParticle;
  13027. private _update;
  13028. /** @hidden */
  13029. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13030. /** @hidden */
  13031. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13032. /**
  13033. * Fill the defines array according to the current settings of the particle system
  13034. * @param defines Array to be updated
  13035. * @param blendMode blend mode to take into account when updating the array
  13036. */
  13037. fillDefines(defines: Array<string>, blendMode: number): void;
  13038. /**
  13039. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13040. * @param uniforms Uniforms array to fill
  13041. * @param attributes Attributes array to fill
  13042. * @param samplers Samplers array to fill
  13043. */
  13044. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13045. /** @hidden */
  13046. private _getEffect;
  13047. /**
  13048. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13049. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13050. */
  13051. animate(preWarmOnly?: boolean): void;
  13052. private _appendParticleVertices;
  13053. /**
  13054. * Rebuilds the particle system.
  13055. */
  13056. rebuild(): void;
  13057. /**
  13058. * Is this system ready to be used/rendered
  13059. * @return true if the system is ready
  13060. */
  13061. isReady(): boolean;
  13062. private _render;
  13063. /**
  13064. * Renders the particle system in its current state.
  13065. * @returns the current number of particles
  13066. */
  13067. render(): number;
  13068. /**
  13069. * Disposes the particle system and free the associated resources
  13070. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13071. */
  13072. dispose(disposeTexture?: boolean): void;
  13073. /**
  13074. * Clones the particle system.
  13075. * @param name The name of the cloned object
  13076. * @param newEmitter The new emitter to use
  13077. * @returns the cloned particle system
  13078. */
  13079. clone(name: string, newEmitter: any): ParticleSystem;
  13080. /**
  13081. * Serializes the particle system to a JSON object
  13082. * @param serializeTexture defines if the texture must be serialized as well
  13083. * @returns the JSON object
  13084. */
  13085. serialize(serializeTexture?: boolean): any;
  13086. /** @hidden */
  13087. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13088. /** @hidden */
  13089. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13090. /**
  13091. * Parses a JSON object to create a particle system.
  13092. * @param parsedParticleSystem The JSON object to parse
  13093. * @param sceneOrEngine The scene or the engine to create the particle system in
  13094. * @param rootUrl The root url to use to load external dependencies like texture
  13095. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13096. * @returns the Parsed particle system
  13097. */
  13098. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13099. }
  13100. }
  13101. declare module BABYLON {
  13102. /**
  13103. * A particle represents one of the element emitted by a particle system.
  13104. * This is mainly define by its coordinates, direction, velocity and age.
  13105. */
  13106. export class Particle {
  13107. /**
  13108. * The particle system the particle belongs to.
  13109. */
  13110. particleSystem: ParticleSystem;
  13111. private static _Count;
  13112. /**
  13113. * Unique ID of the particle
  13114. */
  13115. id: number;
  13116. /**
  13117. * The world position of the particle in the scene.
  13118. */
  13119. position: Vector3;
  13120. /**
  13121. * The world direction of the particle in the scene.
  13122. */
  13123. direction: Vector3;
  13124. /**
  13125. * The color of the particle.
  13126. */
  13127. color: Color4;
  13128. /**
  13129. * The color change of the particle per step.
  13130. */
  13131. colorStep: Color4;
  13132. /**
  13133. * Defines how long will the life of the particle be.
  13134. */
  13135. lifeTime: number;
  13136. /**
  13137. * The current age of the particle.
  13138. */
  13139. age: number;
  13140. /**
  13141. * The current size of the particle.
  13142. */
  13143. size: number;
  13144. /**
  13145. * The current scale of the particle.
  13146. */
  13147. scale: Vector2;
  13148. /**
  13149. * The current angle of the particle.
  13150. */
  13151. angle: number;
  13152. /**
  13153. * Defines how fast is the angle changing.
  13154. */
  13155. angularSpeed: number;
  13156. /**
  13157. * Defines the cell index used by the particle to be rendered from a sprite.
  13158. */
  13159. cellIndex: number;
  13160. /**
  13161. * The information required to support color remapping
  13162. */
  13163. remapData: Vector4;
  13164. /** @hidden */
  13165. _randomCellOffset?: number;
  13166. /** @hidden */
  13167. _initialDirection: Nullable<Vector3>;
  13168. /** @hidden */
  13169. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13170. /** @hidden */
  13171. _initialStartSpriteCellID: number;
  13172. /** @hidden */
  13173. _initialEndSpriteCellID: number;
  13174. /** @hidden */
  13175. _currentColorGradient: Nullable<ColorGradient>;
  13176. /** @hidden */
  13177. _currentColor1: Color4;
  13178. /** @hidden */
  13179. _currentColor2: Color4;
  13180. /** @hidden */
  13181. _currentSizeGradient: Nullable<FactorGradient>;
  13182. /** @hidden */
  13183. _currentSize1: number;
  13184. /** @hidden */
  13185. _currentSize2: number;
  13186. /** @hidden */
  13187. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13188. /** @hidden */
  13189. _currentAngularSpeed1: number;
  13190. /** @hidden */
  13191. _currentAngularSpeed2: number;
  13192. /** @hidden */
  13193. _currentVelocityGradient: Nullable<FactorGradient>;
  13194. /** @hidden */
  13195. _currentVelocity1: number;
  13196. /** @hidden */
  13197. _currentVelocity2: number;
  13198. /** @hidden */
  13199. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13200. /** @hidden */
  13201. _currentLimitVelocity1: number;
  13202. /** @hidden */
  13203. _currentLimitVelocity2: number;
  13204. /** @hidden */
  13205. _currentDragGradient: Nullable<FactorGradient>;
  13206. /** @hidden */
  13207. _currentDrag1: number;
  13208. /** @hidden */
  13209. _currentDrag2: number;
  13210. /** @hidden */
  13211. _randomNoiseCoordinates1: Vector3;
  13212. /** @hidden */
  13213. _randomNoiseCoordinates2: Vector3;
  13214. /** @hidden */
  13215. _localPosition?: Vector3;
  13216. /**
  13217. * Creates a new instance Particle
  13218. * @param particleSystem the particle system the particle belongs to
  13219. */
  13220. constructor(
  13221. /**
  13222. * The particle system the particle belongs to.
  13223. */
  13224. particleSystem: ParticleSystem);
  13225. private updateCellInfoFromSystem;
  13226. /**
  13227. * Defines how the sprite cell index is updated for the particle
  13228. */
  13229. updateCellIndex(): void;
  13230. /** @hidden */
  13231. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13232. /** @hidden */
  13233. _inheritParticleInfoToSubEmitters(): void;
  13234. /** @hidden */
  13235. _reset(): void;
  13236. /**
  13237. * Copy the properties of particle to another one.
  13238. * @param other the particle to copy the information to.
  13239. */
  13240. copyTo(other: Particle): void;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Particle emitter represents a volume emitting particles.
  13246. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13247. */
  13248. export interface IParticleEmitterType {
  13249. /**
  13250. * Called by the particle System when the direction is computed for the created particle.
  13251. * @param worldMatrix is the world matrix of the particle system
  13252. * @param directionToUpdate is the direction vector to update with the result
  13253. * @param particle is the particle we are computed the direction for
  13254. * @param isLocal defines if the direction should be set in local space
  13255. */
  13256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13257. /**
  13258. * Called by the particle System when the position is computed for the created particle.
  13259. * @param worldMatrix is the world matrix of the particle system
  13260. * @param positionToUpdate is the position vector to update with the result
  13261. * @param particle is the particle we are computed the position for
  13262. * @param isLocal defines if the position should be set in local space
  13263. */
  13264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13265. /**
  13266. * Clones the current emitter and returns a copy of it
  13267. * @returns the new emitter
  13268. */
  13269. clone(): IParticleEmitterType;
  13270. /**
  13271. * Called by the GPUParticleSystem to setup the update shader
  13272. * @param effect defines the update shader
  13273. */
  13274. applyToShader(effect: Effect): void;
  13275. /**
  13276. * Returns a string to use to update the GPU particles update shader
  13277. * @returns the effect defines string
  13278. */
  13279. getEffectDefines(): string;
  13280. /**
  13281. * Returns a string representing the class name
  13282. * @returns a string containing the class name
  13283. */
  13284. getClassName(): string;
  13285. /**
  13286. * Serializes the particle system to a JSON object.
  13287. * @returns the JSON object
  13288. */
  13289. serialize(): any;
  13290. /**
  13291. * Parse properties from a JSON object
  13292. * @param serializationObject defines the JSON object
  13293. * @param scene defines the hosting scene
  13294. */
  13295. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13296. }
  13297. }
  13298. declare module BABYLON {
  13299. /**
  13300. * Particle emitter emitting particles from the inside of a box.
  13301. * It emits the particles randomly between 2 given directions.
  13302. */
  13303. export class BoxParticleEmitter implements IParticleEmitterType {
  13304. /**
  13305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13306. */
  13307. direction1: Vector3;
  13308. /**
  13309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13310. */
  13311. direction2: Vector3;
  13312. /**
  13313. * 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.
  13314. */
  13315. minEmitBox: Vector3;
  13316. /**
  13317. * 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.
  13318. */
  13319. maxEmitBox: Vector3;
  13320. /**
  13321. * Creates a new instance BoxParticleEmitter
  13322. */
  13323. constructor();
  13324. /**
  13325. * Called by the particle System when the direction is computed for the created particle.
  13326. * @param worldMatrix is the world matrix of the particle system
  13327. * @param directionToUpdate is the direction vector to update with the result
  13328. * @param particle is the particle we are computed the direction for
  13329. * @param isLocal defines if the direction should be set in local space
  13330. */
  13331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13332. /**
  13333. * Called by the particle System when the position is computed for the created particle.
  13334. * @param worldMatrix is the world matrix of the particle system
  13335. * @param positionToUpdate is the position vector to update with the result
  13336. * @param particle is the particle we are computed the position for
  13337. * @param isLocal defines if the position should be set in local space
  13338. */
  13339. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13340. /**
  13341. * Clones the current emitter and returns a copy of it
  13342. * @returns the new emitter
  13343. */
  13344. clone(): BoxParticleEmitter;
  13345. /**
  13346. * Called by the GPUParticleSystem to setup the update shader
  13347. * @param effect defines the update shader
  13348. */
  13349. applyToShader(effect: Effect): void;
  13350. /**
  13351. * Returns a string to use to update the GPU particles update shader
  13352. * @returns a string containng the defines string
  13353. */
  13354. getEffectDefines(): string;
  13355. /**
  13356. * Returns the string "BoxParticleEmitter"
  13357. * @returns a string containing the class name
  13358. */
  13359. getClassName(): string;
  13360. /**
  13361. * Serializes the particle system to a JSON object.
  13362. * @returns the JSON object
  13363. */
  13364. serialize(): any;
  13365. /**
  13366. * Parse properties from a JSON object
  13367. * @param serializationObject defines the JSON object
  13368. */
  13369. parse(serializationObject: any): void;
  13370. }
  13371. }
  13372. declare module BABYLON {
  13373. /**
  13374. * Particle emitter emitting particles from the inside of a cone.
  13375. * It emits the particles alongside the cone volume from the base to the particle.
  13376. * The emission direction might be randomized.
  13377. */
  13378. export class ConeParticleEmitter implements IParticleEmitterType {
  13379. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13380. directionRandomizer: number;
  13381. private _radius;
  13382. private _angle;
  13383. private _height;
  13384. /**
  13385. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13386. */
  13387. radiusRange: number;
  13388. /**
  13389. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13390. */
  13391. heightRange: number;
  13392. /**
  13393. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13394. */
  13395. emitFromSpawnPointOnly: boolean;
  13396. /**
  13397. * Gets or sets the radius of the emission cone
  13398. */
  13399. get radius(): number;
  13400. set radius(value: number);
  13401. /**
  13402. * Gets or sets the angle of the emission cone
  13403. */
  13404. get angle(): number;
  13405. set angle(value: number);
  13406. private _buildHeight;
  13407. /**
  13408. * Creates a new instance ConeParticleEmitter
  13409. * @param radius the radius of the emission cone (1 by default)
  13410. * @param angle the cone base angle (PI by default)
  13411. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13412. */
  13413. constructor(radius?: number, angle?: number,
  13414. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13415. directionRandomizer?: number);
  13416. /**
  13417. * Called by the particle System when the direction is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param directionToUpdate is the direction vector to update with the result
  13420. * @param particle is the particle we are computed the direction for
  13421. * @param isLocal defines if the direction should be set in local space
  13422. */
  13423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Called by the particle System when the position is computed for the created particle.
  13426. * @param worldMatrix is the world matrix of the particle system
  13427. * @param positionToUpdate is the position vector to update with the result
  13428. * @param particle is the particle we are computed the position for
  13429. * @param isLocal defines if the position should be set in local space
  13430. */
  13431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13432. /**
  13433. * Clones the current emitter and returns a copy of it
  13434. * @returns the new emitter
  13435. */
  13436. clone(): ConeParticleEmitter;
  13437. /**
  13438. * Called by the GPUParticleSystem to setup the update shader
  13439. * @param effect defines the update shader
  13440. */
  13441. applyToShader(effect: Effect): void;
  13442. /**
  13443. * Returns a string to use to update the GPU particles update shader
  13444. * @returns a string containng the defines string
  13445. */
  13446. getEffectDefines(): string;
  13447. /**
  13448. * Returns the string "ConeParticleEmitter"
  13449. * @returns a string containing the class name
  13450. */
  13451. getClassName(): string;
  13452. /**
  13453. * Serializes the particle system to a JSON object.
  13454. * @returns the JSON object
  13455. */
  13456. serialize(): any;
  13457. /**
  13458. * Parse properties from a JSON object
  13459. * @param serializationObject defines the JSON object
  13460. */
  13461. parse(serializationObject: any): void;
  13462. }
  13463. }
  13464. declare module BABYLON {
  13465. /**
  13466. * Particle emitter emitting particles from the inside of a cylinder.
  13467. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13468. */
  13469. export class CylinderParticleEmitter implements IParticleEmitterType {
  13470. /**
  13471. * The radius of the emission cylinder.
  13472. */
  13473. radius: number;
  13474. /**
  13475. * The height of the emission cylinder.
  13476. */
  13477. height: number;
  13478. /**
  13479. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13480. */
  13481. radiusRange: number;
  13482. /**
  13483. * How much to randomize the particle direction [0-1].
  13484. */
  13485. directionRandomizer: number;
  13486. /**
  13487. * Creates a new instance CylinderParticleEmitter
  13488. * @param radius the radius of the emission cylinder (1 by default)
  13489. * @param height the height of the emission cylinder (1 by default)
  13490. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13492. */
  13493. constructor(
  13494. /**
  13495. * The radius of the emission cylinder.
  13496. */
  13497. radius?: number,
  13498. /**
  13499. * The height of the emission cylinder.
  13500. */
  13501. height?: number,
  13502. /**
  13503. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13504. */
  13505. radiusRange?: number,
  13506. /**
  13507. * How much to randomize the particle direction [0-1].
  13508. */
  13509. directionRandomizer?: number);
  13510. /**
  13511. * Called by the particle System when the direction is computed for the created particle.
  13512. * @param worldMatrix is the world matrix of the particle system
  13513. * @param directionToUpdate is the direction vector to update with the result
  13514. * @param particle is the particle we are computed the direction for
  13515. * @param isLocal defines if the direction should be set in local space
  13516. */
  13517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13518. /**
  13519. * Called by the particle System when the position is computed for the created particle.
  13520. * @param worldMatrix is the world matrix of the particle system
  13521. * @param positionToUpdate is the position vector to update with the result
  13522. * @param particle is the particle we are computed the position for
  13523. * @param isLocal defines if the position should be set in local space
  13524. */
  13525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13526. /**
  13527. * Clones the current emitter and returns a copy of it
  13528. * @returns the new emitter
  13529. */
  13530. clone(): CylinderParticleEmitter;
  13531. /**
  13532. * Called by the GPUParticleSystem to setup the update shader
  13533. * @param effect defines the update shader
  13534. */
  13535. applyToShader(effect: Effect): void;
  13536. /**
  13537. * Returns a string to use to update the GPU particles update shader
  13538. * @returns a string containng the defines string
  13539. */
  13540. getEffectDefines(): string;
  13541. /**
  13542. * Returns the string "CylinderParticleEmitter"
  13543. * @returns a string containing the class name
  13544. */
  13545. getClassName(): string;
  13546. /**
  13547. * Serializes the particle system to a JSON object.
  13548. * @returns the JSON object
  13549. */
  13550. serialize(): any;
  13551. /**
  13552. * Parse properties from a JSON object
  13553. * @param serializationObject defines the JSON object
  13554. */
  13555. parse(serializationObject: any): void;
  13556. }
  13557. /**
  13558. * Particle emitter emitting particles from the inside of a cylinder.
  13559. * It emits the particles randomly between two vectors.
  13560. */
  13561. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13562. /**
  13563. * The min limit of the emission direction.
  13564. */
  13565. direction1: Vector3;
  13566. /**
  13567. * The max limit of the emission direction.
  13568. */
  13569. direction2: Vector3;
  13570. /**
  13571. * Creates a new instance CylinderDirectedParticleEmitter
  13572. * @param radius the radius of the emission cylinder (1 by default)
  13573. * @param height the height of the emission cylinder (1 by default)
  13574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13575. * @param direction1 the min limit of the emission direction (up vector by default)
  13576. * @param direction2 the max limit of the emission direction (up vector by default)
  13577. */
  13578. constructor(radius?: number, height?: number, radiusRange?: number,
  13579. /**
  13580. * The min limit of the emission direction.
  13581. */
  13582. direction1?: Vector3,
  13583. /**
  13584. * The max limit of the emission direction.
  13585. */
  13586. direction2?: Vector3);
  13587. /**
  13588. * Called by the particle System when the direction is computed for the created particle.
  13589. * @param worldMatrix is the world matrix of the particle system
  13590. * @param directionToUpdate is the direction vector to update with the result
  13591. * @param particle is the particle we are computed the direction for
  13592. */
  13593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13594. /**
  13595. * Clones the current emitter and returns a copy of it
  13596. * @returns the new emitter
  13597. */
  13598. clone(): CylinderDirectedParticleEmitter;
  13599. /**
  13600. * Called by the GPUParticleSystem to setup the update shader
  13601. * @param effect defines the update shader
  13602. */
  13603. applyToShader(effect: Effect): void;
  13604. /**
  13605. * Returns a string to use to update the GPU particles update shader
  13606. * @returns a string containng the defines string
  13607. */
  13608. getEffectDefines(): string;
  13609. /**
  13610. * Returns the string "CylinderDirectedParticleEmitter"
  13611. * @returns a string containing the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Serializes the particle system to a JSON object.
  13616. * @returns the JSON object
  13617. */
  13618. serialize(): any;
  13619. /**
  13620. * Parse properties from a JSON object
  13621. * @param serializationObject defines the JSON object
  13622. */
  13623. parse(serializationObject: any): void;
  13624. }
  13625. }
  13626. declare module BABYLON {
  13627. /**
  13628. * Particle emitter emitting particles from the inside of a hemisphere.
  13629. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13630. */
  13631. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13632. /**
  13633. * The radius of the emission hemisphere.
  13634. */
  13635. radius: number;
  13636. /**
  13637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13638. */
  13639. radiusRange: number;
  13640. /**
  13641. * How much to randomize the particle direction [0-1].
  13642. */
  13643. directionRandomizer: number;
  13644. /**
  13645. * Creates a new instance HemisphericParticleEmitter
  13646. * @param radius the radius of the emission hemisphere (1 by default)
  13647. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13649. */
  13650. constructor(
  13651. /**
  13652. * The radius of the emission hemisphere.
  13653. */
  13654. radius?: number,
  13655. /**
  13656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13657. */
  13658. radiusRange?: number,
  13659. /**
  13660. * How much to randomize the particle direction [0-1].
  13661. */
  13662. directionRandomizer?: number);
  13663. /**
  13664. * Called by the particle System when the direction is computed for the created particle.
  13665. * @param worldMatrix is the world matrix of the particle system
  13666. * @param directionToUpdate is the direction vector to update with the result
  13667. * @param particle is the particle we are computed the direction for
  13668. * @param isLocal defines if the direction should be set in local space
  13669. */
  13670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13671. /**
  13672. * Called by the particle System when the position is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param positionToUpdate is the position vector to update with the result
  13675. * @param particle is the particle we are computed the position for
  13676. * @param isLocal defines if the position should be set in local space
  13677. */
  13678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13679. /**
  13680. * Clones the current emitter and returns a copy of it
  13681. * @returns the new emitter
  13682. */
  13683. clone(): HemisphericParticleEmitter;
  13684. /**
  13685. * Called by the GPUParticleSystem to setup the update shader
  13686. * @param effect defines the update shader
  13687. */
  13688. applyToShader(effect: Effect): void;
  13689. /**
  13690. * Returns a string to use to update the GPU particles update shader
  13691. * @returns a string containng the defines string
  13692. */
  13693. getEffectDefines(): string;
  13694. /**
  13695. * Returns the string "HemisphericParticleEmitter"
  13696. * @returns a string containing the class name
  13697. */
  13698. getClassName(): string;
  13699. /**
  13700. * Serializes the particle system to a JSON object.
  13701. * @returns the JSON object
  13702. */
  13703. serialize(): any;
  13704. /**
  13705. * Parse properties from a JSON object
  13706. * @param serializationObject defines the JSON object
  13707. */
  13708. parse(serializationObject: any): void;
  13709. }
  13710. }
  13711. declare module BABYLON {
  13712. /**
  13713. * Particle emitter emitting particles from a point.
  13714. * It emits the particles randomly between 2 given directions.
  13715. */
  13716. export class PointParticleEmitter implements IParticleEmitterType {
  13717. /**
  13718. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13719. */
  13720. direction1: Vector3;
  13721. /**
  13722. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13723. */
  13724. direction2: Vector3;
  13725. /**
  13726. * Creates a new instance PointParticleEmitter
  13727. */
  13728. constructor();
  13729. /**
  13730. * Called by the particle System when the direction is computed for the created particle.
  13731. * @param worldMatrix is the world matrix of the particle system
  13732. * @param directionToUpdate is the direction vector to update with the result
  13733. * @param particle is the particle we are computed the direction for
  13734. * @param isLocal defines if the direction should be set in local space
  13735. */
  13736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13737. /**
  13738. * Called by the particle System when the position is computed for the created particle.
  13739. * @param worldMatrix is the world matrix of the particle system
  13740. * @param positionToUpdate is the position vector to update with the result
  13741. * @param particle is the particle we are computed the position for
  13742. * @param isLocal defines if the position should be set in local space
  13743. */
  13744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13745. /**
  13746. * Clones the current emitter and returns a copy of it
  13747. * @returns the new emitter
  13748. */
  13749. clone(): PointParticleEmitter;
  13750. /**
  13751. * Called by the GPUParticleSystem to setup the update shader
  13752. * @param effect defines the update shader
  13753. */
  13754. applyToShader(effect: Effect): void;
  13755. /**
  13756. * Returns a string to use to update the GPU particles update shader
  13757. * @returns a string containng the defines string
  13758. */
  13759. getEffectDefines(): string;
  13760. /**
  13761. * Returns the string "PointParticleEmitter"
  13762. * @returns a string containing the class name
  13763. */
  13764. getClassName(): string;
  13765. /**
  13766. * Serializes the particle system to a JSON object.
  13767. * @returns the JSON object
  13768. */
  13769. serialize(): any;
  13770. /**
  13771. * Parse properties from a JSON object
  13772. * @param serializationObject defines the JSON object
  13773. */
  13774. parse(serializationObject: any): void;
  13775. }
  13776. }
  13777. declare module BABYLON {
  13778. /**
  13779. * Particle emitter emitting particles from the inside of a sphere.
  13780. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13781. */
  13782. export class SphereParticleEmitter implements IParticleEmitterType {
  13783. /**
  13784. * The radius of the emission sphere.
  13785. */
  13786. radius: number;
  13787. /**
  13788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13789. */
  13790. radiusRange: number;
  13791. /**
  13792. * How much to randomize the particle direction [0-1].
  13793. */
  13794. directionRandomizer: number;
  13795. /**
  13796. * Creates a new instance SphereParticleEmitter
  13797. * @param radius the radius of the emission sphere (1 by default)
  13798. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13800. */
  13801. constructor(
  13802. /**
  13803. * The radius of the emission sphere.
  13804. */
  13805. radius?: number,
  13806. /**
  13807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13808. */
  13809. radiusRange?: number,
  13810. /**
  13811. * How much to randomize the particle direction [0-1].
  13812. */
  13813. directionRandomizer?: number);
  13814. /**
  13815. * Called by the particle System when the direction is computed for the created particle.
  13816. * @param worldMatrix is the world matrix of the particle system
  13817. * @param directionToUpdate is the direction vector to update with the result
  13818. * @param particle is the particle we are computed the direction for
  13819. * @param isLocal defines if the direction should be set in local space
  13820. */
  13821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13822. /**
  13823. * Called by the particle System when the position is computed for the created particle.
  13824. * @param worldMatrix is the world matrix of the particle system
  13825. * @param positionToUpdate is the position vector to update with the result
  13826. * @param particle is the particle we are computed the position for
  13827. * @param isLocal defines if the position should be set in local space
  13828. */
  13829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13830. /**
  13831. * Clones the current emitter and returns a copy of it
  13832. * @returns the new emitter
  13833. */
  13834. clone(): SphereParticleEmitter;
  13835. /**
  13836. * Called by the GPUParticleSystem to setup the update shader
  13837. * @param effect defines the update shader
  13838. */
  13839. applyToShader(effect: Effect): void;
  13840. /**
  13841. * Returns a string to use to update the GPU particles update shader
  13842. * @returns a string containng the defines string
  13843. */
  13844. getEffectDefines(): string;
  13845. /**
  13846. * Returns the string "SphereParticleEmitter"
  13847. * @returns a string containing the class name
  13848. */
  13849. getClassName(): string;
  13850. /**
  13851. * Serializes the particle system to a JSON object.
  13852. * @returns the JSON object
  13853. */
  13854. serialize(): any;
  13855. /**
  13856. * Parse properties from a JSON object
  13857. * @param serializationObject defines the JSON object
  13858. */
  13859. parse(serializationObject: any): void;
  13860. }
  13861. /**
  13862. * Particle emitter emitting particles from the inside of a sphere.
  13863. * It emits the particles randomly between two vectors.
  13864. */
  13865. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13866. /**
  13867. * The min limit of the emission direction.
  13868. */
  13869. direction1: Vector3;
  13870. /**
  13871. * The max limit of the emission direction.
  13872. */
  13873. direction2: Vector3;
  13874. /**
  13875. * Creates a new instance SphereDirectedParticleEmitter
  13876. * @param radius the radius of the emission sphere (1 by default)
  13877. * @param direction1 the min limit of the emission direction (up vector by default)
  13878. * @param direction2 the max limit of the emission direction (up vector by default)
  13879. */
  13880. constructor(radius?: number,
  13881. /**
  13882. * The min limit of the emission direction.
  13883. */
  13884. direction1?: Vector3,
  13885. /**
  13886. * The max limit of the emission direction.
  13887. */
  13888. direction2?: Vector3);
  13889. /**
  13890. * Called by the particle System when the direction is computed for the created particle.
  13891. * @param worldMatrix is the world matrix of the particle system
  13892. * @param directionToUpdate is the direction vector to update with the result
  13893. * @param particle is the particle we are computed the direction for
  13894. */
  13895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13896. /**
  13897. * Clones the current emitter and returns a copy of it
  13898. * @returns the new emitter
  13899. */
  13900. clone(): SphereDirectedParticleEmitter;
  13901. /**
  13902. * Called by the GPUParticleSystem to setup the update shader
  13903. * @param effect defines the update shader
  13904. */
  13905. applyToShader(effect: Effect): void;
  13906. /**
  13907. * Returns a string to use to update the GPU particles update shader
  13908. * @returns a string containng the defines string
  13909. */
  13910. getEffectDefines(): string;
  13911. /**
  13912. * Returns the string "SphereDirectedParticleEmitter"
  13913. * @returns a string containing the class name
  13914. */
  13915. getClassName(): string;
  13916. /**
  13917. * Serializes the particle system to a JSON object.
  13918. * @returns the JSON object
  13919. */
  13920. serialize(): any;
  13921. /**
  13922. * Parse properties from a JSON object
  13923. * @param serializationObject defines the JSON object
  13924. */
  13925. parse(serializationObject: any): void;
  13926. }
  13927. }
  13928. declare module BABYLON {
  13929. /**
  13930. * Particle emitter emitting particles from a custom list of positions.
  13931. */
  13932. export class CustomParticleEmitter implements IParticleEmitterType {
  13933. /**
  13934. * Gets or sets the position generator that will create the inital position of each particle.
  13935. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13936. */
  13937. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13938. /**
  13939. * Gets or sets the destination generator that will create the final destination of each particle.
  13940. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13941. */
  13942. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13943. /**
  13944. * Creates a new instance CustomParticleEmitter
  13945. */
  13946. constructor();
  13947. /**
  13948. * Called by the particle System when the direction is computed for the created particle.
  13949. * @param worldMatrix is the world matrix of the particle system
  13950. * @param directionToUpdate is the direction vector to update with the result
  13951. * @param particle is the particle we are computed the direction for
  13952. * @param isLocal defines if the direction should be set in local space
  13953. */
  13954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13955. /**
  13956. * Called by the particle System when the position is computed for the created particle.
  13957. * @param worldMatrix is the world matrix of the particle system
  13958. * @param positionToUpdate is the position vector to update with the result
  13959. * @param particle is the particle we are computed the position for
  13960. * @param isLocal defines if the position should be set in local space
  13961. */
  13962. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13963. /**
  13964. * Clones the current emitter and returns a copy of it
  13965. * @returns the new emitter
  13966. */
  13967. clone(): CustomParticleEmitter;
  13968. /**
  13969. * Called by the GPUParticleSystem to setup the update shader
  13970. * @param effect defines the update shader
  13971. */
  13972. applyToShader(effect: Effect): void;
  13973. /**
  13974. * Returns a string to use to update the GPU particles update shader
  13975. * @returns a string containng the defines string
  13976. */
  13977. getEffectDefines(): string;
  13978. /**
  13979. * Returns the string "PointParticleEmitter"
  13980. * @returns a string containing the class name
  13981. */
  13982. getClassName(): string;
  13983. /**
  13984. * Serializes the particle system to a JSON object.
  13985. * @returns the JSON object
  13986. */
  13987. serialize(): any;
  13988. /**
  13989. * Parse properties from a JSON object
  13990. * @param serializationObject defines the JSON object
  13991. */
  13992. parse(serializationObject: any): void;
  13993. }
  13994. }
  13995. declare module BABYLON {
  13996. /**
  13997. * Particle emitter emitting particles from the inside of a box.
  13998. * It emits the particles randomly between 2 given directions.
  13999. */
  14000. export class MeshParticleEmitter implements IParticleEmitterType {
  14001. private _indices;
  14002. private _positions;
  14003. private _normals;
  14004. private _storedNormal;
  14005. private _mesh;
  14006. /**
  14007. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14008. */
  14009. direction1: Vector3;
  14010. /**
  14011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14012. */
  14013. direction2: Vector3;
  14014. /**
  14015. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14016. */
  14017. useMeshNormalsForDirection: boolean;
  14018. /** Defines the mesh to use as source */
  14019. get mesh(): Nullable<AbstractMesh>;
  14020. set mesh(value: Nullable<AbstractMesh>);
  14021. /**
  14022. * Creates a new instance MeshParticleEmitter
  14023. * @param mesh defines the mesh to use as source
  14024. */
  14025. constructor(mesh?: Nullable<AbstractMesh>);
  14026. /**
  14027. * Called by the particle System when the direction is computed for the created particle.
  14028. * @param worldMatrix is the world matrix of the particle system
  14029. * @param directionToUpdate is the direction vector to update with the result
  14030. * @param particle is the particle we are computed the direction for
  14031. * @param isLocal defines if the direction should be set in local space
  14032. */
  14033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14034. /**
  14035. * Called by the particle System when the position is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param positionToUpdate is the position vector to update with the result
  14038. * @param particle is the particle we are computed the position for
  14039. * @param isLocal defines if the position should be set in local space
  14040. */
  14041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Clones the current emitter and returns a copy of it
  14044. * @returns the new emitter
  14045. */
  14046. clone(): MeshParticleEmitter;
  14047. /**
  14048. * Called by the GPUParticleSystem to setup the update shader
  14049. * @param effect defines the update shader
  14050. */
  14051. applyToShader(effect: Effect): void;
  14052. /**
  14053. * Returns a string to use to update the GPU particles update shader
  14054. * @returns a string containng the defines string
  14055. */
  14056. getEffectDefines(): string;
  14057. /**
  14058. * Returns the string "BoxParticleEmitter"
  14059. * @returns a string containing the class name
  14060. */
  14061. getClassName(): string;
  14062. /**
  14063. * Serializes the particle system to a JSON object.
  14064. * @returns the JSON object
  14065. */
  14066. serialize(): any;
  14067. /**
  14068. * Parse properties from a JSON object
  14069. * @param serializationObject defines the JSON object
  14070. * @param scene defines the hosting scene
  14071. */
  14072. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14073. }
  14074. }
  14075. declare module BABYLON {
  14076. /**
  14077. * Interface representing a particle system in Babylon.js.
  14078. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14079. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14080. */
  14081. export interface IParticleSystem {
  14082. /**
  14083. * List of animations used by the particle system.
  14084. */
  14085. animations: Animation[];
  14086. /**
  14087. * The id of the Particle system.
  14088. */
  14089. id: string;
  14090. /**
  14091. * The name of the Particle system.
  14092. */
  14093. name: string;
  14094. /**
  14095. * The emitter represents the Mesh or position we are attaching the particle system to.
  14096. */
  14097. emitter: Nullable<AbstractMesh | Vector3>;
  14098. /**
  14099. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14100. */
  14101. isBillboardBased: boolean;
  14102. /**
  14103. * The rendering group used by the Particle system to chose when to render.
  14104. */
  14105. renderingGroupId: number;
  14106. /**
  14107. * The layer mask we are rendering the particles through.
  14108. */
  14109. layerMask: number;
  14110. /**
  14111. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14112. */
  14113. updateSpeed: number;
  14114. /**
  14115. * The amount of time the particle system is running (depends of the overall update speed).
  14116. */
  14117. targetStopDuration: number;
  14118. /**
  14119. * The texture used to render each particle. (this can be a spritesheet)
  14120. */
  14121. particleTexture: Nullable<BaseTexture>;
  14122. /**
  14123. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14124. */
  14125. blendMode: number;
  14126. /**
  14127. * Minimum life time of emitting particles.
  14128. */
  14129. minLifeTime: number;
  14130. /**
  14131. * Maximum life time of emitting particles.
  14132. */
  14133. maxLifeTime: number;
  14134. /**
  14135. * Minimum Size of emitting particles.
  14136. */
  14137. minSize: number;
  14138. /**
  14139. * Maximum Size of emitting particles.
  14140. */
  14141. maxSize: number;
  14142. /**
  14143. * Minimum scale of emitting particles on X axis.
  14144. */
  14145. minScaleX: number;
  14146. /**
  14147. * Maximum scale of emitting particles on X axis.
  14148. */
  14149. maxScaleX: number;
  14150. /**
  14151. * Minimum scale of emitting particles on Y axis.
  14152. */
  14153. minScaleY: number;
  14154. /**
  14155. * Maximum scale of emitting particles on Y axis.
  14156. */
  14157. maxScaleY: number;
  14158. /**
  14159. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14160. */
  14161. color1: Color4;
  14162. /**
  14163. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14164. */
  14165. color2: Color4;
  14166. /**
  14167. * Color the particle will have at the end of its lifetime.
  14168. */
  14169. colorDead: Color4;
  14170. /**
  14171. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14172. */
  14173. emitRate: number;
  14174. /**
  14175. * You can use gravity if you want to give an orientation to your particles.
  14176. */
  14177. gravity: Vector3;
  14178. /**
  14179. * Minimum power of emitting particles.
  14180. */
  14181. minEmitPower: number;
  14182. /**
  14183. * Maximum power of emitting particles.
  14184. */
  14185. maxEmitPower: number;
  14186. /**
  14187. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14188. */
  14189. minAngularSpeed: number;
  14190. /**
  14191. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14192. */
  14193. maxAngularSpeed: number;
  14194. /**
  14195. * Gets or sets the minimal initial rotation in radians.
  14196. */
  14197. minInitialRotation: number;
  14198. /**
  14199. * Gets or sets the maximal initial rotation in radians.
  14200. */
  14201. maxInitialRotation: number;
  14202. /**
  14203. * The particle emitter type defines the emitter used by the particle system.
  14204. * It can be for example box, sphere, or cone...
  14205. */
  14206. particleEmitterType: Nullable<IParticleEmitterType>;
  14207. /**
  14208. * Defines the delay in milliseconds before starting the system (0 by default)
  14209. */
  14210. startDelay: number;
  14211. /**
  14212. * 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
  14213. */
  14214. preWarmCycles: number;
  14215. /**
  14216. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14217. */
  14218. preWarmStepOffset: number;
  14219. /**
  14220. * 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)
  14221. */
  14222. spriteCellChangeSpeed: number;
  14223. /**
  14224. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14225. */
  14226. startSpriteCellID: number;
  14227. /**
  14228. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14229. */
  14230. endSpriteCellID: number;
  14231. /**
  14232. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14233. */
  14234. spriteCellWidth: number;
  14235. /**
  14236. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14237. */
  14238. spriteCellHeight: number;
  14239. /**
  14240. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14241. */
  14242. spriteRandomStartCell: boolean;
  14243. /**
  14244. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14245. */
  14246. isAnimationSheetEnabled: boolean;
  14247. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14248. translationPivot: Vector2;
  14249. /**
  14250. * Gets or sets a texture used to add random noise to particle positions
  14251. */
  14252. noiseTexture: Nullable<BaseTexture>;
  14253. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14254. noiseStrength: Vector3;
  14255. /**
  14256. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14257. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14258. */
  14259. billboardMode: number;
  14260. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14261. limitVelocityDamping: number;
  14262. /**
  14263. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14264. */
  14265. beginAnimationOnStart: boolean;
  14266. /**
  14267. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14268. */
  14269. beginAnimationFrom: number;
  14270. /**
  14271. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14272. */
  14273. beginAnimationTo: number;
  14274. /**
  14275. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14276. */
  14277. beginAnimationLoop: boolean;
  14278. /**
  14279. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14280. */
  14281. disposeOnStop: boolean;
  14282. /**
  14283. * Specifies if the particles are updated in emitter local space or world space
  14284. */
  14285. isLocal: boolean;
  14286. /** Snippet ID if the particle system was created from the snippet server */
  14287. snippetId: string;
  14288. /** Gets or sets a matrix to use to compute projection */
  14289. defaultProjectionMatrix: Matrix;
  14290. /**
  14291. * Gets the maximum number of particles active at the same time.
  14292. * @returns The max number of active particles.
  14293. */
  14294. getCapacity(): number;
  14295. /**
  14296. * Gets the number of particles active at the same time.
  14297. * @returns The number of active particles.
  14298. */
  14299. getActiveCount(): number;
  14300. /**
  14301. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14302. * @returns True if it has been started, otherwise false.
  14303. */
  14304. isStarted(): boolean;
  14305. /**
  14306. * Animates the particle system for this frame.
  14307. */
  14308. animate(): void;
  14309. /**
  14310. * Renders the particle system in its current state.
  14311. * @returns the current number of particles
  14312. */
  14313. render(): number;
  14314. /**
  14315. * Dispose the particle system and frees its associated resources.
  14316. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14317. */
  14318. dispose(disposeTexture?: boolean): void;
  14319. /**
  14320. * An event triggered when the system is disposed
  14321. */
  14322. onDisposeObservable: Observable<IParticleSystem>;
  14323. /**
  14324. * An event triggered when the system is stopped
  14325. */
  14326. onStoppedObservable: Observable<IParticleSystem>;
  14327. /**
  14328. * Clones the particle system.
  14329. * @param name The name of the cloned object
  14330. * @param newEmitter The new emitter to use
  14331. * @returns the cloned particle system
  14332. */
  14333. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14334. /**
  14335. * Serializes the particle system to a JSON object
  14336. * @param serializeTexture defines if the texture must be serialized as well
  14337. * @returns the JSON object
  14338. */
  14339. serialize(serializeTexture: boolean): any;
  14340. /**
  14341. * Rebuild the particle system
  14342. */
  14343. rebuild(): void;
  14344. /** Force the system to rebuild all gradients that need to be resync */
  14345. forceRefreshGradients(): void;
  14346. /**
  14347. * Starts the particle system and begins to emit
  14348. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14349. */
  14350. start(delay?: number): void;
  14351. /**
  14352. * Stops the particle system.
  14353. */
  14354. stop(): void;
  14355. /**
  14356. * Remove all active particles
  14357. */
  14358. reset(): void;
  14359. /**
  14360. * Gets a boolean indicating that the system is stopping
  14361. * @returns true if the system is currently stopping
  14362. */
  14363. isStopping(): boolean;
  14364. /**
  14365. * Is this system ready to be used/rendered
  14366. * @return true if the system is ready
  14367. */
  14368. isReady(): boolean;
  14369. /**
  14370. * Returns the string "ParticleSystem"
  14371. * @returns a string containing the class name
  14372. */
  14373. getClassName(): string;
  14374. /**
  14375. * Gets the custom effect used to render the particles
  14376. * @param blendMode Blend mode for which the effect should be retrieved
  14377. * @returns The effect
  14378. */
  14379. getCustomEffect(blendMode: number): Nullable<Effect>;
  14380. /**
  14381. * Sets the custom effect used to render the particles
  14382. * @param effect The effect to set
  14383. * @param blendMode Blend mode for which the effect should be set
  14384. */
  14385. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14386. /**
  14387. * Fill the defines array according to the current settings of the particle system
  14388. * @param defines Array to be updated
  14389. * @param blendMode blend mode to take into account when updating the array
  14390. */
  14391. fillDefines(defines: Array<string>, blendMode: number): void;
  14392. /**
  14393. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14394. * @param uniforms Uniforms array to fill
  14395. * @param attributes Attributes array to fill
  14396. * @param samplers Samplers array to fill
  14397. */
  14398. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14399. /**
  14400. * Observable that will be called just before the particles are drawn
  14401. */
  14402. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14403. /**
  14404. * Gets the name of the particle vertex shader
  14405. */
  14406. vertexShaderName: string;
  14407. /**
  14408. * Adds a new color gradient
  14409. * @param gradient defines the gradient to use (between 0 and 1)
  14410. * @param color1 defines the color to affect to the specified gradient
  14411. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14412. * @returns the current particle system
  14413. */
  14414. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14415. /**
  14416. * Remove a specific color gradient
  14417. * @param gradient defines the gradient to remove
  14418. * @returns the current particle system
  14419. */
  14420. removeColorGradient(gradient: number): IParticleSystem;
  14421. /**
  14422. * Adds a new size gradient
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the size factor to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific size gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeSizeGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of color gradients.
  14437. * You must use addColorGradient and removeColorGradient to udpate this list
  14438. * @returns the list of color gradients
  14439. */
  14440. getColorGradients(): Nullable<Array<ColorGradient>>;
  14441. /**
  14442. * Gets the current list of size gradients.
  14443. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14444. * @returns the list of size gradients
  14445. */
  14446. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14447. /**
  14448. * Gets the current list of angular speed gradients.
  14449. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14450. * @returns the list of angular speed gradients
  14451. */
  14452. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14453. /**
  14454. * Adds a new angular speed gradient
  14455. * @param gradient defines the gradient to use (between 0 and 1)
  14456. * @param factor defines the angular speed to affect to the specified gradient
  14457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14458. * @returns the current particle system
  14459. */
  14460. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14461. /**
  14462. * Remove a specific angular speed gradient
  14463. * @param gradient defines the gradient to remove
  14464. * @returns the current particle system
  14465. */
  14466. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14467. /**
  14468. * Gets the current list of velocity gradients.
  14469. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14470. * @returns the list of velocity gradients
  14471. */
  14472. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14473. /**
  14474. * Adds a new velocity gradient
  14475. * @param gradient defines the gradient to use (between 0 and 1)
  14476. * @param factor defines the velocity to affect to the specified gradient
  14477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14478. * @returns the current particle system
  14479. */
  14480. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14481. /**
  14482. * Remove a specific velocity gradient
  14483. * @param gradient defines the gradient to remove
  14484. * @returns the current particle system
  14485. */
  14486. removeVelocityGradient(gradient: number): IParticleSystem;
  14487. /**
  14488. * Gets the current list of limit velocity gradients.
  14489. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14490. * @returns the list of limit velocity gradients
  14491. */
  14492. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14493. /**
  14494. * Adds a new limit velocity gradient
  14495. * @param gradient defines the gradient to use (between 0 and 1)
  14496. * @param factor defines the limit velocity to affect to the specified gradient
  14497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14498. * @returns the current particle system
  14499. */
  14500. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14501. /**
  14502. * Remove a specific limit velocity gradient
  14503. * @param gradient defines the gradient to remove
  14504. * @returns the current particle system
  14505. */
  14506. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14507. /**
  14508. * Adds a new drag gradient
  14509. * @param gradient defines the gradient to use (between 0 and 1)
  14510. * @param factor defines the drag to affect to the specified gradient
  14511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14512. * @returns the current particle system
  14513. */
  14514. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14515. /**
  14516. * Remove a specific drag gradient
  14517. * @param gradient defines the gradient to remove
  14518. * @returns the current particle system
  14519. */
  14520. removeDragGradient(gradient: number): IParticleSystem;
  14521. /**
  14522. * Gets the current list of drag gradients.
  14523. * You must use addDragGradient and removeDragGradient to udpate this list
  14524. * @returns the list of drag gradients
  14525. */
  14526. getDragGradients(): Nullable<Array<FactorGradient>>;
  14527. /**
  14528. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14529. * @param gradient defines the gradient to use (between 0 and 1)
  14530. * @param factor defines the emit rate to affect to the specified gradient
  14531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14532. * @returns the current particle system
  14533. */
  14534. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14535. /**
  14536. * Remove a specific emit rate gradient
  14537. * @param gradient defines the gradient to remove
  14538. * @returns the current particle system
  14539. */
  14540. removeEmitRateGradient(gradient: number): IParticleSystem;
  14541. /**
  14542. * Gets the current list of emit rate gradients.
  14543. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14544. * @returns the list of emit rate gradients
  14545. */
  14546. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14547. /**
  14548. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14549. * @param gradient defines the gradient to use (between 0 and 1)
  14550. * @param factor defines the start size to affect to the specified gradient
  14551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14552. * @returns the current particle system
  14553. */
  14554. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14555. /**
  14556. * Remove a specific start size gradient
  14557. * @param gradient defines the gradient to remove
  14558. * @returns the current particle system
  14559. */
  14560. removeStartSizeGradient(gradient: number): IParticleSystem;
  14561. /**
  14562. * Gets the current list of start size gradients.
  14563. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14564. * @returns the list of start size gradients
  14565. */
  14566. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14567. /**
  14568. * Adds a new life time gradient
  14569. * @param gradient defines the gradient to use (between 0 and 1)
  14570. * @param factor defines the life time factor to affect to the specified gradient
  14571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14572. * @returns the current particle system
  14573. */
  14574. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14575. /**
  14576. * Remove a specific life time gradient
  14577. * @param gradient defines the gradient to remove
  14578. * @returns the current particle system
  14579. */
  14580. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14581. /**
  14582. * Gets the current list of life time gradients.
  14583. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14584. * @returns the list of life time gradients
  14585. */
  14586. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14587. /**
  14588. * Gets the current list of color gradients.
  14589. * You must use addColorGradient and removeColorGradient to udpate this list
  14590. * @returns the list of color gradients
  14591. */
  14592. getColorGradients(): Nullable<Array<ColorGradient>>;
  14593. /**
  14594. * Adds a new ramp gradient used to remap particle colors
  14595. * @param gradient defines the gradient to use (between 0 and 1)
  14596. * @param color defines the color to affect to the specified gradient
  14597. * @returns the current particle system
  14598. */
  14599. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14600. /**
  14601. * Gets the current list of ramp gradients.
  14602. * You must use addRampGradient and removeRampGradient to udpate this list
  14603. * @returns the list of ramp gradients
  14604. */
  14605. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14606. /** Gets or sets a boolean indicating that ramp gradients must be used
  14607. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14608. */
  14609. useRampGradients: boolean;
  14610. /**
  14611. * Adds a new color remap gradient
  14612. * @param gradient defines the gradient to use (between 0 and 1)
  14613. * @param min defines the color remap minimal range
  14614. * @param max defines the color remap maximal range
  14615. * @returns the current particle system
  14616. */
  14617. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14618. /**
  14619. * Gets the current list of color remap gradients.
  14620. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14621. * @returns the list of color remap gradients
  14622. */
  14623. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14624. /**
  14625. * Adds a new alpha remap gradient
  14626. * @param gradient defines the gradient to use (between 0 and 1)
  14627. * @param min defines the alpha remap minimal range
  14628. * @param max defines the alpha remap maximal range
  14629. * @returns the current particle system
  14630. */
  14631. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of alpha remap gradients.
  14634. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14635. * @returns the list of alpha remap gradients
  14636. */
  14637. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14640. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14641. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14642. * @returns the emitter
  14643. */
  14644. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14645. /**
  14646. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14647. * @param radius The radius of the hemisphere to emit from
  14648. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14649. * @returns the emitter
  14650. */
  14651. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14652. /**
  14653. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14654. * @param radius The radius of the sphere to emit from
  14655. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14656. * @returns the emitter
  14657. */
  14658. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14659. /**
  14660. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14661. * @param radius The radius of the sphere to emit from
  14662. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14663. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14664. * @returns the emitter
  14665. */
  14666. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14667. /**
  14668. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14669. * @param radius The radius of the emission cylinder
  14670. * @param height The height of the emission cylinder
  14671. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14672. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14673. * @returns the emitter
  14674. */
  14675. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14676. /**
  14677. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14678. * @param radius The radius of the cylinder to emit from
  14679. * @param height The height of the emission cylinder
  14680. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14681. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14682. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14683. * @returns the emitter
  14684. */
  14685. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14686. /**
  14687. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14688. * @param radius The radius of the cone to emit from
  14689. * @param angle The base angle of the cone
  14690. * @returns the emitter
  14691. */
  14692. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14693. /**
  14694. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14697. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14698. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14699. * @returns the emitter
  14700. */
  14701. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14702. /**
  14703. * Get hosting scene
  14704. * @returns the scene
  14705. */
  14706. getScene(): Nullable<Scene>;
  14707. }
  14708. }
  14709. declare module BABYLON {
  14710. /**
  14711. * 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.
  14712. * @see https://doc.babylonjs.com/how_to/transformnode
  14713. */
  14714. export class TransformNode extends Node {
  14715. /**
  14716. * Object will not rotate to face the camera
  14717. */
  14718. static BILLBOARDMODE_NONE: number;
  14719. /**
  14720. * Object will rotate to face the camera but only on the x axis
  14721. */
  14722. static BILLBOARDMODE_X: number;
  14723. /**
  14724. * Object will rotate to face the camera but only on the y axis
  14725. */
  14726. static BILLBOARDMODE_Y: number;
  14727. /**
  14728. * Object will rotate to face the camera but only on the z axis
  14729. */
  14730. static BILLBOARDMODE_Z: number;
  14731. /**
  14732. * Object will rotate to face the camera
  14733. */
  14734. static BILLBOARDMODE_ALL: number;
  14735. /**
  14736. * Object will rotate to face the camera's position instead of orientation
  14737. */
  14738. static BILLBOARDMODE_USE_POSITION: number;
  14739. private static _TmpRotation;
  14740. private static _TmpScaling;
  14741. private static _TmpTranslation;
  14742. private _forward;
  14743. private _forwardInverted;
  14744. private _up;
  14745. private _right;
  14746. private _rightInverted;
  14747. private _position;
  14748. private _rotation;
  14749. private _rotationQuaternion;
  14750. protected _scaling: Vector3;
  14751. protected _isDirty: boolean;
  14752. private _transformToBoneReferal;
  14753. private _isAbsoluteSynced;
  14754. private _billboardMode;
  14755. /**
  14756. * Gets or sets the billboard mode. Default is 0.
  14757. *
  14758. * | Value | Type | Description |
  14759. * | --- | --- | --- |
  14760. * | 0 | BILLBOARDMODE_NONE | |
  14761. * | 1 | BILLBOARDMODE_X | |
  14762. * | 2 | BILLBOARDMODE_Y | |
  14763. * | 4 | BILLBOARDMODE_Z | |
  14764. * | 7 | BILLBOARDMODE_ALL | |
  14765. *
  14766. */
  14767. get billboardMode(): number;
  14768. set billboardMode(value: number);
  14769. private _preserveParentRotationForBillboard;
  14770. /**
  14771. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14772. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14773. */
  14774. get preserveParentRotationForBillboard(): boolean;
  14775. set preserveParentRotationForBillboard(value: boolean);
  14776. /**
  14777. * 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
  14778. */
  14779. scalingDeterminant: number;
  14780. private _infiniteDistance;
  14781. /**
  14782. * Gets or sets the distance of the object to max, often used by skybox
  14783. */
  14784. get infiniteDistance(): boolean;
  14785. set infiniteDistance(value: boolean);
  14786. /**
  14787. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14788. * By default the system will update normals to compensate
  14789. */
  14790. ignoreNonUniformScaling: boolean;
  14791. /**
  14792. * 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
  14793. */
  14794. reIntegrateRotationIntoRotationQuaternion: boolean;
  14795. /** @hidden */
  14796. _poseMatrix: Nullable<Matrix>;
  14797. /** @hidden */
  14798. _localMatrix: Matrix;
  14799. private _usePivotMatrix;
  14800. private _absolutePosition;
  14801. private _absoluteScaling;
  14802. private _absoluteRotationQuaternion;
  14803. private _pivotMatrix;
  14804. private _pivotMatrixInverse;
  14805. /** @hidden */
  14806. _postMultiplyPivotMatrix: boolean;
  14807. protected _isWorldMatrixFrozen: boolean;
  14808. /** @hidden */
  14809. _indexInSceneTransformNodesArray: number;
  14810. /**
  14811. * An event triggered after the world matrix is updated
  14812. */
  14813. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14814. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14815. /**
  14816. * Gets a string identifying the name of the class
  14817. * @returns "TransformNode" string
  14818. */
  14819. getClassName(): string;
  14820. /**
  14821. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14822. */
  14823. get position(): Vector3;
  14824. set position(newPosition: Vector3);
  14825. /**
  14826. * 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)).
  14827. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14828. */
  14829. get rotation(): Vector3;
  14830. set rotation(newRotation: Vector3);
  14831. /**
  14832. * 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)).
  14833. */
  14834. get scaling(): Vector3;
  14835. set scaling(newScaling: Vector3);
  14836. /**
  14837. * 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).
  14838. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14839. */
  14840. get rotationQuaternion(): Nullable<Quaternion>;
  14841. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14842. /**
  14843. * The forward direction of that transform in world space.
  14844. */
  14845. get forward(): Vector3;
  14846. /**
  14847. * The up direction of that transform in world space.
  14848. */
  14849. get up(): Vector3;
  14850. /**
  14851. * The right direction of that transform in world space.
  14852. */
  14853. get right(): Vector3;
  14854. /**
  14855. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14856. * @param matrix the matrix to copy the pose from
  14857. * @returns this TransformNode.
  14858. */
  14859. updatePoseMatrix(matrix: Matrix): TransformNode;
  14860. /**
  14861. * Returns the mesh Pose matrix.
  14862. * @returns the pose matrix
  14863. */
  14864. getPoseMatrix(): Matrix;
  14865. /** @hidden */
  14866. _isSynchronized(): boolean;
  14867. /** @hidden */
  14868. _initCache(): void;
  14869. /**
  14870. * Flag the transform node as dirty (Forcing it to update everything)
  14871. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14872. * @returns this transform node
  14873. */
  14874. markAsDirty(property: string): TransformNode;
  14875. /**
  14876. * Returns the current mesh absolute position.
  14877. * Returns a Vector3.
  14878. */
  14879. get absolutePosition(): Vector3;
  14880. /**
  14881. * Returns the current mesh absolute scaling.
  14882. * Returns a Vector3.
  14883. */
  14884. get absoluteScaling(): Vector3;
  14885. /**
  14886. * Returns the current mesh absolute rotation.
  14887. * Returns a Quaternion.
  14888. */
  14889. get absoluteRotationQuaternion(): Quaternion;
  14890. /**
  14891. * Sets a new matrix to apply before all other transformation
  14892. * @param matrix defines the transform matrix
  14893. * @returns the current TransformNode
  14894. */
  14895. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14896. /**
  14897. * Sets a new pivot matrix to the current node
  14898. * @param matrix defines the new pivot matrix to use
  14899. * @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
  14900. * @returns the current TransformNode
  14901. */
  14902. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14903. /**
  14904. * Returns the mesh pivot matrix.
  14905. * Default : Identity.
  14906. * @returns the matrix
  14907. */
  14908. getPivotMatrix(): Matrix;
  14909. /**
  14910. * Instantiate (when possible) or clone that node with its hierarchy
  14911. * @param newParent defines the new parent to use for the instance (or clone)
  14912. * @param options defines options to configure how copy is done
  14913. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14914. * @returns an instance (or a clone) of the current node with its hiearchy
  14915. */
  14916. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14917. doNotInstantiate: boolean;
  14918. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14919. /**
  14920. * Prevents the World matrix to be computed any longer
  14921. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14922. * @returns the TransformNode.
  14923. */
  14924. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14925. /**
  14926. * Allows back the World matrix computation.
  14927. * @returns the TransformNode.
  14928. */
  14929. unfreezeWorldMatrix(): this;
  14930. /**
  14931. * True if the World matrix has been frozen.
  14932. */
  14933. get isWorldMatrixFrozen(): boolean;
  14934. /**
  14935. * Retuns the mesh absolute position in the World.
  14936. * @returns a Vector3.
  14937. */
  14938. getAbsolutePosition(): Vector3;
  14939. /**
  14940. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14941. * @param absolutePosition the absolute position to set
  14942. * @returns the TransformNode.
  14943. */
  14944. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14945. /**
  14946. * Sets the mesh position in its local space.
  14947. * @param vector3 the position to set in localspace
  14948. * @returns the TransformNode.
  14949. */
  14950. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14951. /**
  14952. * Returns the mesh position in the local space from the current World matrix values.
  14953. * @returns a new Vector3.
  14954. */
  14955. getPositionExpressedInLocalSpace(): Vector3;
  14956. /**
  14957. * Translates the mesh along the passed Vector3 in its local space.
  14958. * @param vector3 the distance to translate in localspace
  14959. * @returns the TransformNode.
  14960. */
  14961. locallyTranslate(vector3: Vector3): TransformNode;
  14962. private static _lookAtVectorCache;
  14963. /**
  14964. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14965. * @param targetPoint the position (must be in same space as current mesh) to look at
  14966. * @param yawCor optional yaw (y-axis) correction in radians
  14967. * @param pitchCor optional pitch (x-axis) correction in radians
  14968. * @param rollCor optional roll (z-axis) correction in radians
  14969. * @param space the choosen space of the target
  14970. * @returns the TransformNode.
  14971. */
  14972. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14973. /**
  14974. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14975. * This Vector3 is expressed in the World space.
  14976. * @param localAxis axis to rotate
  14977. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14978. */
  14979. getDirection(localAxis: Vector3): Vector3;
  14980. /**
  14981. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14982. * localAxis is expressed in the mesh local space.
  14983. * result is computed in the Wordl space from the mesh World matrix.
  14984. * @param localAxis axis to rotate
  14985. * @param result the resulting transformnode
  14986. * @returns this TransformNode.
  14987. */
  14988. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14989. /**
  14990. * Sets this transform node rotation to the given local axis.
  14991. * @param localAxis the axis in local space
  14992. * @param yawCor optional yaw (y-axis) correction in radians
  14993. * @param pitchCor optional pitch (x-axis) correction in radians
  14994. * @param rollCor optional roll (z-axis) correction in radians
  14995. * @returns this TransformNode
  14996. */
  14997. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14998. /**
  14999. * Sets a new pivot point to the current node
  15000. * @param point defines the new pivot point to use
  15001. * @param space defines if the point is in world or local space (local by default)
  15002. * @returns the current TransformNode
  15003. */
  15004. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15005. /**
  15006. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15007. * @returns the pivot point
  15008. */
  15009. getPivotPoint(): Vector3;
  15010. /**
  15011. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15012. * @param result the vector3 to store the result
  15013. * @returns this TransformNode.
  15014. */
  15015. getPivotPointToRef(result: Vector3): TransformNode;
  15016. /**
  15017. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15018. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15019. */
  15020. getAbsolutePivotPoint(): Vector3;
  15021. /**
  15022. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15023. * @param result vector3 to store the result
  15024. * @returns this TransformNode.
  15025. */
  15026. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15027. /**
  15028. * Defines the passed node as the parent of the current node.
  15029. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15030. * @see https://doc.babylonjs.com/how_to/parenting
  15031. * @param node the node ot set as the parent
  15032. * @returns this TransformNode.
  15033. */
  15034. setParent(node: Nullable<Node>): TransformNode;
  15035. private _nonUniformScaling;
  15036. /**
  15037. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15038. */
  15039. get nonUniformScaling(): boolean;
  15040. /** @hidden */
  15041. _updateNonUniformScalingState(value: boolean): boolean;
  15042. /**
  15043. * Attach the current TransformNode to another TransformNode associated with a bone
  15044. * @param bone Bone affecting the TransformNode
  15045. * @param affectedTransformNode TransformNode associated with the bone
  15046. * @returns this object
  15047. */
  15048. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15049. /**
  15050. * Detach the transform node if its associated with a bone
  15051. * @returns this object
  15052. */
  15053. detachFromBone(): TransformNode;
  15054. private static _rotationAxisCache;
  15055. /**
  15056. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15057. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15058. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15059. * The passed axis is also normalized.
  15060. * @param axis the axis to rotate around
  15061. * @param amount the amount to rotate in radians
  15062. * @param space Space to rotate in (Default: local)
  15063. * @returns the TransformNode.
  15064. */
  15065. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15066. /**
  15067. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15068. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15069. * The passed axis is also normalized. .
  15070. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15071. * @param point the point to rotate around
  15072. * @param axis the axis to rotate around
  15073. * @param amount the amount to rotate in radians
  15074. * @returns the TransformNode
  15075. */
  15076. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15077. /**
  15078. * Translates the mesh along the axis vector for the passed distance in the given space.
  15079. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15080. * @param axis the axis to translate in
  15081. * @param distance the distance to translate
  15082. * @param space Space to rotate in (Default: local)
  15083. * @returns the TransformNode.
  15084. */
  15085. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15086. /**
  15087. * Adds a rotation step to the mesh current rotation.
  15088. * x, y, z are Euler angles expressed in radians.
  15089. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15090. * This means this rotation is made in the mesh local space only.
  15091. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15092. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15093. * ```javascript
  15094. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15095. * ```
  15096. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15097. * 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.
  15098. * @param x Rotation to add
  15099. * @param y Rotation to add
  15100. * @param z Rotation to add
  15101. * @returns the TransformNode.
  15102. */
  15103. addRotation(x: number, y: number, z: number): TransformNode;
  15104. /**
  15105. * @hidden
  15106. */
  15107. protected _getEffectiveParent(): Nullable<Node>;
  15108. /**
  15109. * Computes the world matrix of the node
  15110. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15111. * @returns the world matrix
  15112. */
  15113. computeWorldMatrix(force?: boolean): Matrix;
  15114. /**
  15115. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15116. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15117. */
  15118. resetLocalMatrix(independentOfChildren?: boolean): void;
  15119. protected _afterComputeWorldMatrix(): void;
  15120. /**
  15121. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15122. * @param func callback function to add
  15123. *
  15124. * @returns the TransformNode.
  15125. */
  15126. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15127. /**
  15128. * Removes a registered callback function.
  15129. * @param func callback function to remove
  15130. * @returns the TransformNode.
  15131. */
  15132. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15133. /**
  15134. * Gets the position of the current mesh in camera space
  15135. * @param camera defines the camera to use
  15136. * @returns a position
  15137. */
  15138. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15139. /**
  15140. * Returns the distance from the mesh to the active camera
  15141. * @param camera defines the camera to use
  15142. * @returns the distance
  15143. */
  15144. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15145. /**
  15146. * Clone the current transform node
  15147. * @param name Name of the new clone
  15148. * @param newParent New parent for the clone
  15149. * @param doNotCloneChildren Do not clone children hierarchy
  15150. * @returns the new transform node
  15151. */
  15152. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15153. /**
  15154. * Serializes the objects information.
  15155. * @param currentSerializationObject defines the object to serialize in
  15156. * @returns the serialized object
  15157. */
  15158. serialize(currentSerializationObject?: any): any;
  15159. /**
  15160. * Returns a new TransformNode object parsed from the source provided.
  15161. * @param parsedTransformNode is the source.
  15162. * @param scene the scne the object belongs to
  15163. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15164. * @returns a new TransformNode object parsed from the source provided.
  15165. */
  15166. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15167. /**
  15168. * Get all child-transformNodes of this node
  15169. * @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
  15170. * @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
  15171. * @returns an array of TransformNode
  15172. */
  15173. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15174. /**
  15175. * Releases resources associated with this transform node.
  15176. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15177. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15178. */
  15179. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15180. /**
  15181. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15182. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15183. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15184. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15185. * @returns the current mesh
  15186. */
  15187. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15188. private _syncAbsoluteScalingAndRotation;
  15189. }
  15190. }
  15191. declare module BABYLON {
  15192. /**
  15193. * Class used to override all child animations of a given target
  15194. */
  15195. export class AnimationPropertiesOverride {
  15196. /**
  15197. * Gets or sets a value indicating if animation blending must be used
  15198. */
  15199. enableBlending: boolean;
  15200. /**
  15201. * Gets or sets the blending speed to use when enableBlending is true
  15202. */
  15203. blendingSpeed: number;
  15204. /**
  15205. * Gets or sets the default loop mode to use
  15206. */
  15207. loopMode: number;
  15208. }
  15209. }
  15210. declare module BABYLON {
  15211. /**
  15212. * Class used to store bone information
  15213. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15214. */
  15215. export class Bone extends Node {
  15216. /**
  15217. * defines the bone name
  15218. */
  15219. name: string;
  15220. private static _tmpVecs;
  15221. private static _tmpQuat;
  15222. private static _tmpMats;
  15223. /**
  15224. * Gets the list of child bones
  15225. */
  15226. children: Bone[];
  15227. /** Gets the animations associated with this bone */
  15228. animations: Animation[];
  15229. /**
  15230. * Gets or sets bone length
  15231. */
  15232. length: number;
  15233. /**
  15234. * @hidden Internal only
  15235. * Set this value to map this bone to a different index in the transform matrices
  15236. * Set this value to -1 to exclude the bone from the transform matrices
  15237. */
  15238. _index: Nullable<number>;
  15239. private _skeleton;
  15240. private _localMatrix;
  15241. private _restPose;
  15242. private _bindPose;
  15243. private _baseMatrix;
  15244. private _absoluteTransform;
  15245. private _invertedAbsoluteTransform;
  15246. private _parent;
  15247. private _scalingDeterminant;
  15248. private _worldTransform;
  15249. private _localScaling;
  15250. private _localRotation;
  15251. private _localPosition;
  15252. private _needToDecompose;
  15253. private _needToCompose;
  15254. /** @hidden */
  15255. _linkedTransformNode: Nullable<TransformNode>;
  15256. /** @hidden */
  15257. _waitingTransformNodeId: Nullable<string>;
  15258. /** @hidden */
  15259. get _matrix(): Matrix;
  15260. /** @hidden */
  15261. set _matrix(value: Matrix);
  15262. /**
  15263. * Create a new bone
  15264. * @param name defines the bone name
  15265. * @param skeleton defines the parent skeleton
  15266. * @param parentBone defines the parent (can be null if the bone is the root)
  15267. * @param localMatrix defines the local matrix
  15268. * @param restPose defines the rest pose matrix
  15269. * @param baseMatrix defines the base matrix
  15270. * @param index defines index of the bone in the hiearchy
  15271. */
  15272. constructor(
  15273. /**
  15274. * defines the bone name
  15275. */
  15276. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15277. /**
  15278. * Gets the current object class name.
  15279. * @return the class name
  15280. */
  15281. getClassName(): string;
  15282. /**
  15283. * Gets the parent skeleton
  15284. * @returns a skeleton
  15285. */
  15286. getSkeleton(): Skeleton;
  15287. /**
  15288. * Gets parent bone
  15289. * @returns a bone or null if the bone is the root of the bone hierarchy
  15290. */
  15291. getParent(): Nullable<Bone>;
  15292. /**
  15293. * Returns an array containing the root bones
  15294. * @returns an array containing the root bones
  15295. */
  15296. getChildren(): Array<Bone>;
  15297. /**
  15298. * Gets the node index in matrix array generated for rendering
  15299. * @returns the node index
  15300. */
  15301. getIndex(): number;
  15302. /**
  15303. * Sets the parent bone
  15304. * @param parent defines the parent (can be null if the bone is the root)
  15305. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15306. */
  15307. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15308. /**
  15309. * Gets the local matrix
  15310. * @returns a matrix
  15311. */
  15312. getLocalMatrix(): Matrix;
  15313. /**
  15314. * Gets the base matrix (initial matrix which remains unchanged)
  15315. * @returns a matrix
  15316. */
  15317. getBaseMatrix(): Matrix;
  15318. /**
  15319. * Gets the rest pose matrix
  15320. * @returns a matrix
  15321. */
  15322. getRestPose(): Matrix;
  15323. /**
  15324. * Sets the rest pose matrix
  15325. * @param matrix the local-space rest pose to set for this bone
  15326. */
  15327. setRestPose(matrix: Matrix): void;
  15328. /**
  15329. * Gets the bind pose matrix
  15330. * @returns the bind pose matrix
  15331. */
  15332. getBindPose(): Matrix;
  15333. /**
  15334. * Sets the bind pose matrix
  15335. * @param matrix the local-space bind pose to set for this bone
  15336. */
  15337. setBindPose(matrix: Matrix): void;
  15338. /**
  15339. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15340. */
  15341. getWorldMatrix(): Matrix;
  15342. /**
  15343. * Sets the local matrix to rest pose matrix
  15344. */
  15345. returnToRest(): void;
  15346. /**
  15347. * Gets the inverse of the absolute transform matrix.
  15348. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15349. * @returns a matrix
  15350. */
  15351. getInvertedAbsoluteTransform(): Matrix;
  15352. /**
  15353. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15354. * @returns a matrix
  15355. */
  15356. getAbsoluteTransform(): Matrix;
  15357. /**
  15358. * Links with the given transform node.
  15359. * The local matrix of this bone is copied from the transform node every frame.
  15360. * @param transformNode defines the transform node to link to
  15361. */
  15362. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15363. /**
  15364. * Gets the node used to drive the bone's transformation
  15365. * @returns a transform node or null
  15366. */
  15367. getTransformNode(): Nullable<TransformNode>;
  15368. /** Gets or sets current position (in local space) */
  15369. get position(): Vector3;
  15370. set position(newPosition: Vector3);
  15371. /** Gets or sets current rotation (in local space) */
  15372. get rotation(): Vector3;
  15373. set rotation(newRotation: Vector3);
  15374. /** Gets or sets current rotation quaternion (in local space) */
  15375. get rotationQuaternion(): Quaternion;
  15376. set rotationQuaternion(newRotation: Quaternion);
  15377. /** Gets or sets current scaling (in local space) */
  15378. get scaling(): Vector3;
  15379. set scaling(newScaling: Vector3);
  15380. /**
  15381. * Gets the animation properties override
  15382. */
  15383. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15384. private _decompose;
  15385. private _compose;
  15386. /**
  15387. * Update the base and local matrices
  15388. * @param matrix defines the new base or local matrix
  15389. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15390. * @param updateLocalMatrix defines if the local matrix should be updated
  15391. */
  15392. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15393. /** @hidden */
  15394. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15395. /**
  15396. * Flag the bone as dirty (Forcing it to update everything)
  15397. */
  15398. markAsDirty(): void;
  15399. /** @hidden */
  15400. _markAsDirtyAndCompose(): void;
  15401. private _markAsDirtyAndDecompose;
  15402. /**
  15403. * Translate the bone in local or world space
  15404. * @param vec The amount to translate the bone
  15405. * @param space The space that the translation is in
  15406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15407. */
  15408. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15409. /**
  15410. * Set the postion of the bone in local or world space
  15411. * @param position The position to set the bone
  15412. * @param space The space that the position is in
  15413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15414. */
  15415. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15416. /**
  15417. * Set the absolute position of the bone (world space)
  15418. * @param position The position to set the bone
  15419. * @param mesh The mesh that this bone is attached to
  15420. */
  15421. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15422. /**
  15423. * Scale the bone on the x, y and z axes (in local space)
  15424. * @param x The amount to scale the bone on the x axis
  15425. * @param y The amount to scale the bone on the y axis
  15426. * @param z The amount to scale the bone on the z axis
  15427. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15428. */
  15429. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15430. /**
  15431. * Set the bone scaling in local space
  15432. * @param scale defines the scaling vector
  15433. */
  15434. setScale(scale: Vector3): void;
  15435. /**
  15436. * Gets the current scaling in local space
  15437. * @returns the current scaling vector
  15438. */
  15439. getScale(): Vector3;
  15440. /**
  15441. * Gets the current scaling in local space and stores it in a target vector
  15442. * @param result defines the target vector
  15443. */
  15444. getScaleToRef(result: Vector3): void;
  15445. /**
  15446. * Set the yaw, pitch, and roll of the bone in local or world space
  15447. * @param yaw The rotation of the bone on the y axis
  15448. * @param pitch The rotation of the bone on the x axis
  15449. * @param roll The rotation of the bone on the z axis
  15450. * @param space The space that the axes of rotation are in
  15451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15452. */
  15453. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15454. /**
  15455. * Add a rotation to the bone on an axis in local or world space
  15456. * @param axis The axis to rotate the bone on
  15457. * @param amount The amount to rotate the bone
  15458. * @param space The space that the axis is in
  15459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15460. */
  15461. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15462. /**
  15463. * Set the rotation of the bone to a particular axis angle in local or world space
  15464. * @param axis The axis to rotate the bone on
  15465. * @param angle The angle that the bone should be rotated to
  15466. * @param space The space that the axis is in
  15467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15468. */
  15469. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15470. /**
  15471. * Set the euler rotation of the bone in local or world space
  15472. * @param rotation The euler rotation that the bone should be set to
  15473. * @param space The space that the rotation is in
  15474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15475. */
  15476. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15477. /**
  15478. * Set the quaternion rotation of the bone in local or world space
  15479. * @param quat The quaternion rotation that the bone should be set to
  15480. * @param space The space that the rotation is in
  15481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15482. */
  15483. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15484. /**
  15485. * Set the rotation matrix of the bone in local or world space
  15486. * @param rotMat The rotation matrix that the bone should be set to
  15487. * @param space The space that the rotation is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15491. private _rotateWithMatrix;
  15492. private _getNegativeRotationToRef;
  15493. /**
  15494. * Get the position of the bone in local or world space
  15495. * @param space The space that the returned position is in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. * @returns The position of the bone
  15498. */
  15499. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15500. /**
  15501. * Copy the position of the bone to a vector3 in local or world space
  15502. * @param space The space that the returned position is in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. * @param result The vector3 to copy the position to
  15505. */
  15506. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15507. /**
  15508. * Get the absolute position of the bone (world space)
  15509. * @param mesh The mesh that this bone is attached to
  15510. * @returns The absolute position of the bone
  15511. */
  15512. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15513. /**
  15514. * Copy the absolute position of the bone (world space) to the result param
  15515. * @param mesh The mesh that this bone is attached to
  15516. * @param result The vector3 to copy the absolute position to
  15517. */
  15518. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15519. /**
  15520. * Compute the absolute transforms of this bone and its children
  15521. */
  15522. computeAbsoluteTransforms(): void;
  15523. /**
  15524. * Get the world direction from an axis that is in the local space of the bone
  15525. * @param localAxis The local direction that is used to compute the world direction
  15526. * @param mesh The mesh that this bone is attached to
  15527. * @returns The world direction
  15528. */
  15529. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15530. /**
  15531. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15532. * @param localAxis The local direction that is used to compute the world direction
  15533. * @param mesh The mesh that this bone is attached to
  15534. * @param result The vector3 that the world direction will be copied to
  15535. */
  15536. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15537. /**
  15538. * Get the euler rotation of the bone in local or world space
  15539. * @param space The space that the rotation should be in
  15540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15541. * @returns The euler rotation
  15542. */
  15543. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15544. /**
  15545. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15546. * @param space The space that the rotation should be in
  15547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15548. * @param result The vector3 that the rotation should be copied to
  15549. */
  15550. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15551. /**
  15552. * Get the quaternion rotation of the bone in either local or world space
  15553. * @param space The space that the rotation should be in
  15554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15555. * @returns The quaternion rotation
  15556. */
  15557. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15558. /**
  15559. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15560. * @param space The space that the rotation should be in
  15561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15562. * @param result The quaternion that the rotation should be copied to
  15563. */
  15564. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15565. /**
  15566. * Get the rotation matrix of the bone in local or world space
  15567. * @param space The space that the rotation should be in
  15568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15569. * @returns The rotation matrix
  15570. */
  15571. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15572. /**
  15573. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15574. * @param space The space that the rotation should be in
  15575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15576. * @param result The quaternion that the rotation should be copied to
  15577. */
  15578. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15579. /**
  15580. * Get the world position of a point that is in the local space of the bone
  15581. * @param position The local position
  15582. * @param mesh The mesh that this bone is attached to
  15583. * @returns The world position
  15584. */
  15585. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15586. /**
  15587. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15588. * @param position The local position
  15589. * @param mesh The mesh that this bone is attached to
  15590. * @param result The vector3 that the world position should be copied to
  15591. */
  15592. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15593. /**
  15594. * Get the local position of a point that is in world space
  15595. * @param position The world position
  15596. * @param mesh The mesh that this bone is attached to
  15597. * @returns The local position
  15598. */
  15599. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15600. /**
  15601. * Get the local position of a point that is in world space and copy it to the result param
  15602. * @param position The world position
  15603. * @param mesh The mesh that this bone is attached to
  15604. * @param result The vector3 that the local position should be copied to
  15605. */
  15606. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15607. /**
  15608. * Set the current local matrix as the restPose for this bone.
  15609. */
  15610. setCurrentPoseAsRest(): void;
  15611. }
  15612. }
  15613. declare module BABYLON {
  15614. /**
  15615. * Defines a runtime animation
  15616. */
  15617. export class RuntimeAnimation {
  15618. private _events;
  15619. /**
  15620. * The current frame of the runtime animation
  15621. */
  15622. private _currentFrame;
  15623. /**
  15624. * The animation used by the runtime animation
  15625. */
  15626. private _animation;
  15627. /**
  15628. * The target of the runtime animation
  15629. */
  15630. private _target;
  15631. /**
  15632. * The initiating animatable
  15633. */
  15634. private _host;
  15635. /**
  15636. * The original value of the runtime animation
  15637. */
  15638. private _originalValue;
  15639. /**
  15640. * The original blend value of the runtime animation
  15641. */
  15642. private _originalBlendValue;
  15643. /**
  15644. * The offsets cache of the runtime animation
  15645. */
  15646. private _offsetsCache;
  15647. /**
  15648. * The high limits cache of the runtime animation
  15649. */
  15650. private _highLimitsCache;
  15651. /**
  15652. * Specifies if the runtime animation has been stopped
  15653. */
  15654. private _stopped;
  15655. /**
  15656. * The blending factor of the runtime animation
  15657. */
  15658. private _blendingFactor;
  15659. /**
  15660. * The BabylonJS scene
  15661. */
  15662. private _scene;
  15663. /**
  15664. * The current value of the runtime animation
  15665. */
  15666. private _currentValue;
  15667. /** @hidden */
  15668. _animationState: _IAnimationState;
  15669. /**
  15670. * The active target of the runtime animation
  15671. */
  15672. private _activeTargets;
  15673. private _currentActiveTarget;
  15674. private _directTarget;
  15675. /**
  15676. * The target path of the runtime animation
  15677. */
  15678. private _targetPath;
  15679. /**
  15680. * The weight of the runtime animation
  15681. */
  15682. private _weight;
  15683. /**
  15684. * The ratio offset of the runtime animation
  15685. */
  15686. private _ratioOffset;
  15687. /**
  15688. * The previous delay of the runtime animation
  15689. */
  15690. private _previousDelay;
  15691. /**
  15692. * The previous ratio of the runtime animation
  15693. */
  15694. private _previousRatio;
  15695. private _enableBlending;
  15696. private _keys;
  15697. private _minFrame;
  15698. private _maxFrame;
  15699. private _minValue;
  15700. private _maxValue;
  15701. private _targetIsArray;
  15702. /**
  15703. * Gets the current frame of the runtime animation
  15704. */
  15705. get currentFrame(): number;
  15706. /**
  15707. * Gets the weight of the runtime animation
  15708. */
  15709. get weight(): number;
  15710. /**
  15711. * Gets the current value of the runtime animation
  15712. */
  15713. get currentValue(): any;
  15714. /**
  15715. * Gets the target path of the runtime animation
  15716. */
  15717. get targetPath(): string;
  15718. /**
  15719. * Gets the actual target of the runtime animation
  15720. */
  15721. get target(): any;
  15722. /**
  15723. * Gets the additive state of the runtime animation
  15724. */
  15725. get isAdditive(): boolean;
  15726. /** @hidden */
  15727. _onLoop: () => void;
  15728. /**
  15729. * Create a new RuntimeAnimation object
  15730. * @param target defines the target of the animation
  15731. * @param animation defines the source animation object
  15732. * @param scene defines the hosting scene
  15733. * @param host defines the initiating Animatable
  15734. */
  15735. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15736. private _preparePath;
  15737. /**
  15738. * Gets the animation from the runtime animation
  15739. */
  15740. get animation(): Animation;
  15741. /**
  15742. * Resets the runtime animation to the beginning
  15743. * @param restoreOriginal defines whether to restore the target property to the original value
  15744. */
  15745. reset(restoreOriginal?: boolean): void;
  15746. /**
  15747. * Specifies if the runtime animation is stopped
  15748. * @returns Boolean specifying if the runtime animation is stopped
  15749. */
  15750. isStopped(): boolean;
  15751. /**
  15752. * Disposes of the runtime animation
  15753. */
  15754. dispose(): void;
  15755. /**
  15756. * Apply the interpolated value to the target
  15757. * @param currentValue defines the value computed by the animation
  15758. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15759. */
  15760. setValue(currentValue: any, weight: number): void;
  15761. private _getOriginalValues;
  15762. private _setValue;
  15763. /**
  15764. * Gets the loop pmode of the runtime animation
  15765. * @returns Loop Mode
  15766. */
  15767. private _getCorrectLoopMode;
  15768. /**
  15769. * Move the current animation to a given frame
  15770. * @param frame defines the frame to move to
  15771. */
  15772. goToFrame(frame: number): void;
  15773. /**
  15774. * @hidden Internal use only
  15775. */
  15776. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15777. /**
  15778. * Execute the current animation
  15779. * @param delay defines the delay to add to the current frame
  15780. * @param from defines the lower bound of the animation range
  15781. * @param to defines the upper bound of the animation range
  15782. * @param loop defines if the current animation must loop
  15783. * @param speedRatio defines the current speed ratio
  15784. * @param weight defines the weight of the animation (default is -1 so no weight)
  15785. * @param onLoop optional callback called when animation loops
  15786. * @returns a boolean indicating if the animation is running
  15787. */
  15788. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15789. }
  15790. }
  15791. declare module BABYLON {
  15792. /**
  15793. * Class used to store an actual running animation
  15794. */
  15795. export class Animatable {
  15796. /** defines the target object */
  15797. target: any;
  15798. /** defines the starting frame number (default is 0) */
  15799. fromFrame: number;
  15800. /** defines the ending frame number (default is 100) */
  15801. toFrame: number;
  15802. /** defines if the animation must loop (default is false) */
  15803. loopAnimation: boolean;
  15804. /** defines a callback to call when animation ends if it is not looping */
  15805. onAnimationEnd?: (() => void) | null | undefined;
  15806. /** defines a callback to call when animation loops */
  15807. onAnimationLoop?: (() => void) | null | undefined;
  15808. /** defines whether the animation should be evaluated additively */
  15809. isAdditive: boolean;
  15810. private _localDelayOffset;
  15811. private _pausedDelay;
  15812. private _runtimeAnimations;
  15813. private _paused;
  15814. private _scene;
  15815. private _speedRatio;
  15816. private _weight;
  15817. private _syncRoot;
  15818. /**
  15819. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15820. * This will only apply for non looping animation (default is true)
  15821. */
  15822. disposeOnEnd: boolean;
  15823. /**
  15824. * Gets a boolean indicating if the animation has started
  15825. */
  15826. animationStarted: boolean;
  15827. /**
  15828. * Observer raised when the animation ends
  15829. */
  15830. onAnimationEndObservable: Observable<Animatable>;
  15831. /**
  15832. * Observer raised when the animation loops
  15833. */
  15834. onAnimationLoopObservable: Observable<Animatable>;
  15835. /**
  15836. * Gets the root Animatable used to synchronize and normalize animations
  15837. */
  15838. get syncRoot(): Nullable<Animatable>;
  15839. /**
  15840. * Gets the current frame of the first RuntimeAnimation
  15841. * Used to synchronize Animatables
  15842. */
  15843. get masterFrame(): number;
  15844. /**
  15845. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15846. */
  15847. get weight(): number;
  15848. set weight(value: number);
  15849. /**
  15850. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15851. */
  15852. get speedRatio(): number;
  15853. set speedRatio(value: number);
  15854. /**
  15855. * Creates a new Animatable
  15856. * @param scene defines the hosting scene
  15857. * @param target defines the target object
  15858. * @param fromFrame defines the starting frame number (default is 0)
  15859. * @param toFrame defines the ending frame number (default is 100)
  15860. * @param loopAnimation defines if the animation must loop (default is false)
  15861. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15862. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15863. * @param animations defines a group of animation to add to the new Animatable
  15864. * @param onAnimationLoop defines a callback to call when animation loops
  15865. * @param isAdditive defines whether the animation should be evaluated additively
  15866. */
  15867. constructor(scene: Scene,
  15868. /** defines the target object */
  15869. target: any,
  15870. /** defines the starting frame number (default is 0) */
  15871. fromFrame?: number,
  15872. /** defines the ending frame number (default is 100) */
  15873. toFrame?: number,
  15874. /** defines if the animation must loop (default is false) */
  15875. loopAnimation?: boolean, speedRatio?: number,
  15876. /** defines a callback to call when animation ends if it is not looping */
  15877. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15878. /** defines a callback to call when animation loops */
  15879. onAnimationLoop?: (() => void) | null | undefined,
  15880. /** defines whether the animation should be evaluated additively */
  15881. isAdditive?: boolean);
  15882. /**
  15883. * Synchronize and normalize current Animatable with a source Animatable
  15884. * This is useful when using animation weights and when animations are not of the same length
  15885. * @param root defines the root Animatable to synchronize with
  15886. * @returns the current Animatable
  15887. */
  15888. syncWith(root: Animatable): Animatable;
  15889. /**
  15890. * Gets the list of runtime animations
  15891. * @returns an array of RuntimeAnimation
  15892. */
  15893. getAnimations(): RuntimeAnimation[];
  15894. /**
  15895. * Adds more animations to the current animatable
  15896. * @param target defines the target of the animations
  15897. * @param animations defines the new animations to add
  15898. */
  15899. appendAnimations(target: any, animations: Animation[]): void;
  15900. /**
  15901. * Gets the source animation for a specific property
  15902. * @param property defines the propertyu to look for
  15903. * @returns null or the source animation for the given property
  15904. */
  15905. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15906. /**
  15907. * Gets the runtime animation for a specific property
  15908. * @param property defines the propertyu to look for
  15909. * @returns null or the runtime animation for the given property
  15910. */
  15911. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15912. /**
  15913. * Resets the animatable to its original state
  15914. */
  15915. reset(): void;
  15916. /**
  15917. * Allows the animatable to blend with current running animations
  15918. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15919. * @param blendingSpeed defines the blending speed to use
  15920. */
  15921. enableBlending(blendingSpeed: number): void;
  15922. /**
  15923. * Disable animation blending
  15924. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15925. */
  15926. disableBlending(): void;
  15927. /**
  15928. * Jump directly to a given frame
  15929. * @param frame defines the frame to jump to
  15930. */
  15931. goToFrame(frame: number): void;
  15932. /**
  15933. * Pause the animation
  15934. */
  15935. pause(): void;
  15936. /**
  15937. * Restart the animation
  15938. */
  15939. restart(): void;
  15940. private _raiseOnAnimationEnd;
  15941. /**
  15942. * Stop and delete the current animation
  15943. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15944. * @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)
  15945. */
  15946. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15947. /**
  15948. * Wait asynchronously for the animation to end
  15949. * @returns a promise which will be fullfilled when the animation ends
  15950. */
  15951. waitAsync(): Promise<Animatable>;
  15952. /** @hidden */
  15953. _animate(delay: number): boolean;
  15954. }
  15955. interface Scene {
  15956. /** @hidden */
  15957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15958. /** @hidden */
  15959. _processLateAnimationBindingsForMatrices(holder: {
  15960. totalWeight: number;
  15961. totalAdditiveWeight: number;
  15962. animations: RuntimeAnimation[];
  15963. additiveAnimations: RuntimeAnimation[];
  15964. originalValue: Matrix;
  15965. }): any;
  15966. /** @hidden */
  15967. _processLateAnimationBindingsForQuaternions(holder: {
  15968. totalWeight: number;
  15969. totalAdditiveWeight: number;
  15970. animations: RuntimeAnimation[];
  15971. additiveAnimations: RuntimeAnimation[];
  15972. originalValue: Quaternion;
  15973. }, refQuaternion: Quaternion): Quaternion;
  15974. /** @hidden */
  15975. _processLateAnimationBindings(): void;
  15976. /**
  15977. * Will start the animation sequence of a given target
  15978. * @param target defines the target
  15979. * @param from defines from which frame should animation start
  15980. * @param to defines until which frame should animation run.
  15981. * @param weight defines the weight to apply to the animation (1.0 by default)
  15982. * @param loop defines if the animation loops
  15983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15984. * @param onAnimationEnd defines the function to be executed when the animation ends
  15985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15986. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15987. * @param onAnimationLoop defines the callback to call when an animation loops
  15988. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15989. * @returns the animatable object created for this animation
  15990. */
  15991. 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;
  15992. /**
  15993. * Will start the animation sequence of a given target
  15994. * @param target defines the target
  15995. * @param from defines from which frame should animation start
  15996. * @param to defines until which frame should animation run.
  15997. * @param loop defines if the animation loops
  15998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15999. * @param onAnimationEnd defines the function to be executed when the animation ends
  16000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16001. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16002. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16003. * @param onAnimationLoop defines the callback to call when an animation loops
  16004. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16005. * @returns the animatable object created for this animation
  16006. */
  16007. 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;
  16008. /**
  16009. * Will start the animation sequence of a given target and its hierarchy
  16010. * @param target defines the target
  16011. * @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.
  16012. * @param from defines from which frame should animation start
  16013. * @param to defines until which frame should animation run.
  16014. * @param loop defines if the animation loops
  16015. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16016. * @param onAnimationEnd defines the function to be executed when the animation ends
  16017. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16018. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16019. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16020. * @param onAnimationLoop defines the callback to call when an animation loops
  16021. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16022. * @returns the list of created animatables
  16023. */
  16024. 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[];
  16025. /**
  16026. * Begin a new animation on a given node
  16027. * @param target defines the target where the animation will take place
  16028. * @param animations defines the list of animations to start
  16029. * @param from defines the initial value
  16030. * @param to defines the final value
  16031. * @param loop defines if you want animation to loop (off by default)
  16032. * @param speedRatio defines the speed ratio to apply to all animations
  16033. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16034. * @param onAnimationLoop defines the callback to call when an animation loops
  16035. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16036. * @returns the list of created animatables
  16037. */
  16038. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16039. /**
  16040. * Begin a new animation on a given node and its hierarchy
  16041. * @param target defines the root node where the animation will take place
  16042. * @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.
  16043. * @param animations defines the list of animations to start
  16044. * @param from defines the initial value
  16045. * @param to defines the final value
  16046. * @param loop defines if you want animation to loop (off by default)
  16047. * @param speedRatio defines the speed ratio to apply to all animations
  16048. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16049. * @param onAnimationLoop defines the callback to call when an animation loops
  16050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16051. * @returns the list of animatables created for all nodes
  16052. */
  16053. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16054. /**
  16055. * Gets the animatable associated with a specific target
  16056. * @param target defines the target of the animatable
  16057. * @returns the required animatable if found
  16058. */
  16059. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16060. /**
  16061. * Gets all animatables associated with a given target
  16062. * @param target defines the target to look animatables for
  16063. * @returns an array of Animatables
  16064. */
  16065. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16066. /**
  16067. * Stops and removes all animations that have been applied to the scene
  16068. */
  16069. stopAllAnimations(): void;
  16070. /**
  16071. * Gets the current delta time used by animation engine
  16072. */
  16073. deltaTime: number;
  16074. }
  16075. interface Bone {
  16076. /**
  16077. * Copy an animation range from another bone
  16078. * @param source defines the source bone
  16079. * @param rangeName defines the range name to copy
  16080. * @param frameOffset defines the frame offset
  16081. * @param rescaleAsRequired defines if rescaling must be applied if required
  16082. * @param skelDimensionsRatio defines the scaling ratio
  16083. * @returns true if operation was successful
  16084. */
  16085. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16086. }
  16087. }
  16088. declare module BABYLON {
  16089. /**
  16090. * Class used to handle skinning animations
  16091. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16092. */
  16093. export class Skeleton implements IAnimatable {
  16094. /** defines the skeleton name */
  16095. name: string;
  16096. /** defines the skeleton Id */
  16097. id: string;
  16098. /**
  16099. * Defines the list of child bones
  16100. */
  16101. bones: Bone[];
  16102. /**
  16103. * Defines an estimate of the dimension of the skeleton at rest
  16104. */
  16105. dimensionsAtRest: Vector3;
  16106. /**
  16107. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16108. */
  16109. needInitialSkinMatrix: boolean;
  16110. /**
  16111. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16112. */
  16113. overrideMesh: Nullable<AbstractMesh>;
  16114. /**
  16115. * Gets the list of animations attached to this skeleton
  16116. */
  16117. animations: Array<Animation>;
  16118. private _scene;
  16119. private _isDirty;
  16120. private _transformMatrices;
  16121. private _transformMatrixTexture;
  16122. private _meshesWithPoseMatrix;
  16123. private _animatables;
  16124. private _identity;
  16125. private _synchronizedWithMesh;
  16126. private _ranges;
  16127. private _lastAbsoluteTransformsUpdateId;
  16128. private _canUseTextureForBones;
  16129. private _uniqueId;
  16130. /** @hidden */
  16131. _numBonesWithLinkedTransformNode: number;
  16132. /** @hidden */
  16133. _hasWaitingData: Nullable<boolean>;
  16134. /** @hidden */
  16135. _waitingOverrideMeshId: Nullable<string>;
  16136. /**
  16137. * Specifies if the skeleton should be serialized
  16138. */
  16139. doNotSerialize: boolean;
  16140. private _useTextureToStoreBoneMatrices;
  16141. /**
  16142. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16143. * Please note that this option is not available if the hardware does not support it
  16144. */
  16145. get useTextureToStoreBoneMatrices(): boolean;
  16146. set useTextureToStoreBoneMatrices(value: boolean);
  16147. private _animationPropertiesOverride;
  16148. /**
  16149. * Gets or sets the animation properties override
  16150. */
  16151. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16152. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16153. /**
  16154. * List of inspectable custom properties (used by the Inspector)
  16155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16156. */
  16157. inspectableCustomProperties: IInspectable[];
  16158. /**
  16159. * An observable triggered before computing the skeleton's matrices
  16160. */
  16161. onBeforeComputeObservable: Observable<Skeleton>;
  16162. /**
  16163. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16164. */
  16165. get isUsingTextureForMatrices(): boolean;
  16166. /**
  16167. * Gets the unique ID of this skeleton
  16168. */
  16169. get uniqueId(): number;
  16170. /**
  16171. * Creates a new skeleton
  16172. * @param name defines the skeleton name
  16173. * @param id defines the skeleton Id
  16174. * @param scene defines the hosting scene
  16175. */
  16176. constructor(
  16177. /** defines the skeleton name */
  16178. name: string,
  16179. /** defines the skeleton Id */
  16180. id: string, scene: Scene);
  16181. /**
  16182. * Gets the current object class name.
  16183. * @return the class name
  16184. */
  16185. getClassName(): string;
  16186. /**
  16187. * Returns an array containing the root bones
  16188. * @returns an array containing the root bones
  16189. */
  16190. getChildren(): Array<Bone>;
  16191. /**
  16192. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16193. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16194. * @returns a Float32Array containing matrices data
  16195. */
  16196. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16197. /**
  16198. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16199. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16200. * @returns a raw texture containing the data
  16201. */
  16202. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16203. /**
  16204. * Gets the current hosting scene
  16205. * @returns a scene object
  16206. */
  16207. getScene(): Scene;
  16208. /**
  16209. * Gets a string representing the current skeleton data
  16210. * @param fullDetails defines a boolean indicating if we want a verbose version
  16211. * @returns a string representing the current skeleton data
  16212. */
  16213. toString(fullDetails?: boolean): string;
  16214. /**
  16215. * Get bone's index searching by name
  16216. * @param name defines bone's name to search for
  16217. * @return the indice of the bone. Returns -1 if not found
  16218. */
  16219. getBoneIndexByName(name: string): number;
  16220. /**
  16221. * Creater a new animation range
  16222. * @param name defines the name of the range
  16223. * @param from defines the start key
  16224. * @param to defines the end key
  16225. */
  16226. createAnimationRange(name: string, from: number, to: number): void;
  16227. /**
  16228. * Delete a specific animation range
  16229. * @param name defines the name of the range
  16230. * @param deleteFrames defines if frames must be removed as well
  16231. */
  16232. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16233. /**
  16234. * Gets a specific animation range
  16235. * @param name defines the name of the range to look for
  16236. * @returns the requested animation range or null if not found
  16237. */
  16238. getAnimationRange(name: string): Nullable<AnimationRange>;
  16239. /**
  16240. * Gets the list of all animation ranges defined on this skeleton
  16241. * @returns an array
  16242. */
  16243. getAnimationRanges(): Nullable<AnimationRange>[];
  16244. /**
  16245. * Copy animation range from a source skeleton.
  16246. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16247. * @param source defines the source skeleton
  16248. * @param name defines the name of the range to copy
  16249. * @param rescaleAsRequired defines if rescaling must be applied if required
  16250. * @returns true if operation was successful
  16251. */
  16252. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16253. /**
  16254. * Forces the skeleton to go to rest pose
  16255. */
  16256. returnToRest(): void;
  16257. private _getHighestAnimationFrame;
  16258. /**
  16259. * Begin a specific animation range
  16260. * @param name defines the name of the range to start
  16261. * @param loop defines if looping must be turned on (false by default)
  16262. * @param speedRatio defines the speed ratio to apply (1 by default)
  16263. * @param onAnimationEnd defines a callback which will be called when animation will end
  16264. * @returns a new animatable
  16265. */
  16266. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16267. /**
  16268. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16269. * @param skeleton defines the Skeleton containing the animation range to convert
  16270. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16271. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16272. * @returns the original skeleton
  16273. */
  16274. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16275. /** @hidden */
  16276. _markAsDirty(): void;
  16277. /** @hidden */
  16278. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16279. /** @hidden */
  16280. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16281. private _computeTransformMatrices;
  16282. /**
  16283. * Build all resources required to render a skeleton
  16284. */
  16285. prepare(): void;
  16286. /**
  16287. * Gets the list of animatables currently running for this skeleton
  16288. * @returns an array of animatables
  16289. */
  16290. getAnimatables(): IAnimatable[];
  16291. /**
  16292. * Clone the current skeleton
  16293. * @param name defines the name of the new skeleton
  16294. * @param id defines the id of the new skeleton
  16295. * @returns the new skeleton
  16296. */
  16297. clone(name: string, id?: string): Skeleton;
  16298. /**
  16299. * Enable animation blending for this skeleton
  16300. * @param blendingSpeed defines the blending speed to apply
  16301. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16302. */
  16303. enableBlending(blendingSpeed?: number): void;
  16304. /**
  16305. * Releases all resources associated with the current skeleton
  16306. */
  16307. dispose(): void;
  16308. /**
  16309. * Serialize the skeleton in a JSON object
  16310. * @returns a JSON object
  16311. */
  16312. serialize(): any;
  16313. /**
  16314. * Creates a new skeleton from serialized data
  16315. * @param parsedSkeleton defines the serialized data
  16316. * @param scene defines the hosting scene
  16317. * @returns a new skeleton
  16318. */
  16319. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16320. /**
  16321. * Compute all node absolute transforms
  16322. * @param forceUpdate defines if computation must be done even if cache is up to date
  16323. */
  16324. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16325. /**
  16326. * Gets the root pose matrix
  16327. * @returns a matrix
  16328. */
  16329. getPoseMatrix(): Nullable<Matrix>;
  16330. /**
  16331. * Sorts bones per internal index
  16332. */
  16333. sortBones(): void;
  16334. private _sortBones;
  16335. /**
  16336. * Set the current local matrix as the restPose for all bones in the skeleton.
  16337. */
  16338. setCurrentPoseAsRest(): void;
  16339. }
  16340. }
  16341. declare module BABYLON {
  16342. /**
  16343. * Creates an instance based on a source mesh.
  16344. */
  16345. export class InstancedMesh extends AbstractMesh {
  16346. private _sourceMesh;
  16347. private _currentLOD;
  16348. /** @hidden */
  16349. _indexInSourceMeshInstanceArray: number;
  16350. constructor(name: string, source: Mesh);
  16351. /**
  16352. * Returns the string "InstancedMesh".
  16353. */
  16354. getClassName(): string;
  16355. /** Gets the list of lights affecting that mesh */
  16356. get lightSources(): Light[];
  16357. _resyncLightSources(): void;
  16358. _resyncLightSource(light: Light): void;
  16359. _removeLightSource(light: Light, dispose: boolean): void;
  16360. /**
  16361. * If the source mesh receives shadows
  16362. */
  16363. get receiveShadows(): boolean;
  16364. /**
  16365. * The material of the source mesh
  16366. */
  16367. get material(): Nullable<Material>;
  16368. /**
  16369. * Visibility of the source mesh
  16370. */
  16371. get visibility(): number;
  16372. /**
  16373. * Skeleton of the source mesh
  16374. */
  16375. get skeleton(): Nullable<Skeleton>;
  16376. /**
  16377. * Rendering ground id of the source mesh
  16378. */
  16379. get renderingGroupId(): number;
  16380. set renderingGroupId(value: number);
  16381. /**
  16382. * Returns the total number of vertices (integer).
  16383. */
  16384. getTotalVertices(): number;
  16385. /**
  16386. * Returns a positive integer : the total number of indices in this mesh geometry.
  16387. * @returns the numner of indices or zero if the mesh has no geometry.
  16388. */
  16389. getTotalIndices(): number;
  16390. /**
  16391. * The source mesh of the instance
  16392. */
  16393. get sourceMesh(): Mesh;
  16394. /**
  16395. * Creates a new InstancedMesh object from the mesh model.
  16396. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16397. * @param name defines the name of the new instance
  16398. * @returns a new InstancedMesh
  16399. */
  16400. createInstance(name: string): InstancedMesh;
  16401. /**
  16402. * Is this node ready to be used/rendered
  16403. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16404. * @return {boolean} is it ready
  16405. */
  16406. isReady(completeCheck?: boolean): boolean;
  16407. /**
  16408. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16409. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16410. * @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.
  16411. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16412. */
  16413. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16414. /**
  16415. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16416. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16417. * The `data` are either a numeric array either a Float32Array.
  16418. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16419. * 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).
  16420. * Note that a new underlying VertexBuffer object is created each call.
  16421. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16422. *
  16423. * Possible `kind` values :
  16424. * - VertexBuffer.PositionKind
  16425. * - VertexBuffer.UVKind
  16426. * - VertexBuffer.UV2Kind
  16427. * - VertexBuffer.UV3Kind
  16428. * - VertexBuffer.UV4Kind
  16429. * - VertexBuffer.UV5Kind
  16430. * - VertexBuffer.UV6Kind
  16431. * - VertexBuffer.ColorKind
  16432. * - VertexBuffer.MatricesIndicesKind
  16433. * - VertexBuffer.MatricesIndicesExtraKind
  16434. * - VertexBuffer.MatricesWeightsKind
  16435. * - VertexBuffer.MatricesWeightsExtraKind
  16436. *
  16437. * Returns the Mesh.
  16438. */
  16439. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16440. /**
  16441. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16442. * If the mesh has no geometry, it is simply returned as it is.
  16443. * The `data` are either a numeric array either a Float32Array.
  16444. * No new underlying VertexBuffer object is created.
  16445. * 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.
  16446. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16447. *
  16448. * Possible `kind` values :
  16449. * - VertexBuffer.PositionKind
  16450. * - VertexBuffer.UVKind
  16451. * - VertexBuffer.UV2Kind
  16452. * - VertexBuffer.UV3Kind
  16453. * - VertexBuffer.UV4Kind
  16454. * - VertexBuffer.UV5Kind
  16455. * - VertexBuffer.UV6Kind
  16456. * - VertexBuffer.ColorKind
  16457. * - VertexBuffer.MatricesIndicesKind
  16458. * - VertexBuffer.MatricesIndicesExtraKind
  16459. * - VertexBuffer.MatricesWeightsKind
  16460. * - VertexBuffer.MatricesWeightsExtraKind
  16461. *
  16462. * Returns the Mesh.
  16463. */
  16464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16465. /**
  16466. * Sets the mesh indices.
  16467. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16468. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16469. * This method creates a new index buffer each call.
  16470. * Returns the Mesh.
  16471. */
  16472. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16473. /**
  16474. * Boolean : True if the mesh owns the requested kind of data.
  16475. */
  16476. isVerticesDataPresent(kind: string): boolean;
  16477. /**
  16478. * Returns an array of indices (IndicesArray).
  16479. */
  16480. getIndices(): Nullable<IndicesArray>;
  16481. get _positions(): Nullable<Vector3[]>;
  16482. /**
  16483. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16484. * This means the mesh underlying bounding box and sphere are recomputed.
  16485. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16486. * @returns the current mesh
  16487. */
  16488. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16489. /** @hidden */
  16490. _preActivate(): InstancedMesh;
  16491. /** @hidden */
  16492. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16493. /** @hidden */
  16494. _postActivate(): void;
  16495. getWorldMatrix(): Matrix;
  16496. get isAnInstance(): boolean;
  16497. /**
  16498. * Returns the current associated LOD AbstractMesh.
  16499. */
  16500. getLOD(camera: Camera): AbstractMesh;
  16501. /** @hidden */
  16502. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16503. /** @hidden */
  16504. _syncSubMeshes(): InstancedMesh;
  16505. /** @hidden */
  16506. _generatePointsArray(): boolean;
  16507. /** @hidden */
  16508. _updateBoundingInfo(): AbstractMesh;
  16509. /**
  16510. * Creates a new InstancedMesh from the current mesh.
  16511. * - name (string) : the cloned mesh name
  16512. * - newParent (optional Node) : the optional Node to parent the clone to.
  16513. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16514. *
  16515. * Returns the clone.
  16516. */
  16517. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16518. /**
  16519. * Disposes the InstancedMesh.
  16520. * Returns nothing.
  16521. */
  16522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16523. }
  16524. interface Mesh {
  16525. /**
  16526. * Register a custom buffer that will be instanced
  16527. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16528. * @param kind defines the buffer kind
  16529. * @param stride defines the stride in floats
  16530. */
  16531. registerInstancedBuffer(kind: string, stride: number): void;
  16532. /**
  16533. * true to use the edge renderer for all instances of this mesh
  16534. */
  16535. edgesShareWithInstances: boolean;
  16536. /** @hidden */
  16537. _userInstancedBuffersStorage: {
  16538. data: {
  16539. [key: string]: Float32Array;
  16540. };
  16541. sizes: {
  16542. [key: string]: number;
  16543. };
  16544. vertexBuffers: {
  16545. [key: string]: Nullable<VertexBuffer>;
  16546. };
  16547. strides: {
  16548. [key: string]: number;
  16549. };
  16550. };
  16551. }
  16552. interface AbstractMesh {
  16553. /**
  16554. * Object used to store instanced buffers defined by user
  16555. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16556. */
  16557. instancedBuffers: {
  16558. [key: string]: any;
  16559. };
  16560. }
  16561. }
  16562. declare module BABYLON {
  16563. /**
  16564. * Defines the options associated with the creation of a shader material.
  16565. */
  16566. export interface IShaderMaterialOptions {
  16567. /**
  16568. * Does the material work in alpha blend mode
  16569. */
  16570. needAlphaBlending: boolean;
  16571. /**
  16572. * Does the material work in alpha test mode
  16573. */
  16574. needAlphaTesting: boolean;
  16575. /**
  16576. * The list of attribute names used in the shader
  16577. */
  16578. attributes: string[];
  16579. /**
  16580. * The list of unifrom names used in the shader
  16581. */
  16582. uniforms: string[];
  16583. /**
  16584. * The list of UBO names used in the shader
  16585. */
  16586. uniformBuffers: string[];
  16587. /**
  16588. * The list of sampler names used in the shader
  16589. */
  16590. samplers: string[];
  16591. /**
  16592. * The list of defines used in the shader
  16593. */
  16594. defines: string[];
  16595. }
  16596. /**
  16597. * 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.
  16598. *
  16599. * This returned material effects how the mesh will look based on the code in the shaders.
  16600. *
  16601. * @see https://doc.babylonjs.com/how_to/shader_material
  16602. */
  16603. export class ShaderMaterial extends Material {
  16604. private _shaderPath;
  16605. private _options;
  16606. private _textures;
  16607. private _textureArrays;
  16608. private _floats;
  16609. private _ints;
  16610. private _floatsArrays;
  16611. private _colors3;
  16612. private _colors3Arrays;
  16613. private _colors4;
  16614. private _colors4Arrays;
  16615. private _vectors2;
  16616. private _vectors3;
  16617. private _vectors4;
  16618. private _matrices;
  16619. private _matrixArrays;
  16620. private _matrices3x3;
  16621. private _matrices2x2;
  16622. private _vectors2Arrays;
  16623. private _vectors3Arrays;
  16624. private _vectors4Arrays;
  16625. private _cachedWorldViewMatrix;
  16626. private _cachedWorldViewProjectionMatrix;
  16627. private _renderId;
  16628. private _multiview;
  16629. private _cachedDefines;
  16630. /** Define the Url to load snippets */
  16631. static SnippetUrl: string;
  16632. /** Snippet ID if the material was created from the snippet server */
  16633. snippetId: string;
  16634. /**
  16635. * Instantiate a new shader material.
  16636. * 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.
  16637. * This returned material effects how the mesh will look based on the code in the shaders.
  16638. * @see https://doc.babylonjs.com/how_to/shader_material
  16639. * @param name Define the name of the material in the scene
  16640. * @param scene Define the scene the material belongs to
  16641. * @param shaderPath Defines the route to the shader code in one of three ways:
  16642. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16643. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16644. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16645. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16646. * @param options Define the options used to create the shader
  16647. */
  16648. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16649. /**
  16650. * Gets the shader path used to define the shader code
  16651. * It can be modified to trigger a new compilation
  16652. */
  16653. get shaderPath(): any;
  16654. /**
  16655. * Sets the shader path used to define the shader code
  16656. * It can be modified to trigger a new compilation
  16657. */
  16658. set shaderPath(shaderPath: any);
  16659. /**
  16660. * Gets the options used to compile the shader.
  16661. * They can be modified to trigger a new compilation
  16662. */
  16663. get options(): IShaderMaterialOptions;
  16664. /**
  16665. * Gets the current class name of the material e.g. "ShaderMaterial"
  16666. * Mainly use in serialization.
  16667. * @returns the class name
  16668. */
  16669. getClassName(): string;
  16670. /**
  16671. * Specifies if the material will require alpha blending
  16672. * @returns a boolean specifying if alpha blending is needed
  16673. */
  16674. needAlphaBlending(): boolean;
  16675. /**
  16676. * Specifies if this material should be rendered in alpha test mode
  16677. * @returns a boolean specifying if an alpha test is needed.
  16678. */
  16679. needAlphaTesting(): boolean;
  16680. private _checkUniform;
  16681. /**
  16682. * Set a texture in the shader.
  16683. * @param name Define the name of the uniform samplers as defined in the shader
  16684. * @param texture Define the texture to bind to this sampler
  16685. * @return the material itself allowing "fluent" like uniform updates
  16686. */
  16687. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16688. /**
  16689. * Set a texture array in the shader.
  16690. * @param name Define the name of the uniform sampler array as defined in the shader
  16691. * @param textures Define the list of textures to bind to this sampler
  16692. * @return the material itself allowing "fluent" like uniform updates
  16693. */
  16694. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16695. /**
  16696. * Set a float in the shader.
  16697. * @param name Define the name of the uniform as defined in the shader
  16698. * @param value Define the value to give to the uniform
  16699. * @return the material itself allowing "fluent" like uniform updates
  16700. */
  16701. setFloat(name: string, value: number): ShaderMaterial;
  16702. /**
  16703. * Set a int in the shader.
  16704. * @param name Define the name of the uniform as defined in the shader
  16705. * @param value Define the value to give to the uniform
  16706. * @return the material itself allowing "fluent" like uniform updates
  16707. */
  16708. setInt(name: string, value: number): ShaderMaterial;
  16709. /**
  16710. * Set an array of floats in the shader.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the material itself allowing "fluent" like uniform updates
  16714. */
  16715. setFloats(name: string, value: number[]): ShaderMaterial;
  16716. /**
  16717. * Set a vec3 in the shader from a Color3.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the material itself allowing "fluent" like uniform updates
  16721. */
  16722. setColor3(name: string, value: Color3): ShaderMaterial;
  16723. /**
  16724. * Set a vec3 array in the shader from a Color3 array.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the material itself allowing "fluent" like uniform updates
  16728. */
  16729. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16730. /**
  16731. * Set a vec4 in the shader from a Color4.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the material itself allowing "fluent" like uniform updates
  16735. */
  16736. setColor4(name: string, value: Color4): ShaderMaterial;
  16737. /**
  16738. * Set a vec4 array in the shader from a Color4 array.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the material itself allowing "fluent" like uniform updates
  16742. */
  16743. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16744. /**
  16745. * Set a vec2 in the shader from a Vector2.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the material itself allowing "fluent" like uniform updates
  16749. */
  16750. setVector2(name: string, value: Vector2): ShaderMaterial;
  16751. /**
  16752. * Set a vec3 in the shader from a Vector3.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the material itself allowing "fluent" like uniform updates
  16756. */
  16757. setVector3(name: string, value: Vector3): ShaderMaterial;
  16758. /**
  16759. * Set a vec4 in the shader from a Vector4.
  16760. * @param name Define the name of the uniform as defined in the shader
  16761. * @param value Define the value to give to the uniform
  16762. * @return the material itself allowing "fluent" like uniform updates
  16763. */
  16764. setVector4(name: string, value: Vector4): ShaderMaterial;
  16765. /**
  16766. * Set a mat4 in the shader from a Matrix.
  16767. * @param name Define the name of the uniform as defined in the shader
  16768. * @param value Define the value to give to the uniform
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16772. /**
  16773. * Set a float32Array in the shader from a matrix array.
  16774. * @param name Define the name of the uniform as defined in the shader
  16775. * @param value Define the value to give to the uniform
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16779. /**
  16780. * Set a mat3 in the shader from a Float32Array.
  16781. * @param name Define the name of the uniform as defined in the shader
  16782. * @param value Define the value to give to the uniform
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16786. /**
  16787. * Set a mat2 in the shader from a Float32Array.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16793. /**
  16794. * Set a vec2 array in the shader from a number array.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setArray2(name: string, value: number[]): ShaderMaterial;
  16800. /**
  16801. * Set a vec3 array in the shader from a number array.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setArray3(name: string, value: number[]): ShaderMaterial;
  16807. /**
  16808. * Set a vec4 array in the shader from a number array.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setArray4(name: string, value: number[]): ShaderMaterial;
  16814. private _checkCache;
  16815. /**
  16816. * Specifies that the submesh is ready to be used
  16817. * @param mesh defines the mesh to check
  16818. * @param subMesh defines which submesh to check
  16819. * @param useInstances specifies that instances should be used
  16820. * @returns a boolean indicating that the submesh is ready or not
  16821. */
  16822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16823. /**
  16824. * Checks if the material is ready to render the requested mesh
  16825. * @param mesh Define the mesh to render
  16826. * @param useInstances Define whether or not the material is used with instances
  16827. * @returns true if ready, otherwise false
  16828. */
  16829. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16830. /**
  16831. * Binds the world matrix to the material
  16832. * @param world defines the world transformation matrix
  16833. * @param effectOverride - If provided, use this effect instead of internal effect
  16834. */
  16835. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16836. /**
  16837. * Binds the submesh to this material by preparing the effect and shader to draw
  16838. * @param world defines the world transformation matrix
  16839. * @param mesh defines the mesh containing the submesh
  16840. * @param subMesh defines the submesh to bind the material to
  16841. */
  16842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16843. /**
  16844. * Binds the material to the mesh
  16845. * @param world defines the world transformation matrix
  16846. * @param mesh defines the mesh to bind the material to
  16847. * @param effectOverride - If provided, use this effect instead of internal effect
  16848. */
  16849. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16850. protected _afterBind(mesh?: Mesh): void;
  16851. /**
  16852. * Gets the active textures from the material
  16853. * @returns an array of textures
  16854. */
  16855. getActiveTextures(): BaseTexture[];
  16856. /**
  16857. * Specifies if the material uses a texture
  16858. * @param texture defines the texture to check against the material
  16859. * @returns a boolean specifying if the material uses the texture
  16860. */
  16861. hasTexture(texture: BaseTexture): boolean;
  16862. /**
  16863. * Makes a duplicate of the material, and gives it a new name
  16864. * @param name defines the new name for the duplicated material
  16865. * @returns the cloned material
  16866. */
  16867. clone(name: string): ShaderMaterial;
  16868. /**
  16869. * Disposes the material
  16870. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16871. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16872. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16873. */
  16874. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16875. /**
  16876. * Serializes this material in a JSON representation
  16877. * @returns the serialized material object
  16878. */
  16879. serialize(): any;
  16880. /**
  16881. * Creates a shader material from parsed shader material data
  16882. * @param source defines the JSON represnetation of the material
  16883. * @param scene defines the hosting scene
  16884. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16885. * @returns a new material
  16886. */
  16887. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16888. /**
  16889. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16890. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16891. * @param url defines the url to load from
  16892. * @param scene defines the hosting scene
  16893. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16894. * @returns a promise that will resolve to the new ShaderMaterial
  16895. */
  16896. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16897. /**
  16898. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16899. * @param snippetId defines the snippet to load
  16900. * @param scene defines the hosting scene
  16901. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16902. * @returns a promise that will resolve to the new ShaderMaterial
  16903. */
  16904. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16905. }
  16906. }
  16907. declare module BABYLON {
  16908. /** @hidden */
  16909. export var colorPixelShader: {
  16910. name: string;
  16911. shader: string;
  16912. };
  16913. }
  16914. declare module BABYLON {
  16915. /** @hidden */
  16916. export var colorVertexShader: {
  16917. name: string;
  16918. shader: string;
  16919. };
  16920. }
  16921. declare module BABYLON {
  16922. /**
  16923. * Line mesh
  16924. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16925. */
  16926. export class LinesMesh extends Mesh {
  16927. /**
  16928. * If vertex color should be applied to the mesh
  16929. */
  16930. readonly useVertexColor?: boolean | undefined;
  16931. /**
  16932. * If vertex alpha should be applied to the mesh
  16933. */
  16934. readonly useVertexAlpha?: boolean | undefined;
  16935. /**
  16936. * Color of the line (Default: White)
  16937. */
  16938. color: Color3;
  16939. /**
  16940. * Alpha of the line (Default: 1)
  16941. */
  16942. alpha: number;
  16943. /**
  16944. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16945. * This margin is expressed in world space coordinates, so its value may vary.
  16946. * Default value is 0.1
  16947. */
  16948. intersectionThreshold: number;
  16949. private _colorShader;
  16950. private color4;
  16951. /**
  16952. * Creates a new LinesMesh
  16953. * @param name defines the name
  16954. * @param scene defines the hosting scene
  16955. * @param parent defines the parent mesh if any
  16956. * @param source defines the optional source LinesMesh used to clone data from
  16957. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16958. * When false, achieved by calling a clone(), also passing False.
  16959. * This will make creation of children, recursive.
  16960. * @param useVertexColor defines if this LinesMesh supports vertex color
  16961. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16962. */
  16963. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16964. /**
  16965. * If vertex color should be applied to the mesh
  16966. */
  16967. useVertexColor?: boolean | undefined,
  16968. /**
  16969. * If vertex alpha should be applied to the mesh
  16970. */
  16971. useVertexAlpha?: boolean | undefined);
  16972. private _addClipPlaneDefine;
  16973. private _removeClipPlaneDefine;
  16974. isReady(): boolean;
  16975. /**
  16976. * Returns the string "LineMesh"
  16977. */
  16978. getClassName(): string;
  16979. /**
  16980. * @hidden
  16981. */
  16982. get material(): Material;
  16983. /**
  16984. * @hidden
  16985. */
  16986. set material(value: Material);
  16987. /**
  16988. * @hidden
  16989. */
  16990. get checkCollisions(): boolean;
  16991. /** @hidden */
  16992. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16993. /** @hidden */
  16994. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16995. /**
  16996. * Disposes of the line mesh
  16997. * @param doNotRecurse If children should be disposed
  16998. */
  16999. dispose(doNotRecurse?: boolean): void;
  17000. /**
  17001. * Returns a new LineMesh object cloned from the current one.
  17002. */
  17003. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17004. /**
  17005. * Creates a new InstancedLinesMesh object from the mesh model.
  17006. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17007. * @param name defines the name of the new instance
  17008. * @returns a new InstancedLinesMesh
  17009. */
  17010. createInstance(name: string): InstancedLinesMesh;
  17011. }
  17012. /**
  17013. * Creates an instance based on a source LinesMesh
  17014. */
  17015. export class InstancedLinesMesh extends InstancedMesh {
  17016. /**
  17017. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17018. * This margin is expressed in world space coordinates, so its value may vary.
  17019. * Initilized with the intersectionThreshold value of the source LinesMesh
  17020. */
  17021. intersectionThreshold: number;
  17022. constructor(name: string, source: LinesMesh);
  17023. /**
  17024. * Returns the string "InstancedLinesMesh".
  17025. */
  17026. getClassName(): string;
  17027. }
  17028. }
  17029. declare module BABYLON {
  17030. /** @hidden */
  17031. export var linePixelShader: {
  17032. name: string;
  17033. shader: string;
  17034. };
  17035. }
  17036. declare module BABYLON {
  17037. /** @hidden */
  17038. export var lineVertexShader: {
  17039. name: string;
  17040. shader: string;
  17041. };
  17042. }
  17043. declare module BABYLON {
  17044. interface Scene {
  17045. /** @hidden */
  17046. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17047. }
  17048. interface AbstractMesh {
  17049. /**
  17050. * Gets the edgesRenderer associated with the mesh
  17051. */
  17052. edgesRenderer: Nullable<EdgesRenderer>;
  17053. }
  17054. interface LinesMesh {
  17055. /**
  17056. * Enables the edge rendering mode on the mesh.
  17057. * This mode makes the mesh edges visible
  17058. * @param epsilon defines the maximal distance between two angles to detect a face
  17059. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17060. * @returns the currentAbstractMesh
  17061. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17062. */
  17063. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17064. }
  17065. interface InstancedLinesMesh {
  17066. /**
  17067. * Enables the edge rendering mode on the mesh.
  17068. * This mode makes the mesh edges visible
  17069. * @param epsilon defines the maximal distance between two angles to detect a face
  17070. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17071. * @returns the current InstancedLinesMesh
  17072. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17073. */
  17074. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17075. }
  17076. /**
  17077. * Defines the minimum contract an Edges renderer should follow.
  17078. */
  17079. export interface IEdgesRenderer extends IDisposable {
  17080. /**
  17081. * Gets or sets a boolean indicating if the edgesRenderer is active
  17082. */
  17083. isEnabled: boolean;
  17084. /**
  17085. * Renders the edges of the attached mesh,
  17086. */
  17087. render(): void;
  17088. /**
  17089. * Checks wether or not the edges renderer is ready to render.
  17090. * @return true if ready, otherwise false.
  17091. */
  17092. isReady(): boolean;
  17093. /**
  17094. * List of instances to render in case the source mesh has instances
  17095. */
  17096. customInstances: SmartArray<Matrix>;
  17097. }
  17098. /**
  17099. * Defines the additional options of the edges renderer
  17100. */
  17101. export interface IEdgesRendererOptions {
  17102. /**
  17103. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17104. * If not defined, the default value is true
  17105. */
  17106. useAlternateEdgeFinder?: boolean;
  17107. /**
  17108. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17109. * If not defined, the default value is true.
  17110. * 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)
  17111. * This option is used only if useAlternateEdgeFinder = true
  17112. */
  17113. useFastVertexMerger?: boolean;
  17114. /**
  17115. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17116. * The default value is 1e-6
  17117. * This option is used only if useAlternateEdgeFinder = true
  17118. */
  17119. epsilonVertexMerge?: number;
  17120. /**
  17121. * 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
  17122. * 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.
  17123. * This option is used only if useAlternateEdgeFinder = true
  17124. */
  17125. applyTessellation?: boolean;
  17126. /**
  17127. * 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
  17128. * The default value is 1e-6
  17129. * This option is used only if useAlternateEdgeFinder = true
  17130. */
  17131. epsilonVertexAligned?: number;
  17132. }
  17133. /**
  17134. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17135. */
  17136. export class EdgesRenderer implements IEdgesRenderer {
  17137. /**
  17138. * Define the size of the edges with an orthographic camera
  17139. */
  17140. edgesWidthScalerForOrthographic: number;
  17141. /**
  17142. * Define the size of the edges with a perspective camera
  17143. */
  17144. edgesWidthScalerForPerspective: number;
  17145. protected _source: AbstractMesh;
  17146. protected _linesPositions: number[];
  17147. protected _linesNormals: number[];
  17148. protected _linesIndices: number[];
  17149. protected _epsilon: number;
  17150. protected _indicesCount: number;
  17151. protected _lineShader: ShaderMaterial;
  17152. protected _ib: DataBuffer;
  17153. protected _buffers: {
  17154. [key: string]: Nullable<VertexBuffer>;
  17155. };
  17156. protected _buffersForInstances: {
  17157. [key: string]: Nullable<VertexBuffer>;
  17158. };
  17159. protected _checkVerticesInsteadOfIndices: boolean;
  17160. protected _options: Nullable<IEdgesRendererOptions>;
  17161. private _meshRebuildObserver;
  17162. private _meshDisposeObserver;
  17163. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17164. isEnabled: boolean;
  17165. /**
  17166. * List of instances to render in case the source mesh has instances
  17167. */
  17168. customInstances: SmartArray<Matrix>;
  17169. private static GetShader;
  17170. /**
  17171. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17172. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17173. * @param source Mesh used to create edges
  17174. * @param epsilon sum of angles in adjacency to check for edge
  17175. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17176. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17177. * @param options The options to apply when generating the edges
  17178. */
  17179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17180. protected _prepareRessources(): void;
  17181. /** @hidden */
  17182. _rebuild(): void;
  17183. /**
  17184. * Releases the required resources for the edges renderer
  17185. */
  17186. dispose(): void;
  17187. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17188. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17189. /**
  17190. * Checks if the pair of p0 and p1 is en edge
  17191. * @param faceIndex
  17192. * @param edge
  17193. * @param faceNormals
  17194. * @param p0
  17195. * @param p1
  17196. * @private
  17197. */
  17198. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17199. /**
  17200. * push line into the position, normal and index buffer
  17201. * @protected
  17202. */
  17203. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17204. /**
  17205. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17206. */
  17207. private _tessellateTriangle;
  17208. private _generateEdgesLinesAlternate;
  17209. /**
  17210. * Generates lines edges from adjacencjes
  17211. * @private
  17212. */
  17213. _generateEdgesLines(): void;
  17214. /**
  17215. * Checks wether or not the edges renderer is ready to render.
  17216. * @return true if ready, otherwise false.
  17217. */
  17218. isReady(): boolean;
  17219. /**
  17220. * Renders the edges of the attached mesh,
  17221. */
  17222. render(): void;
  17223. }
  17224. /**
  17225. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17226. */
  17227. export class LineEdgesRenderer extends EdgesRenderer {
  17228. /**
  17229. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17230. * @param source LineMesh used to generate edges
  17231. * @param epsilon not important (specified angle for edge detection)
  17232. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17233. */
  17234. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17235. /**
  17236. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17237. */
  17238. _generateEdgesLines(): void;
  17239. }
  17240. }
  17241. declare module BABYLON {
  17242. /**
  17243. * This represents the object necessary to create a rendering group.
  17244. * This is exclusively used and created by the rendering manager.
  17245. * To modify the behavior, you use the available helpers in your scene or meshes.
  17246. * @hidden
  17247. */
  17248. export class RenderingGroup {
  17249. index: number;
  17250. private static _zeroVector;
  17251. private _scene;
  17252. private _opaqueSubMeshes;
  17253. private _transparentSubMeshes;
  17254. private _alphaTestSubMeshes;
  17255. private _depthOnlySubMeshes;
  17256. private _particleSystems;
  17257. private _spriteManagers;
  17258. private _opaqueSortCompareFn;
  17259. private _alphaTestSortCompareFn;
  17260. private _transparentSortCompareFn;
  17261. private _renderOpaque;
  17262. private _renderAlphaTest;
  17263. private _renderTransparent;
  17264. /** @hidden */
  17265. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17266. onBeforeTransparentRendering: () => void;
  17267. /**
  17268. * Set the opaque sort comparison function.
  17269. * If null the sub meshes will be render in the order they were created
  17270. */
  17271. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17272. /**
  17273. * Set the alpha test sort comparison function.
  17274. * If null the sub meshes will be render in the order they were created
  17275. */
  17276. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17277. /**
  17278. * Set the transparent sort comparison function.
  17279. * If null the sub meshes will be render in the order they were created
  17280. */
  17281. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17282. /**
  17283. * Creates a new rendering group.
  17284. * @param index The rendering group index
  17285. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17286. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17287. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17288. */
  17289. 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>);
  17290. /**
  17291. * Render all the sub meshes contained in the group.
  17292. * @param customRenderFunction Used to override the default render behaviour of the group.
  17293. * @returns true if rendered some submeshes.
  17294. */
  17295. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17296. /**
  17297. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17298. * @param subMeshes The submeshes to render
  17299. */
  17300. private renderOpaqueSorted;
  17301. /**
  17302. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17303. * @param subMeshes The submeshes to render
  17304. */
  17305. private renderAlphaTestSorted;
  17306. /**
  17307. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17308. * @param subMeshes The submeshes to render
  17309. */
  17310. private renderTransparentSorted;
  17311. /**
  17312. * Renders the submeshes in a specified order.
  17313. * @param subMeshes The submeshes to sort before render
  17314. * @param sortCompareFn The comparison function use to sort
  17315. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17316. * @param transparent Specifies to activate blending if true
  17317. */
  17318. private static renderSorted;
  17319. /**
  17320. * Renders the submeshes in the order they were dispatched (no sort applied).
  17321. * @param subMeshes The submeshes to render
  17322. */
  17323. private static renderUnsorted;
  17324. /**
  17325. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17326. * are rendered back to front if in the same alpha index.
  17327. *
  17328. * @param a The first submesh
  17329. * @param b The second submesh
  17330. * @returns The result of the comparison
  17331. */
  17332. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17333. /**
  17334. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17335. * are rendered back to front.
  17336. *
  17337. * @param a The first submesh
  17338. * @param b The second submesh
  17339. * @returns The result of the comparison
  17340. */
  17341. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17342. /**
  17343. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17344. * are rendered front to back (prevent overdraw).
  17345. *
  17346. * @param a The first submesh
  17347. * @param b The second submesh
  17348. * @returns The result of the comparison
  17349. */
  17350. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17351. /**
  17352. * Resets the different lists of submeshes to prepare a new frame.
  17353. */
  17354. prepare(): void;
  17355. dispose(): void;
  17356. /**
  17357. * Inserts the submesh in its correct queue depending on its material.
  17358. * @param subMesh The submesh to dispatch
  17359. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17360. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17361. */
  17362. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17363. dispatchSprites(spriteManager: ISpriteManager): void;
  17364. dispatchParticles(particleSystem: IParticleSystem): void;
  17365. private _renderParticles;
  17366. private _renderSprites;
  17367. }
  17368. }
  17369. declare module BABYLON {
  17370. /**
  17371. * Interface describing the different options available in the rendering manager
  17372. * regarding Auto Clear between groups.
  17373. */
  17374. export interface IRenderingManagerAutoClearSetup {
  17375. /**
  17376. * Defines whether or not autoclear is enable.
  17377. */
  17378. autoClear: boolean;
  17379. /**
  17380. * Defines whether or not to autoclear the depth buffer.
  17381. */
  17382. depth: boolean;
  17383. /**
  17384. * Defines whether or not to autoclear the stencil buffer.
  17385. */
  17386. stencil: boolean;
  17387. }
  17388. /**
  17389. * This class is used by the onRenderingGroupObservable
  17390. */
  17391. export class RenderingGroupInfo {
  17392. /**
  17393. * The Scene that being rendered
  17394. */
  17395. scene: Scene;
  17396. /**
  17397. * The camera currently used for the rendering pass
  17398. */
  17399. camera: Nullable<Camera>;
  17400. /**
  17401. * The ID of the renderingGroup being processed
  17402. */
  17403. renderingGroupId: number;
  17404. }
  17405. /**
  17406. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17407. * It is enable to manage the different groups as well as the different necessary sort functions.
  17408. * This should not be used directly aside of the few static configurations
  17409. */
  17410. export class RenderingManager {
  17411. /**
  17412. * The max id used for rendering groups (not included)
  17413. */
  17414. static MAX_RENDERINGGROUPS: number;
  17415. /**
  17416. * The min id used for rendering groups (included)
  17417. */
  17418. static MIN_RENDERINGGROUPS: number;
  17419. /**
  17420. * Used to globally prevent autoclearing scenes.
  17421. */
  17422. static AUTOCLEAR: boolean;
  17423. /**
  17424. * @hidden
  17425. */
  17426. _useSceneAutoClearSetup: boolean;
  17427. private _scene;
  17428. private _renderingGroups;
  17429. private _depthStencilBufferAlreadyCleaned;
  17430. private _autoClearDepthStencil;
  17431. private _customOpaqueSortCompareFn;
  17432. private _customAlphaTestSortCompareFn;
  17433. private _customTransparentSortCompareFn;
  17434. private _renderingGroupInfo;
  17435. /**
  17436. * Instantiates a new rendering group for a particular scene
  17437. * @param scene Defines the scene the groups belongs to
  17438. */
  17439. constructor(scene: Scene);
  17440. private _clearDepthStencilBuffer;
  17441. /**
  17442. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17443. * @hidden
  17444. */
  17445. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17446. /**
  17447. * Resets the different information of the group to prepare a new frame
  17448. * @hidden
  17449. */
  17450. reset(): void;
  17451. /**
  17452. * Dispose and release the group and its associated resources.
  17453. * @hidden
  17454. */
  17455. dispose(): void;
  17456. /**
  17457. * Clear the info related to rendering groups preventing retention points during dispose.
  17458. */
  17459. freeRenderingGroups(): void;
  17460. private _prepareRenderingGroup;
  17461. /**
  17462. * Add a sprite manager to the rendering manager in order to render it this frame.
  17463. * @param spriteManager Define the sprite manager to render
  17464. */
  17465. dispatchSprites(spriteManager: ISpriteManager): void;
  17466. /**
  17467. * Add a particle system to the rendering manager in order to render it this frame.
  17468. * @param particleSystem Define the particle system to render
  17469. */
  17470. dispatchParticles(particleSystem: IParticleSystem): void;
  17471. /**
  17472. * Add a submesh to the manager in order to render it this frame
  17473. * @param subMesh The submesh to dispatch
  17474. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17475. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17476. */
  17477. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17478. /**
  17479. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17480. * This allowed control for front to back rendering or reversly depending of the special needs.
  17481. *
  17482. * @param renderingGroupId The rendering group id corresponding to its index
  17483. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17484. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17485. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17486. */
  17487. 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;
  17488. /**
  17489. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17490. *
  17491. * @param renderingGroupId The rendering group id corresponding to its index
  17492. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17493. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17494. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17495. */
  17496. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17497. /**
  17498. * Gets the current auto clear configuration for one rendering group of the rendering
  17499. * manager.
  17500. * @param index the rendering group index to get the information for
  17501. * @returns The auto clear setup for the requested rendering group
  17502. */
  17503. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17504. }
  17505. }
  17506. declare module BABYLON {
  17507. /**
  17508. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17509. */
  17510. export interface ICustomShaderOptions {
  17511. /**
  17512. * Gets or sets the custom shader name to use
  17513. */
  17514. shaderName: string;
  17515. /**
  17516. * The list of attribute names used in the shader
  17517. */
  17518. attributes?: string[];
  17519. /**
  17520. * The list of unifrom names used in the shader
  17521. */
  17522. uniforms?: string[];
  17523. /**
  17524. * The list of sampler names used in the shader
  17525. */
  17526. samplers?: string[];
  17527. /**
  17528. * The list of defines used in the shader
  17529. */
  17530. defines?: string[];
  17531. }
  17532. /**
  17533. * Interface to implement to create a shadow generator compatible with BJS.
  17534. */
  17535. export interface IShadowGenerator {
  17536. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17537. id: string;
  17538. /**
  17539. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17540. * @returns The render target texture if present otherwise, null
  17541. */
  17542. getShadowMap(): Nullable<RenderTargetTexture>;
  17543. /**
  17544. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17545. * @param subMesh The submesh we want to render in the shadow map
  17546. * @param useInstances Defines wether will draw in the map using instances
  17547. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17548. * @returns true if ready otherwise, false
  17549. */
  17550. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17551. /**
  17552. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17553. * @param defines Defines of the material we want to update
  17554. * @param lightIndex Index of the light in the enabled light list of the material
  17555. */
  17556. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17557. /**
  17558. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17559. * defined in the generator but impacting the effect).
  17560. * It implies the unifroms available on the materials are the standard BJS ones.
  17561. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17562. * @param effect The effect we are binfing the information for
  17563. */
  17564. bindShadowLight(lightIndex: string, effect: Effect): void;
  17565. /**
  17566. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17567. * (eq to shadow prjection matrix * light transform matrix)
  17568. * @returns The transform matrix used to create the shadow map
  17569. */
  17570. getTransformMatrix(): Matrix;
  17571. /**
  17572. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17573. * Cube and 2D textures for instance.
  17574. */
  17575. recreateShadowMap(): void;
  17576. /**
  17577. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17578. * @param onCompiled Callback triggered at the and of the effects compilation
  17579. * @param options Sets of optional options forcing the compilation with different modes
  17580. */
  17581. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17582. useInstances: boolean;
  17583. }>): void;
  17584. /**
  17585. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17586. * @param options Sets of optional options forcing the compilation with different modes
  17587. * @returns A promise that resolves when the compilation completes
  17588. */
  17589. forceCompilationAsync(options?: Partial<{
  17590. useInstances: boolean;
  17591. }>): Promise<void>;
  17592. /**
  17593. * Serializes the shadow generator setup to a json object.
  17594. * @returns The serialized JSON object
  17595. */
  17596. serialize(): any;
  17597. /**
  17598. * Disposes the Shadow map and related Textures and effects.
  17599. */
  17600. dispose(): void;
  17601. }
  17602. /**
  17603. * Default implementation IShadowGenerator.
  17604. * This is the main object responsible of generating shadows in the framework.
  17605. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17606. */
  17607. export class ShadowGenerator implements IShadowGenerator {
  17608. /**
  17609. * Name of the shadow generator class
  17610. */
  17611. static CLASSNAME: string;
  17612. /**
  17613. * Shadow generator mode None: no filtering applied.
  17614. */
  17615. static readonly FILTER_NONE: number;
  17616. /**
  17617. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17618. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17619. */
  17620. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17621. /**
  17622. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17623. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17624. */
  17625. static readonly FILTER_POISSONSAMPLING: number;
  17626. /**
  17627. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17628. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17629. */
  17630. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17631. /**
  17632. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17633. * edge artifacts on steep falloff.
  17634. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17635. */
  17636. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17637. /**
  17638. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17639. * edge artifacts on steep falloff.
  17640. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17641. */
  17642. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17643. /**
  17644. * Shadow generator mode PCF: Percentage Closer Filtering
  17645. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17646. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17647. */
  17648. static readonly FILTER_PCF: number;
  17649. /**
  17650. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17651. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17652. * Contact Hardening
  17653. */
  17654. static readonly FILTER_PCSS: number;
  17655. /**
  17656. * Reserved for PCF and PCSS
  17657. * Highest Quality.
  17658. *
  17659. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17660. *
  17661. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17662. */
  17663. static readonly QUALITY_HIGH: number;
  17664. /**
  17665. * Reserved for PCF and PCSS
  17666. * Good tradeoff for quality/perf cross devices
  17667. *
  17668. * Execute PCF on a 3*3 kernel.
  17669. *
  17670. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17671. */
  17672. static readonly QUALITY_MEDIUM: number;
  17673. /**
  17674. * Reserved for PCF and PCSS
  17675. * The lowest quality but the fastest.
  17676. *
  17677. * Execute PCF on a 1*1 kernel.
  17678. *
  17679. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17680. */
  17681. static readonly QUALITY_LOW: number;
  17682. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17683. id: string;
  17684. /** Gets or sets the custom shader name to use */
  17685. customShaderOptions: ICustomShaderOptions;
  17686. /**
  17687. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17688. */
  17689. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17690. /**
  17691. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17692. */
  17693. onAfterShadowMapRenderObservable: Observable<Effect>;
  17694. /**
  17695. * Observable triggered before a mesh is rendered in the shadow map.
  17696. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17697. */
  17698. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17699. /**
  17700. * Observable triggered after a mesh is rendered in the shadow map.
  17701. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17702. */
  17703. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17704. protected _bias: number;
  17705. /**
  17706. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17707. */
  17708. get bias(): number;
  17709. /**
  17710. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17711. */
  17712. set bias(bias: number);
  17713. protected _normalBias: number;
  17714. /**
  17715. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17716. */
  17717. get normalBias(): number;
  17718. /**
  17719. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17720. */
  17721. set normalBias(normalBias: number);
  17722. protected _blurBoxOffset: number;
  17723. /**
  17724. * Gets the blur box offset: offset applied during the blur pass.
  17725. * Only useful if useKernelBlur = false
  17726. */
  17727. get blurBoxOffset(): number;
  17728. /**
  17729. * Sets the blur box offset: offset applied during the blur pass.
  17730. * Only useful if useKernelBlur = false
  17731. */
  17732. set blurBoxOffset(value: number);
  17733. protected _blurScale: number;
  17734. /**
  17735. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17736. * 2 means half of the size.
  17737. */
  17738. get blurScale(): number;
  17739. /**
  17740. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17741. * 2 means half of the size.
  17742. */
  17743. set blurScale(value: number);
  17744. protected _blurKernel: number;
  17745. /**
  17746. * Gets the blur kernel: kernel size of the blur pass.
  17747. * Only useful if useKernelBlur = true
  17748. */
  17749. get blurKernel(): number;
  17750. /**
  17751. * Sets the blur kernel: kernel size of the blur pass.
  17752. * Only useful if useKernelBlur = true
  17753. */
  17754. set blurKernel(value: number);
  17755. protected _useKernelBlur: boolean;
  17756. /**
  17757. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17758. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17759. */
  17760. get useKernelBlur(): boolean;
  17761. /**
  17762. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17763. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17764. */
  17765. set useKernelBlur(value: boolean);
  17766. protected _depthScale: number;
  17767. /**
  17768. * Gets the depth scale used in ESM mode.
  17769. */
  17770. get depthScale(): number;
  17771. /**
  17772. * Sets the depth scale used in ESM mode.
  17773. * This can override the scale stored on the light.
  17774. */
  17775. set depthScale(value: number);
  17776. protected _validateFilter(filter: number): number;
  17777. protected _filter: number;
  17778. /**
  17779. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17780. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17781. */
  17782. get filter(): number;
  17783. /**
  17784. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17785. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17786. */
  17787. set filter(value: number);
  17788. /**
  17789. * Gets if the current filter is set to Poisson Sampling.
  17790. */
  17791. get usePoissonSampling(): boolean;
  17792. /**
  17793. * Sets the current filter to Poisson Sampling.
  17794. */
  17795. set usePoissonSampling(value: boolean);
  17796. /**
  17797. * Gets if the current filter is set to ESM.
  17798. */
  17799. get useExponentialShadowMap(): boolean;
  17800. /**
  17801. * Sets the current filter is to ESM.
  17802. */
  17803. set useExponentialShadowMap(value: boolean);
  17804. /**
  17805. * Gets if the current filter is set to filtered ESM.
  17806. */
  17807. get useBlurExponentialShadowMap(): boolean;
  17808. /**
  17809. * Gets if the current filter is set to filtered ESM.
  17810. */
  17811. set useBlurExponentialShadowMap(value: boolean);
  17812. /**
  17813. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17814. * exponential to prevent steep falloff artifacts).
  17815. */
  17816. get useCloseExponentialShadowMap(): boolean;
  17817. /**
  17818. * Sets the current filter to "close ESM" (using the inverse of the
  17819. * exponential to prevent steep falloff artifacts).
  17820. */
  17821. set useCloseExponentialShadowMap(value: boolean);
  17822. /**
  17823. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17824. * exponential to prevent steep falloff artifacts).
  17825. */
  17826. get useBlurCloseExponentialShadowMap(): boolean;
  17827. /**
  17828. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17829. * exponential to prevent steep falloff artifacts).
  17830. */
  17831. set useBlurCloseExponentialShadowMap(value: boolean);
  17832. /**
  17833. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17834. */
  17835. get usePercentageCloserFiltering(): boolean;
  17836. /**
  17837. * Sets the current filter to "PCF" (percentage closer filtering).
  17838. */
  17839. set usePercentageCloserFiltering(value: boolean);
  17840. protected _filteringQuality: number;
  17841. /**
  17842. * Gets the PCF or PCSS Quality.
  17843. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17844. */
  17845. get filteringQuality(): number;
  17846. /**
  17847. * Sets the PCF or PCSS Quality.
  17848. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17849. */
  17850. set filteringQuality(filteringQuality: number);
  17851. /**
  17852. * Gets if the current filter is set to "PCSS" (contact hardening).
  17853. */
  17854. get useContactHardeningShadow(): boolean;
  17855. /**
  17856. * Sets the current filter to "PCSS" (contact hardening).
  17857. */
  17858. set useContactHardeningShadow(value: boolean);
  17859. protected _contactHardeningLightSizeUVRatio: number;
  17860. /**
  17861. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17862. * Using a ratio helps keeping shape stability independently of the map size.
  17863. *
  17864. * It does not account for the light projection as it was having too much
  17865. * instability during the light setup or during light position changes.
  17866. *
  17867. * Only valid if useContactHardeningShadow is true.
  17868. */
  17869. get contactHardeningLightSizeUVRatio(): number;
  17870. /**
  17871. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17872. * Using a ratio helps keeping shape stability independently of the map size.
  17873. *
  17874. * It does not account for the light projection as it was having too much
  17875. * instability during the light setup or during light position changes.
  17876. *
  17877. * Only valid if useContactHardeningShadow is true.
  17878. */
  17879. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17880. protected _darkness: number;
  17881. /** Gets or sets the actual darkness of a shadow */
  17882. get darkness(): number;
  17883. set darkness(value: number);
  17884. /**
  17885. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17886. * 0 means strongest and 1 would means no shadow.
  17887. * @returns the darkness.
  17888. */
  17889. getDarkness(): number;
  17890. /**
  17891. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17892. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17893. * @returns the shadow generator allowing fluent coding.
  17894. */
  17895. setDarkness(darkness: number): ShadowGenerator;
  17896. protected _transparencyShadow: boolean;
  17897. /** Gets or sets the ability to have transparent shadow */
  17898. get transparencyShadow(): boolean;
  17899. set transparencyShadow(value: boolean);
  17900. /**
  17901. * Sets the ability to have transparent shadow (boolean).
  17902. * @param transparent True if transparent else False
  17903. * @returns the shadow generator allowing fluent coding
  17904. */
  17905. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17906. /**
  17907. * Enables or disables shadows with varying strength based on the transparency
  17908. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17909. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17910. * mesh.visibility * alphaTexture.a
  17911. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17912. */
  17913. enableSoftTransparentShadow: boolean;
  17914. protected _shadowMap: Nullable<RenderTargetTexture>;
  17915. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17916. /**
  17917. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17918. * @returns The render target texture if present otherwise, null
  17919. */
  17920. getShadowMap(): Nullable<RenderTargetTexture>;
  17921. /**
  17922. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17923. * @returns The render target texture if the shadow map is present otherwise, null
  17924. */
  17925. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17926. /**
  17927. * Gets the class name of that object
  17928. * @returns "ShadowGenerator"
  17929. */
  17930. getClassName(): string;
  17931. /**
  17932. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17933. * @param mesh Mesh to add
  17934. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17935. * @returns the Shadow Generator itself
  17936. */
  17937. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17938. /**
  17939. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17940. * @param mesh Mesh to remove
  17941. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17942. * @returns the Shadow Generator itself
  17943. */
  17944. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17945. /**
  17946. * Controls the extent to which the shadows fade out at the edge of the frustum
  17947. */
  17948. frustumEdgeFalloff: number;
  17949. protected _light: IShadowLight;
  17950. /**
  17951. * Returns the associated light object.
  17952. * @returns the light generating the shadow
  17953. */
  17954. getLight(): IShadowLight;
  17955. /**
  17956. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17957. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17958. * It might on the other hand introduce peter panning.
  17959. */
  17960. forceBackFacesOnly: boolean;
  17961. protected _scene: Scene;
  17962. protected _lightDirection: Vector3;
  17963. protected _effect: Effect;
  17964. protected _viewMatrix: Matrix;
  17965. protected _projectionMatrix: Matrix;
  17966. protected _transformMatrix: Matrix;
  17967. protected _cachedPosition: Vector3;
  17968. protected _cachedDirection: Vector3;
  17969. protected _cachedDefines: string;
  17970. protected _currentRenderID: number;
  17971. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17972. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17973. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17974. protected _blurPostProcesses: PostProcess[];
  17975. protected _mapSize: number;
  17976. protected _currentFaceIndex: number;
  17977. protected _currentFaceIndexCache: number;
  17978. protected _textureType: number;
  17979. protected _defaultTextureMatrix: Matrix;
  17980. protected _storedUniqueId: Nullable<number>;
  17981. /** @hidden */
  17982. static _SceneComponentInitialization: (scene: Scene) => void;
  17983. /**
  17984. * Gets or sets the size of the texture what stores the shadows
  17985. */
  17986. get mapSize(): number;
  17987. set mapSize(size: number);
  17988. /**
  17989. * Creates a ShadowGenerator object.
  17990. * A ShadowGenerator is the required tool to use the shadows.
  17991. * Each light casting shadows needs to use its own ShadowGenerator.
  17992. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17993. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17994. * @param light The light object generating the shadows.
  17995. * @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.
  17996. */
  17997. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17998. protected _initializeGenerator(): void;
  17999. protected _createTargetRenderTexture(): void;
  18000. protected _initializeShadowMap(): void;
  18001. protected _initializeBlurRTTAndPostProcesses(): void;
  18002. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18003. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18004. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18005. protected _applyFilterValues(): void;
  18006. /**
  18007. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18008. * @param onCompiled Callback triggered at the and of the effects compilation
  18009. * @param options Sets of optional options forcing the compilation with different modes
  18010. */
  18011. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18012. useInstances: boolean;
  18013. }>): void;
  18014. /**
  18015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18016. * @param options Sets of optional options forcing the compilation with different modes
  18017. * @returns A promise that resolves when the compilation completes
  18018. */
  18019. forceCompilationAsync(options?: Partial<{
  18020. useInstances: boolean;
  18021. }>): Promise<void>;
  18022. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18023. private _prepareShadowDefines;
  18024. /**
  18025. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18026. * @param subMesh The submesh we want to render in the shadow map
  18027. * @param useInstances Defines wether will draw in the map using instances
  18028. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18029. * @returns true if ready otherwise, false
  18030. */
  18031. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18032. /**
  18033. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18034. * @param defines Defines of the material we want to update
  18035. * @param lightIndex Index of the light in the enabled light list of the material
  18036. */
  18037. prepareDefines(defines: any, lightIndex: number): void;
  18038. /**
  18039. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18040. * defined in the generator but impacting the effect).
  18041. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18042. * @param effect The effect we are binfing the information for
  18043. */
  18044. bindShadowLight(lightIndex: string, effect: Effect): void;
  18045. /**
  18046. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18047. * (eq to shadow prjection matrix * light transform matrix)
  18048. * @returns The transform matrix used to create the shadow map
  18049. */
  18050. getTransformMatrix(): Matrix;
  18051. /**
  18052. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18053. * Cube and 2D textures for instance.
  18054. */
  18055. recreateShadowMap(): void;
  18056. protected _disposeBlurPostProcesses(): void;
  18057. protected _disposeRTTandPostProcesses(): void;
  18058. /**
  18059. * Disposes the ShadowGenerator.
  18060. * Returns nothing.
  18061. */
  18062. dispose(): void;
  18063. /**
  18064. * Serializes the shadow generator setup to a json object.
  18065. * @returns The serialized JSON object
  18066. */
  18067. serialize(): any;
  18068. /**
  18069. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18070. * @param parsedShadowGenerator The JSON object to parse
  18071. * @param scene The scene to create the shadow map for
  18072. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18073. * @returns The parsed shadow generator
  18074. */
  18075. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18076. }
  18077. }
  18078. declare module BABYLON {
  18079. /**
  18080. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18081. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18082. * 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.
  18083. */
  18084. export abstract class Light extends Node {
  18085. /**
  18086. * Falloff Default: light is falling off following the material specification:
  18087. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18088. */
  18089. static readonly FALLOFF_DEFAULT: number;
  18090. /**
  18091. * Falloff Physical: light is falling off following the inverse squared distance law.
  18092. */
  18093. static readonly FALLOFF_PHYSICAL: number;
  18094. /**
  18095. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18096. * to enhance interoperability with other engines.
  18097. */
  18098. static readonly FALLOFF_GLTF: number;
  18099. /**
  18100. * Falloff Standard: light is falling off like in the standard material
  18101. * to enhance interoperability with other materials.
  18102. */
  18103. static readonly FALLOFF_STANDARD: number;
  18104. /**
  18105. * If every light affecting the material is in this lightmapMode,
  18106. * material.lightmapTexture adds or multiplies
  18107. * (depends on material.useLightmapAsShadowmap)
  18108. * after every other light calculations.
  18109. */
  18110. static readonly LIGHTMAP_DEFAULT: number;
  18111. /**
  18112. * material.lightmapTexture as only diffuse lighting from this light
  18113. * adds only specular lighting from this light
  18114. * adds dynamic shadows
  18115. */
  18116. static readonly LIGHTMAP_SPECULAR: number;
  18117. /**
  18118. * material.lightmapTexture as only lighting
  18119. * no light calculation from this light
  18120. * only adds dynamic shadows from this light
  18121. */
  18122. static readonly LIGHTMAP_SHADOWSONLY: number;
  18123. /**
  18124. * Each light type uses the default quantity according to its type:
  18125. * point/spot lights use luminous intensity
  18126. * directional lights use illuminance
  18127. */
  18128. static readonly INTENSITYMODE_AUTOMATIC: number;
  18129. /**
  18130. * lumen (lm)
  18131. */
  18132. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18133. /**
  18134. * candela (lm/sr)
  18135. */
  18136. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18137. /**
  18138. * lux (lm/m^2)
  18139. */
  18140. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18141. /**
  18142. * nit (cd/m^2)
  18143. */
  18144. static readonly INTENSITYMODE_LUMINANCE: number;
  18145. /**
  18146. * Light type const id of the point light.
  18147. */
  18148. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18149. /**
  18150. * Light type const id of the directional light.
  18151. */
  18152. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18153. /**
  18154. * Light type const id of the spot light.
  18155. */
  18156. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18157. /**
  18158. * Light type const id of the hemispheric light.
  18159. */
  18160. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18161. /**
  18162. * Diffuse gives the basic color to an object.
  18163. */
  18164. diffuse: Color3;
  18165. /**
  18166. * Specular produces a highlight color on an object.
  18167. * Note: This is note affecting PBR materials.
  18168. */
  18169. specular: Color3;
  18170. /**
  18171. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18172. * falling off base on range or angle.
  18173. * This can be set to any values in Light.FALLOFF_x.
  18174. *
  18175. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18176. * other types of materials.
  18177. */
  18178. falloffType: number;
  18179. /**
  18180. * Strength of the light.
  18181. * Note: By default it is define in the framework own unit.
  18182. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18183. */
  18184. intensity: number;
  18185. private _range;
  18186. protected _inverseSquaredRange: number;
  18187. /**
  18188. * Defines how far from the source the light is impacting in scene units.
  18189. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18190. */
  18191. get range(): number;
  18192. /**
  18193. * Defines how far from the source the light is impacting in scene units.
  18194. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18195. */
  18196. set range(value: number);
  18197. /**
  18198. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18199. * of light.
  18200. */
  18201. private _photometricScale;
  18202. private _intensityMode;
  18203. /**
  18204. * Gets the photometric scale used to interpret the intensity.
  18205. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18206. */
  18207. get intensityMode(): number;
  18208. /**
  18209. * Sets the photometric scale used to interpret the intensity.
  18210. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18211. */
  18212. set intensityMode(value: number);
  18213. private _radius;
  18214. /**
  18215. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18216. */
  18217. get radius(): number;
  18218. /**
  18219. * sets the light radius used by PBR Materials to simulate soft area lights.
  18220. */
  18221. set radius(value: number);
  18222. private _renderPriority;
  18223. /**
  18224. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18225. * exceeding the number allowed of the materials.
  18226. */
  18227. renderPriority: number;
  18228. private _shadowEnabled;
  18229. /**
  18230. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18231. * the current shadow generator.
  18232. */
  18233. get shadowEnabled(): boolean;
  18234. /**
  18235. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18236. * the current shadow generator.
  18237. */
  18238. set shadowEnabled(value: boolean);
  18239. private _includedOnlyMeshes;
  18240. /**
  18241. * Gets the only meshes impacted by this light.
  18242. */
  18243. get includedOnlyMeshes(): AbstractMesh[];
  18244. /**
  18245. * Sets the only meshes impacted by this light.
  18246. */
  18247. set includedOnlyMeshes(value: AbstractMesh[]);
  18248. private _excludedMeshes;
  18249. /**
  18250. * Gets the meshes not impacted by this light.
  18251. */
  18252. get excludedMeshes(): AbstractMesh[];
  18253. /**
  18254. * Sets the meshes not impacted by this light.
  18255. */
  18256. set excludedMeshes(value: AbstractMesh[]);
  18257. private _excludeWithLayerMask;
  18258. /**
  18259. * Gets the layer id use to find what meshes are not impacted by the light.
  18260. * Inactive if 0
  18261. */
  18262. get excludeWithLayerMask(): number;
  18263. /**
  18264. * Sets the layer id use to find what meshes are not impacted by the light.
  18265. * Inactive if 0
  18266. */
  18267. set excludeWithLayerMask(value: number);
  18268. private _includeOnlyWithLayerMask;
  18269. /**
  18270. * Gets the layer id use to find what meshes are impacted by the light.
  18271. * Inactive if 0
  18272. */
  18273. get includeOnlyWithLayerMask(): number;
  18274. /**
  18275. * Sets the layer id use to find what meshes are impacted by the light.
  18276. * Inactive if 0
  18277. */
  18278. set includeOnlyWithLayerMask(value: number);
  18279. private _lightmapMode;
  18280. /**
  18281. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18282. */
  18283. get lightmapMode(): number;
  18284. /**
  18285. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18286. */
  18287. set lightmapMode(value: number);
  18288. /**
  18289. * Shadow generator associted to the light.
  18290. * @hidden Internal use only.
  18291. */
  18292. _shadowGenerator: Nullable<IShadowGenerator>;
  18293. /**
  18294. * @hidden Internal use only.
  18295. */
  18296. _excludedMeshesIds: string[];
  18297. /**
  18298. * @hidden Internal use only.
  18299. */
  18300. _includedOnlyMeshesIds: string[];
  18301. /**
  18302. * The current light unifom buffer.
  18303. * @hidden Internal use only.
  18304. */
  18305. _uniformBuffer: UniformBuffer;
  18306. /** @hidden */
  18307. _renderId: number;
  18308. /**
  18309. * Creates a Light object in the scene.
  18310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18311. * @param name The firendly name of the light
  18312. * @param scene The scene the light belongs too
  18313. */
  18314. constructor(name: string, scene: Scene);
  18315. protected abstract _buildUniformLayout(): void;
  18316. /**
  18317. * Sets the passed Effect "effect" with the Light information.
  18318. * @param effect The effect to update
  18319. * @param lightIndex The index of the light in the effect to update
  18320. * @returns The light
  18321. */
  18322. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18323. /**
  18324. * Sets the passed Effect "effect" with the Light textures.
  18325. * @param effect The effect to update
  18326. * @param lightIndex The index of the light in the effect to update
  18327. * @returns The light
  18328. */
  18329. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18330. /**
  18331. * Binds the lights information from the scene to the effect for the given mesh.
  18332. * @param lightIndex Light index
  18333. * @param scene The scene where the light belongs to
  18334. * @param effect The effect we are binding the data to
  18335. * @param useSpecular Defines if specular is supported
  18336. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18337. */
  18338. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18339. /**
  18340. * Sets the passed Effect "effect" with the Light information.
  18341. * @param effect The effect to update
  18342. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18343. * @returns The light
  18344. */
  18345. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18346. /**
  18347. * Returns the string "Light".
  18348. * @returns the class name
  18349. */
  18350. getClassName(): string;
  18351. /** @hidden */
  18352. readonly _isLight: boolean;
  18353. /**
  18354. * Converts the light information to a readable string for debug purpose.
  18355. * @param fullDetails Supports for multiple levels of logging within scene loading
  18356. * @returns the human readable light info
  18357. */
  18358. toString(fullDetails?: boolean): string;
  18359. /** @hidden */
  18360. protected _syncParentEnabledState(): void;
  18361. /**
  18362. * Set the enabled state of this node.
  18363. * @param value - the new enabled state
  18364. */
  18365. setEnabled(value: boolean): void;
  18366. /**
  18367. * Returns the Light associated shadow generator if any.
  18368. * @return the associated shadow generator.
  18369. */
  18370. getShadowGenerator(): Nullable<IShadowGenerator>;
  18371. /**
  18372. * Returns a Vector3, the absolute light position in the World.
  18373. * @returns the world space position of the light
  18374. */
  18375. getAbsolutePosition(): Vector3;
  18376. /**
  18377. * Specifies if the light will affect the passed mesh.
  18378. * @param mesh The mesh to test against the light
  18379. * @return true the mesh is affected otherwise, false.
  18380. */
  18381. canAffectMesh(mesh: AbstractMesh): boolean;
  18382. /**
  18383. * Sort function to order lights for rendering.
  18384. * @param a First Light object to compare to second.
  18385. * @param b Second Light object to compare first.
  18386. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18387. */
  18388. static CompareLightsPriority(a: Light, b: Light): number;
  18389. /**
  18390. * Releases resources associated with this node.
  18391. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18392. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18393. */
  18394. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18395. /**
  18396. * Returns the light type ID (integer).
  18397. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18398. */
  18399. getTypeID(): number;
  18400. /**
  18401. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18402. * @returns the scaled intensity in intensity mode unit
  18403. */
  18404. getScaledIntensity(): number;
  18405. /**
  18406. * Returns a new Light object, named "name", from the current one.
  18407. * @param name The name of the cloned light
  18408. * @param newParent The parent of this light, if it has one
  18409. * @returns the new created light
  18410. */
  18411. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18412. /**
  18413. * Serializes the current light into a Serialization object.
  18414. * @returns the serialized object.
  18415. */
  18416. serialize(): any;
  18417. /**
  18418. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18419. * This new light is named "name" and added to the passed scene.
  18420. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18421. * @param name The friendly name of the light
  18422. * @param scene The scene the new light will belong to
  18423. * @returns the constructor function
  18424. */
  18425. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18426. /**
  18427. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18428. * @param parsedLight The JSON representation of the light
  18429. * @param scene The scene to create the parsed light in
  18430. * @returns the created light after parsing
  18431. */
  18432. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18433. private _hookArrayForExcluded;
  18434. private _hookArrayForIncludedOnly;
  18435. private _resyncMeshes;
  18436. /**
  18437. * Forces the meshes to update their light related information in their rendering used effects
  18438. * @hidden Internal Use Only
  18439. */
  18440. _markMeshesAsLightDirty(): void;
  18441. /**
  18442. * Recomputes the cached photometric scale if needed.
  18443. */
  18444. private _computePhotometricScale;
  18445. /**
  18446. * Returns the Photometric Scale according to the light type and intensity mode.
  18447. */
  18448. private _getPhotometricScale;
  18449. /**
  18450. * Reorder the light in the scene according to their defined priority.
  18451. * @hidden Internal Use Only
  18452. */
  18453. _reorderLightsInScene(): void;
  18454. /**
  18455. * Prepares the list of defines specific to the light type.
  18456. * @param defines the list of defines
  18457. * @param lightIndex defines the index of the light for the effect
  18458. */
  18459. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18460. }
  18461. }
  18462. declare module BABYLON {
  18463. /**
  18464. * Configuration needed for prepass-capable materials
  18465. */
  18466. export class PrePassConfiguration {
  18467. /**
  18468. * Previous world matrices of meshes carrying this material
  18469. * Used for computing velocity
  18470. */
  18471. previousWorldMatrices: {
  18472. [index: number]: Matrix;
  18473. };
  18474. /**
  18475. * Previous view project matrix
  18476. * Used for computing velocity
  18477. */
  18478. previousViewProjection: Matrix;
  18479. /**
  18480. * Previous bones of meshes carrying this material
  18481. * Used for computing velocity
  18482. */
  18483. previousBones: {
  18484. [index: number]: Float32Array;
  18485. };
  18486. /**
  18487. * Add the required uniforms to the current list.
  18488. * @param uniforms defines the current uniform list.
  18489. */
  18490. static AddUniforms(uniforms: string[]): void;
  18491. /**
  18492. * Add the required samplers to the current list.
  18493. * @param samplers defines the current sampler list.
  18494. */
  18495. static AddSamplers(samplers: string[]): void;
  18496. /**
  18497. * Binds the material data.
  18498. * @param effect defines the effect to update
  18499. * @param scene defines the scene the material belongs to.
  18500. * @param mesh The mesh
  18501. * @param world World matrix of this mesh
  18502. * @param isFrozen Is the material frozen
  18503. */
  18504. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18505. }
  18506. }
  18507. declare module BABYLON {
  18508. /**
  18509. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18510. * This is the base of the follow, arc rotate cameras and Free camera
  18511. * @see https://doc.babylonjs.com/features/cameras
  18512. */
  18513. export class TargetCamera extends Camera {
  18514. private static _RigCamTransformMatrix;
  18515. private static _TargetTransformMatrix;
  18516. private static _TargetFocalPoint;
  18517. private _tmpUpVector;
  18518. private _tmpTargetVector;
  18519. /**
  18520. * Define the current direction the camera is moving to
  18521. */
  18522. cameraDirection: Vector3;
  18523. /**
  18524. * Define the current rotation the camera is rotating to
  18525. */
  18526. cameraRotation: Vector2;
  18527. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18528. ignoreParentScaling: boolean;
  18529. /**
  18530. * When set, the up vector of the camera will be updated by the rotation of the camera
  18531. */
  18532. updateUpVectorFromRotation: boolean;
  18533. private _tmpQuaternion;
  18534. /**
  18535. * Define the current rotation of the camera
  18536. */
  18537. rotation: Vector3;
  18538. /**
  18539. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18540. */
  18541. rotationQuaternion: Quaternion;
  18542. /**
  18543. * Define the current speed of the camera
  18544. */
  18545. speed: number;
  18546. /**
  18547. * Add constraint to the camera to prevent it to move freely in all directions and
  18548. * around all axis.
  18549. */
  18550. noRotationConstraint: boolean;
  18551. /**
  18552. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18553. * panning
  18554. */
  18555. invertRotation: boolean;
  18556. /**
  18557. * Speed multiplier for inverse camera panning
  18558. */
  18559. inverseRotationSpeed: number;
  18560. /**
  18561. * Define the current target of the camera as an object or a position.
  18562. */
  18563. lockedTarget: any;
  18564. /** @hidden */
  18565. _currentTarget: Vector3;
  18566. /** @hidden */
  18567. _initialFocalDistance: number;
  18568. /** @hidden */
  18569. _viewMatrix: Matrix;
  18570. /** @hidden */
  18571. _camMatrix: Matrix;
  18572. /** @hidden */
  18573. _cameraTransformMatrix: Matrix;
  18574. /** @hidden */
  18575. _cameraRotationMatrix: Matrix;
  18576. /** @hidden */
  18577. _referencePoint: Vector3;
  18578. /** @hidden */
  18579. _transformedReferencePoint: Vector3;
  18580. /** @hidden */
  18581. _reset: () => void;
  18582. private _defaultUp;
  18583. /**
  18584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18585. * This is the base of the follow, arc rotate cameras and Free camera
  18586. * @see https://doc.babylonjs.com/features/cameras
  18587. * @param name Defines the name of the camera in the scene
  18588. * @param position Defines the start position of the camera in the scene
  18589. * @param scene Defines the scene the camera belongs to
  18590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18591. */
  18592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18593. /**
  18594. * Gets the position in front of the camera at a given distance.
  18595. * @param distance The distance from the camera we want the position to be
  18596. * @returns the position
  18597. */
  18598. getFrontPosition(distance: number): Vector3;
  18599. /** @hidden */
  18600. _getLockedTargetPosition(): Nullable<Vector3>;
  18601. private _storedPosition;
  18602. private _storedRotation;
  18603. private _storedRotationQuaternion;
  18604. /**
  18605. * Store current camera state of the camera (fov, position, rotation, etc..)
  18606. * @returns the camera
  18607. */
  18608. storeState(): Camera;
  18609. /**
  18610. * Restored camera state. You must call storeState() first
  18611. * @returns whether it was successful or not
  18612. * @hidden
  18613. */
  18614. _restoreStateValues(): boolean;
  18615. /** @hidden */
  18616. _initCache(): void;
  18617. /** @hidden */
  18618. _updateCache(ignoreParentClass?: boolean): void;
  18619. /** @hidden */
  18620. _isSynchronizedViewMatrix(): boolean;
  18621. /** @hidden */
  18622. _computeLocalCameraSpeed(): number;
  18623. /**
  18624. * Defines the target the camera should look at.
  18625. * @param target Defines the new target as a Vector or a mesh
  18626. */
  18627. setTarget(target: Vector3): void;
  18628. /**
  18629. * Defines the target point of the camera.
  18630. * The camera looks towards it form the radius distance.
  18631. */
  18632. get target(): Vector3;
  18633. set target(value: Vector3);
  18634. /**
  18635. * Return the current target position of the camera. This value is expressed in local space.
  18636. * @returns the target position
  18637. */
  18638. getTarget(): Vector3;
  18639. /** @hidden */
  18640. _decideIfNeedsToMove(): boolean;
  18641. /** @hidden */
  18642. _updatePosition(): void;
  18643. /** @hidden */
  18644. _checkInputs(): void;
  18645. protected _updateCameraRotationMatrix(): void;
  18646. /**
  18647. * 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)
  18648. * @returns the current camera
  18649. */
  18650. private _rotateUpVectorWithCameraRotationMatrix;
  18651. private _cachedRotationZ;
  18652. private _cachedQuaternionRotationZ;
  18653. /** @hidden */
  18654. _getViewMatrix(): Matrix;
  18655. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18656. /**
  18657. * @hidden
  18658. */
  18659. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18660. /**
  18661. * @hidden
  18662. */
  18663. _updateRigCameras(): void;
  18664. private _getRigCamPositionAndTarget;
  18665. /**
  18666. * Gets the current object class name.
  18667. * @return the class name
  18668. */
  18669. getClassName(): string;
  18670. }
  18671. }
  18672. declare module BABYLON {
  18673. /**
  18674. * Gather the list of keyboard event types as constants.
  18675. */
  18676. export class KeyboardEventTypes {
  18677. /**
  18678. * The keydown event is fired when a key becomes active (pressed).
  18679. */
  18680. static readonly KEYDOWN: number;
  18681. /**
  18682. * The keyup event is fired when a key has been released.
  18683. */
  18684. static readonly KEYUP: number;
  18685. }
  18686. /**
  18687. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18688. */
  18689. export class KeyboardInfo {
  18690. /**
  18691. * Defines the type of event (KeyboardEventTypes)
  18692. */
  18693. type: number;
  18694. /**
  18695. * Defines the related dom event
  18696. */
  18697. event: KeyboardEvent;
  18698. /**
  18699. * Instantiates a new keyboard info.
  18700. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18701. * @param type Defines the type of event (KeyboardEventTypes)
  18702. * @param event Defines the related dom event
  18703. */
  18704. constructor(
  18705. /**
  18706. * Defines the type of event (KeyboardEventTypes)
  18707. */
  18708. type: number,
  18709. /**
  18710. * Defines the related dom event
  18711. */
  18712. event: KeyboardEvent);
  18713. }
  18714. /**
  18715. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18716. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18717. */
  18718. export class KeyboardInfoPre extends KeyboardInfo {
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number;
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent;
  18727. /**
  18728. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18729. */
  18730. skipOnPointerObservable: boolean;
  18731. /**
  18732. * Instantiates a new keyboard pre info.
  18733. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18734. * @param type Defines the type of event (KeyboardEventTypes)
  18735. * @param event Defines the related dom event
  18736. */
  18737. constructor(
  18738. /**
  18739. * Defines the type of event (KeyboardEventTypes)
  18740. */
  18741. type: number,
  18742. /**
  18743. * Defines the related dom event
  18744. */
  18745. event: KeyboardEvent);
  18746. }
  18747. }
  18748. declare module BABYLON {
  18749. /**
  18750. * Manage the keyboard inputs to control the movement of a free camera.
  18751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18752. */
  18753. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18754. /**
  18755. * Defines the camera the input is attached to.
  18756. */
  18757. camera: FreeCamera;
  18758. /**
  18759. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18760. */
  18761. keysUp: number[];
  18762. /**
  18763. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18764. */
  18765. keysUpward: number[];
  18766. /**
  18767. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18768. */
  18769. keysDown: number[];
  18770. /**
  18771. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18772. */
  18773. keysDownward: number[];
  18774. /**
  18775. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18776. */
  18777. keysLeft: number[];
  18778. /**
  18779. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18780. */
  18781. keysRight: number[];
  18782. private _keys;
  18783. private _onCanvasBlurObserver;
  18784. private _onKeyboardObserver;
  18785. private _engine;
  18786. private _scene;
  18787. /**
  18788. * Attach the input controls to a specific dom element to get the input from.
  18789. * @param element Defines the element the controls should be listened from
  18790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18791. */
  18792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18793. /**
  18794. * Detach the current controls from the specified dom element.
  18795. * @param element Defines the element to stop listening the inputs from
  18796. */
  18797. detachControl(element: Nullable<HTMLElement>): void;
  18798. /**
  18799. * Update the current camera state depending on the inputs that have been used this frame.
  18800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18801. */
  18802. checkInputs(): void;
  18803. /**
  18804. * Gets the class name of the current intput.
  18805. * @returns the class name
  18806. */
  18807. getClassName(): string;
  18808. /** @hidden */
  18809. _onLostFocus(): void;
  18810. /**
  18811. * Get the friendly name associated with the input class.
  18812. * @returns the input friendly name
  18813. */
  18814. getSimpleName(): string;
  18815. }
  18816. }
  18817. declare module BABYLON {
  18818. /**
  18819. * Gather the list of pointer event types as constants.
  18820. */
  18821. export class PointerEventTypes {
  18822. /**
  18823. * 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.
  18824. */
  18825. static readonly POINTERDOWN: number;
  18826. /**
  18827. * The pointerup event is fired when a pointer is no longer active.
  18828. */
  18829. static readonly POINTERUP: number;
  18830. /**
  18831. * The pointermove event is fired when a pointer changes coordinates.
  18832. */
  18833. static readonly POINTERMOVE: number;
  18834. /**
  18835. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18836. */
  18837. static readonly POINTERWHEEL: number;
  18838. /**
  18839. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18840. */
  18841. static readonly POINTERPICK: number;
  18842. /**
  18843. * The pointertap event is fired when a the object has been touched and released without drag.
  18844. */
  18845. static readonly POINTERTAP: number;
  18846. /**
  18847. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18848. */
  18849. static readonly POINTERDOUBLETAP: number;
  18850. }
  18851. /**
  18852. * Base class of pointer info types.
  18853. */
  18854. export class PointerInfoBase {
  18855. /**
  18856. * Defines the type of event (PointerEventTypes)
  18857. */
  18858. type: number;
  18859. /**
  18860. * Defines the related dom event
  18861. */
  18862. event: PointerEvent | MouseWheelEvent;
  18863. /**
  18864. * Instantiates the base class of pointers info.
  18865. * @param type Defines the type of event (PointerEventTypes)
  18866. * @param event Defines the related dom event
  18867. */
  18868. constructor(
  18869. /**
  18870. * Defines the type of event (PointerEventTypes)
  18871. */
  18872. type: number,
  18873. /**
  18874. * Defines the related dom event
  18875. */
  18876. event: PointerEvent | MouseWheelEvent);
  18877. }
  18878. /**
  18879. * This class is used to store pointer related info for the onPrePointerObservable event.
  18880. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18881. */
  18882. export class PointerInfoPre extends PointerInfoBase {
  18883. /**
  18884. * Ray from a pointer if availible (eg. 6dof controller)
  18885. */
  18886. ray: Nullable<Ray>;
  18887. /**
  18888. * Defines the local position of the pointer on the canvas.
  18889. */
  18890. localPosition: Vector2;
  18891. /**
  18892. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18893. */
  18894. skipOnPointerObservable: boolean;
  18895. /**
  18896. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18897. * @param type Defines the type of event (PointerEventTypes)
  18898. * @param event Defines the related dom event
  18899. * @param localX Defines the local x coordinates of the pointer when the event occured
  18900. * @param localY Defines the local y coordinates of the pointer when the event occured
  18901. */
  18902. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18903. }
  18904. /**
  18905. * This type contains all the data related to a pointer event in Babylon.js.
  18906. * 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.
  18907. */
  18908. export class PointerInfo extends PointerInfoBase {
  18909. /**
  18910. * Defines the picking info associated to the info (if any)\
  18911. */
  18912. pickInfo: Nullable<PickingInfo>;
  18913. /**
  18914. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18915. * @param type Defines the type of event (PointerEventTypes)
  18916. * @param event Defines the related dom event
  18917. * @param pickInfo Defines the picking info associated to the info (if any)\
  18918. */
  18919. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18920. /**
  18921. * Defines the picking info associated to the info (if any)\
  18922. */
  18923. pickInfo: Nullable<PickingInfo>);
  18924. }
  18925. /**
  18926. * Data relating to a touch event on the screen.
  18927. */
  18928. export interface PointerTouch {
  18929. /**
  18930. * X coordinate of touch.
  18931. */
  18932. x: number;
  18933. /**
  18934. * Y coordinate of touch.
  18935. */
  18936. y: number;
  18937. /**
  18938. * Id of touch. Unique for each finger.
  18939. */
  18940. pointerId: number;
  18941. /**
  18942. * Event type passed from DOM.
  18943. */
  18944. type: any;
  18945. }
  18946. }
  18947. declare module BABYLON {
  18948. /**
  18949. * Manage the mouse inputs to control the movement of a free camera.
  18950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18951. */
  18952. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18953. /**
  18954. * Define if touch is enabled in the mouse input
  18955. */
  18956. touchEnabled: boolean;
  18957. /**
  18958. * Defines the camera the input is attached to.
  18959. */
  18960. camera: FreeCamera;
  18961. /**
  18962. * Defines the buttons associated with the input to handle camera move.
  18963. */
  18964. buttons: number[];
  18965. /**
  18966. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18967. */
  18968. angularSensibility: number;
  18969. private _pointerInput;
  18970. private _onMouseMove;
  18971. private _observer;
  18972. private previousPosition;
  18973. /**
  18974. * Observable for when a pointer move event occurs containing the move offset
  18975. */
  18976. onPointerMovedObservable: Observable<{
  18977. offsetX: number;
  18978. offsetY: number;
  18979. }>;
  18980. /**
  18981. * @hidden
  18982. * If the camera should be rotated automatically based on pointer movement
  18983. */
  18984. _allowCameraRotation: boolean;
  18985. /**
  18986. * Manage the mouse inputs to control the movement of a free camera.
  18987. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18988. * @param touchEnabled Defines if touch is enabled or not
  18989. */
  18990. constructor(
  18991. /**
  18992. * Define if touch is enabled in the mouse input
  18993. */
  18994. touchEnabled?: boolean);
  18995. /**
  18996. * Attach the input controls to a specific dom element to get the input from.
  18997. * @param element Defines the element the controls should be listened from
  18998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18999. */
  19000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19001. /**
  19002. * Called on JS contextmenu event.
  19003. * Override this method to provide functionality.
  19004. */
  19005. protected onContextMenu(evt: PointerEvent): void;
  19006. /**
  19007. * Detach the current controls from the specified dom element.
  19008. * @param element Defines the element to stop listening the inputs from
  19009. */
  19010. detachControl(element: Nullable<HTMLElement>): void;
  19011. /**
  19012. * Gets the class name of the current intput.
  19013. * @returns the class name
  19014. */
  19015. getClassName(): string;
  19016. /**
  19017. * Get the friendly name associated with the input class.
  19018. * @returns the input friendly name
  19019. */
  19020. getSimpleName(): string;
  19021. }
  19022. }
  19023. declare module BABYLON {
  19024. /**
  19025. * Manage the touch inputs to control the movement of a free camera.
  19026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19027. */
  19028. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19029. /**
  19030. * Define if mouse events can be treated as touch events
  19031. */
  19032. allowMouse: boolean;
  19033. /**
  19034. * Defines the camera the input is attached to.
  19035. */
  19036. camera: FreeCamera;
  19037. /**
  19038. * Defines the touch sensibility for rotation.
  19039. * The higher the faster.
  19040. */
  19041. touchAngularSensibility: number;
  19042. /**
  19043. * Defines the touch sensibility for move.
  19044. * The higher the faster.
  19045. */
  19046. touchMoveSensibility: number;
  19047. private _offsetX;
  19048. private _offsetY;
  19049. private _pointerPressed;
  19050. private _pointerInput;
  19051. private _observer;
  19052. private _onLostFocus;
  19053. /**
  19054. * Manage the touch inputs to control the movement of a free camera.
  19055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19056. * @param allowMouse Defines if mouse events can be treated as touch events
  19057. */
  19058. constructor(
  19059. /**
  19060. * Define if mouse events can be treated as touch events
  19061. */
  19062. allowMouse?: boolean);
  19063. /**
  19064. * Attach the input controls to a specific dom element to get the input from.
  19065. * @param element Defines the element the controls should be listened from
  19066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19067. */
  19068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19069. /**
  19070. * Detach the current controls from the specified dom element.
  19071. * @param element Defines the element to stop listening the inputs from
  19072. */
  19073. detachControl(element: Nullable<HTMLElement>): void;
  19074. /**
  19075. * Update the current camera state depending on the inputs that have been used this frame.
  19076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19077. */
  19078. checkInputs(): void;
  19079. /**
  19080. * Gets the class name of the current intput.
  19081. * @returns the class name
  19082. */
  19083. getClassName(): string;
  19084. /**
  19085. * Get the friendly name associated with the input class.
  19086. * @returns the input friendly name
  19087. */
  19088. getSimpleName(): string;
  19089. }
  19090. }
  19091. declare module BABYLON {
  19092. /**
  19093. * Default Inputs manager for the FreeCamera.
  19094. * It groups all the default supported inputs for ease of use.
  19095. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19096. */
  19097. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19098. /**
  19099. * @hidden
  19100. */
  19101. _mouseInput: Nullable<FreeCameraMouseInput>;
  19102. /**
  19103. * Instantiates a new FreeCameraInputsManager.
  19104. * @param camera Defines the camera the inputs belong to
  19105. */
  19106. constructor(camera: FreeCamera);
  19107. /**
  19108. * Add keyboard input support to the input manager.
  19109. * @returns the current input manager
  19110. */
  19111. addKeyboard(): FreeCameraInputsManager;
  19112. /**
  19113. * Add mouse input support to the input manager.
  19114. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19115. * @returns the current input manager
  19116. */
  19117. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19118. /**
  19119. * Removes the mouse input support from the manager
  19120. * @returns the current input manager
  19121. */
  19122. removeMouse(): FreeCameraInputsManager;
  19123. /**
  19124. * Add touch input support to the input manager.
  19125. * @returns the current input manager
  19126. */
  19127. addTouch(): FreeCameraInputsManager;
  19128. /**
  19129. * Remove all attached input methods from a camera
  19130. */
  19131. clear(): void;
  19132. }
  19133. }
  19134. declare module BABYLON {
  19135. /**
  19136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19137. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19138. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19139. */
  19140. export class FreeCamera extends TargetCamera {
  19141. /**
  19142. * Define the collision ellipsoid of the camera.
  19143. * This is helpful to simulate a camera body like the player body around the camera
  19144. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19145. */
  19146. ellipsoid: Vector3;
  19147. /**
  19148. * Define an offset for the position of the ellipsoid around the camera.
  19149. * This can be helpful to determine the center of the body near the gravity center of the body
  19150. * instead of its head.
  19151. */
  19152. ellipsoidOffset: Vector3;
  19153. /**
  19154. * Enable or disable collisions of the camera with the rest of the scene objects.
  19155. */
  19156. checkCollisions: boolean;
  19157. /**
  19158. * Enable or disable gravity on the camera.
  19159. */
  19160. applyGravity: boolean;
  19161. /**
  19162. * Define the input manager associated to the camera.
  19163. */
  19164. inputs: FreeCameraInputsManager;
  19165. /**
  19166. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19167. * Higher values reduce sensitivity.
  19168. */
  19169. get angularSensibility(): number;
  19170. /**
  19171. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19172. * Higher values reduce sensitivity.
  19173. */
  19174. set angularSensibility(value: number);
  19175. /**
  19176. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19177. */
  19178. get keysUp(): number[];
  19179. set keysUp(value: number[]);
  19180. /**
  19181. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19182. */
  19183. get keysUpward(): number[];
  19184. set keysUpward(value: number[]);
  19185. /**
  19186. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19187. */
  19188. get keysDown(): number[];
  19189. set keysDown(value: number[]);
  19190. /**
  19191. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19192. */
  19193. get keysDownward(): number[];
  19194. set keysDownward(value: number[]);
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19197. */
  19198. get keysLeft(): number[];
  19199. set keysLeft(value: number[]);
  19200. /**
  19201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19202. */
  19203. get keysRight(): number[];
  19204. set keysRight(value: number[]);
  19205. /**
  19206. * Event raised when the camera collide with a mesh in the scene.
  19207. */
  19208. onCollide: (collidedMesh: AbstractMesh) => void;
  19209. private _collider;
  19210. private _needMoveForGravity;
  19211. private _oldPosition;
  19212. private _diffPosition;
  19213. private _newPosition;
  19214. /** @hidden */
  19215. _localDirection: Vector3;
  19216. /** @hidden */
  19217. _transformedDirection: Vector3;
  19218. /**
  19219. * Instantiates a Free Camera.
  19220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19221. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19222. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19223. * @param name Define the name of the camera in the scene
  19224. * @param position Define the start position of the camera in the scene
  19225. * @param scene Define the scene the camera belongs to
  19226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19227. */
  19228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19229. /**
  19230. * Attached controls to the current camera.
  19231. * @param element Defines the element the controls should be listened from
  19232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19233. */
  19234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19235. /**
  19236. * Detach the current controls from the camera.
  19237. * The camera will stop reacting to inputs.
  19238. * @param element Defines the element to stop listening the inputs from
  19239. */
  19240. detachControl(element: HTMLElement): void;
  19241. private _collisionMask;
  19242. /**
  19243. * Define a collision mask to limit the list of object the camera can collide with
  19244. */
  19245. get collisionMask(): number;
  19246. set collisionMask(mask: number);
  19247. /** @hidden */
  19248. _collideWithWorld(displacement: Vector3): void;
  19249. private _onCollisionPositionChange;
  19250. /** @hidden */
  19251. _checkInputs(): void;
  19252. /** @hidden */
  19253. _decideIfNeedsToMove(): boolean;
  19254. /** @hidden */
  19255. _updatePosition(): void;
  19256. /**
  19257. * Destroy the camera and release the current resources hold by it.
  19258. */
  19259. dispose(): void;
  19260. /**
  19261. * Gets the current object class name.
  19262. * @return the class name
  19263. */
  19264. getClassName(): string;
  19265. }
  19266. }
  19267. declare module BABYLON {
  19268. /**
  19269. * Represents a gamepad control stick position
  19270. */
  19271. export class StickValues {
  19272. /**
  19273. * The x component of the control stick
  19274. */
  19275. x: number;
  19276. /**
  19277. * The y component of the control stick
  19278. */
  19279. y: number;
  19280. /**
  19281. * Initializes the gamepad x and y control stick values
  19282. * @param x The x component of the gamepad control stick value
  19283. * @param y The y component of the gamepad control stick value
  19284. */
  19285. constructor(
  19286. /**
  19287. * The x component of the control stick
  19288. */
  19289. x: number,
  19290. /**
  19291. * The y component of the control stick
  19292. */
  19293. y: number);
  19294. }
  19295. /**
  19296. * An interface which manages callbacks for gamepad button changes
  19297. */
  19298. export interface GamepadButtonChanges {
  19299. /**
  19300. * Called when a gamepad has been changed
  19301. */
  19302. changed: boolean;
  19303. /**
  19304. * Called when a gamepad press event has been triggered
  19305. */
  19306. pressChanged: boolean;
  19307. /**
  19308. * Called when a touch event has been triggered
  19309. */
  19310. touchChanged: boolean;
  19311. /**
  19312. * Called when a value has changed
  19313. */
  19314. valueChanged: boolean;
  19315. }
  19316. /**
  19317. * Represents a gamepad
  19318. */
  19319. export class Gamepad {
  19320. /**
  19321. * The id of the gamepad
  19322. */
  19323. id: string;
  19324. /**
  19325. * The index of the gamepad
  19326. */
  19327. index: number;
  19328. /**
  19329. * The browser gamepad
  19330. */
  19331. browserGamepad: any;
  19332. /**
  19333. * Specifies what type of gamepad this represents
  19334. */
  19335. type: number;
  19336. private _leftStick;
  19337. private _rightStick;
  19338. /** @hidden */
  19339. _isConnected: boolean;
  19340. private _leftStickAxisX;
  19341. private _leftStickAxisY;
  19342. private _rightStickAxisX;
  19343. private _rightStickAxisY;
  19344. /**
  19345. * Triggered when the left control stick has been changed
  19346. */
  19347. private _onleftstickchanged;
  19348. /**
  19349. * Triggered when the right control stick has been changed
  19350. */
  19351. private _onrightstickchanged;
  19352. /**
  19353. * Represents a gamepad controller
  19354. */
  19355. static GAMEPAD: number;
  19356. /**
  19357. * Represents a generic controller
  19358. */
  19359. static GENERIC: number;
  19360. /**
  19361. * Represents an XBox controller
  19362. */
  19363. static XBOX: number;
  19364. /**
  19365. * Represents a pose-enabled controller
  19366. */
  19367. static POSE_ENABLED: number;
  19368. /**
  19369. * Represents an Dual Shock controller
  19370. */
  19371. static DUALSHOCK: number;
  19372. /**
  19373. * Specifies whether the left control stick should be Y-inverted
  19374. */
  19375. protected _invertLeftStickY: boolean;
  19376. /**
  19377. * Specifies if the gamepad has been connected
  19378. */
  19379. get isConnected(): boolean;
  19380. /**
  19381. * Initializes the gamepad
  19382. * @param id The id of the gamepad
  19383. * @param index The index of the gamepad
  19384. * @param browserGamepad The browser gamepad
  19385. * @param leftStickX The x component of the left joystick
  19386. * @param leftStickY The y component of the left joystick
  19387. * @param rightStickX The x component of the right joystick
  19388. * @param rightStickY The y component of the right joystick
  19389. */
  19390. constructor(
  19391. /**
  19392. * The id of the gamepad
  19393. */
  19394. id: string,
  19395. /**
  19396. * The index of the gamepad
  19397. */
  19398. index: number,
  19399. /**
  19400. * The browser gamepad
  19401. */
  19402. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19403. /**
  19404. * Callback triggered when the left joystick has changed
  19405. * @param callback
  19406. */
  19407. onleftstickchanged(callback: (values: StickValues) => void): void;
  19408. /**
  19409. * Callback triggered when the right joystick has changed
  19410. * @param callback
  19411. */
  19412. onrightstickchanged(callback: (values: StickValues) => void): void;
  19413. /**
  19414. * Gets the left joystick
  19415. */
  19416. get leftStick(): StickValues;
  19417. /**
  19418. * Sets the left joystick values
  19419. */
  19420. set leftStick(newValues: StickValues);
  19421. /**
  19422. * Gets the right joystick
  19423. */
  19424. get rightStick(): StickValues;
  19425. /**
  19426. * Sets the right joystick value
  19427. */
  19428. set rightStick(newValues: StickValues);
  19429. /**
  19430. * Updates the gamepad joystick positions
  19431. */
  19432. update(): void;
  19433. /**
  19434. * Disposes the gamepad
  19435. */
  19436. dispose(): void;
  19437. }
  19438. /**
  19439. * Represents a generic gamepad
  19440. */
  19441. export class GenericPad extends Gamepad {
  19442. private _buttons;
  19443. private _onbuttondown;
  19444. private _onbuttonup;
  19445. /**
  19446. * Observable triggered when a button has been pressed
  19447. */
  19448. onButtonDownObservable: Observable<number>;
  19449. /**
  19450. * Observable triggered when a button has been released
  19451. */
  19452. onButtonUpObservable: Observable<number>;
  19453. /**
  19454. * Callback triggered when a button has been pressed
  19455. * @param callback Called when a button has been pressed
  19456. */
  19457. onbuttondown(callback: (buttonPressed: number) => void): void;
  19458. /**
  19459. * Callback triggered when a button has been released
  19460. * @param callback Called when a button has been released
  19461. */
  19462. onbuttonup(callback: (buttonReleased: number) => void): void;
  19463. /**
  19464. * Initializes the generic gamepad
  19465. * @param id The id of the generic gamepad
  19466. * @param index The index of the generic gamepad
  19467. * @param browserGamepad The browser gamepad
  19468. */
  19469. constructor(id: string, index: number, browserGamepad: any);
  19470. private _setButtonValue;
  19471. /**
  19472. * Updates the generic gamepad
  19473. */
  19474. update(): void;
  19475. /**
  19476. * Disposes the generic gamepad
  19477. */
  19478. dispose(): void;
  19479. }
  19480. }
  19481. declare module BABYLON {
  19482. /**
  19483. * Defines the types of pose enabled controllers that are supported
  19484. */
  19485. export enum PoseEnabledControllerType {
  19486. /**
  19487. * HTC Vive
  19488. */
  19489. VIVE = 0,
  19490. /**
  19491. * Oculus Rift
  19492. */
  19493. OCULUS = 1,
  19494. /**
  19495. * Windows mixed reality
  19496. */
  19497. WINDOWS = 2,
  19498. /**
  19499. * Samsung gear VR
  19500. */
  19501. GEAR_VR = 3,
  19502. /**
  19503. * Google Daydream
  19504. */
  19505. DAYDREAM = 4,
  19506. /**
  19507. * Generic
  19508. */
  19509. GENERIC = 5
  19510. }
  19511. /**
  19512. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19513. */
  19514. export interface MutableGamepadButton {
  19515. /**
  19516. * Value of the button/trigger
  19517. */
  19518. value: number;
  19519. /**
  19520. * If the button/trigger is currently touched
  19521. */
  19522. touched: boolean;
  19523. /**
  19524. * If the button/trigger is currently pressed
  19525. */
  19526. pressed: boolean;
  19527. }
  19528. /**
  19529. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19530. * @hidden
  19531. */
  19532. export interface ExtendedGamepadButton extends GamepadButton {
  19533. /**
  19534. * If the button/trigger is currently pressed
  19535. */
  19536. readonly pressed: boolean;
  19537. /**
  19538. * If the button/trigger is currently touched
  19539. */
  19540. readonly touched: boolean;
  19541. /**
  19542. * Value of the button/trigger
  19543. */
  19544. readonly value: number;
  19545. }
  19546. /** @hidden */
  19547. export interface _GamePadFactory {
  19548. /**
  19549. * Returns whether or not the current gamepad can be created for this type of controller.
  19550. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19551. * @returns true if it can be created, otherwise false
  19552. */
  19553. canCreate(gamepadInfo: any): boolean;
  19554. /**
  19555. * Creates a new instance of the Gamepad.
  19556. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19557. * @returns the new gamepad instance
  19558. */
  19559. create(gamepadInfo: any): Gamepad;
  19560. }
  19561. /**
  19562. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19563. */
  19564. export class PoseEnabledControllerHelper {
  19565. /** @hidden */
  19566. static _ControllerFactories: _GamePadFactory[];
  19567. /** @hidden */
  19568. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19569. /**
  19570. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19571. * @param vrGamepad the gamepad to initialized
  19572. * @returns a vr controller of the type the gamepad identified as
  19573. */
  19574. static InitiateController(vrGamepad: any): Gamepad;
  19575. }
  19576. /**
  19577. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19578. */
  19579. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19580. /**
  19581. * If the controller is used in a webXR session
  19582. */
  19583. isXR: boolean;
  19584. private _deviceRoomPosition;
  19585. private _deviceRoomRotationQuaternion;
  19586. /**
  19587. * The device position in babylon space
  19588. */
  19589. devicePosition: Vector3;
  19590. /**
  19591. * The device rotation in babylon space
  19592. */
  19593. deviceRotationQuaternion: Quaternion;
  19594. /**
  19595. * The scale factor of the device in babylon space
  19596. */
  19597. deviceScaleFactor: number;
  19598. /**
  19599. * (Likely devicePosition should be used instead) The device position in its room space
  19600. */
  19601. position: Vector3;
  19602. /**
  19603. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19604. */
  19605. rotationQuaternion: Quaternion;
  19606. /**
  19607. * The type of controller (Eg. Windows mixed reality)
  19608. */
  19609. controllerType: PoseEnabledControllerType;
  19610. protected _calculatedPosition: Vector3;
  19611. private _calculatedRotation;
  19612. /**
  19613. * The raw pose from the device
  19614. */
  19615. rawPose: DevicePose;
  19616. private _trackPosition;
  19617. private _maxRotationDistFromHeadset;
  19618. private _draggedRoomRotation;
  19619. /**
  19620. * @hidden
  19621. */
  19622. _disableTrackPosition(fixedPosition: Vector3): void;
  19623. /**
  19624. * Internal, the mesh attached to the controller
  19625. * @hidden
  19626. */
  19627. _mesh: Nullable<AbstractMesh>;
  19628. private _poseControlledCamera;
  19629. private _leftHandSystemQuaternion;
  19630. /**
  19631. * Internal, matrix used to convert room space to babylon space
  19632. * @hidden
  19633. */
  19634. _deviceToWorld: Matrix;
  19635. /**
  19636. * Node to be used when casting a ray from the controller
  19637. * @hidden
  19638. */
  19639. _pointingPoseNode: Nullable<TransformNode>;
  19640. /**
  19641. * Name of the child mesh that can be used to cast a ray from the controller
  19642. */
  19643. static readonly POINTING_POSE: string;
  19644. /**
  19645. * Creates a new PoseEnabledController from a gamepad
  19646. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19647. */
  19648. constructor(browserGamepad: any);
  19649. private _workingMatrix;
  19650. /**
  19651. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19652. */
  19653. update(): void;
  19654. /**
  19655. * Updates only the pose device and mesh without doing any button event checking
  19656. */
  19657. protected _updatePoseAndMesh(): void;
  19658. /**
  19659. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19660. * @param poseData raw pose fromthe device
  19661. */
  19662. updateFromDevice(poseData: DevicePose): void;
  19663. /**
  19664. * @hidden
  19665. */
  19666. _meshAttachedObservable: Observable<AbstractMesh>;
  19667. /**
  19668. * Attaches a mesh to the controller
  19669. * @param mesh the mesh to be attached
  19670. */
  19671. attachToMesh(mesh: AbstractMesh): void;
  19672. /**
  19673. * Attaches the controllers mesh to a camera
  19674. * @param camera the camera the mesh should be attached to
  19675. */
  19676. attachToPoseControlledCamera(camera: TargetCamera): void;
  19677. /**
  19678. * Disposes of the controller
  19679. */
  19680. dispose(): void;
  19681. /**
  19682. * The mesh that is attached to the controller
  19683. */
  19684. get mesh(): Nullable<AbstractMesh>;
  19685. /**
  19686. * Gets the ray of the controller in the direction the controller is pointing
  19687. * @param length the length the resulting ray should be
  19688. * @returns a ray in the direction the controller is pointing
  19689. */
  19690. getForwardRay(length?: number): Ray;
  19691. }
  19692. }
  19693. declare module BABYLON {
  19694. /**
  19695. * Defines the WebVRController object that represents controllers tracked in 3D space
  19696. */
  19697. export abstract class WebVRController extends PoseEnabledController {
  19698. /**
  19699. * Internal, the default controller model for the controller
  19700. */
  19701. protected _defaultModel: Nullable<AbstractMesh>;
  19702. /**
  19703. * Fired when the trigger state has changed
  19704. */
  19705. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19706. /**
  19707. * Fired when the main button state has changed
  19708. */
  19709. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19710. /**
  19711. * Fired when the secondary button state has changed
  19712. */
  19713. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19714. /**
  19715. * Fired when the pad state has changed
  19716. */
  19717. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19718. /**
  19719. * Fired when controllers stick values have changed
  19720. */
  19721. onPadValuesChangedObservable: Observable<StickValues>;
  19722. /**
  19723. * Array of button availible on the controller
  19724. */
  19725. protected _buttons: Array<MutableGamepadButton>;
  19726. private _onButtonStateChange;
  19727. /**
  19728. * Fired when a controller button's state has changed
  19729. * @param callback the callback containing the button that was modified
  19730. */
  19731. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19732. /**
  19733. * X and Y axis corresponding to the controllers joystick
  19734. */
  19735. pad: StickValues;
  19736. /**
  19737. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19738. */
  19739. hand: string;
  19740. /**
  19741. * The default controller model for the controller
  19742. */
  19743. get defaultModel(): Nullable<AbstractMesh>;
  19744. /**
  19745. * Creates a new WebVRController from a gamepad
  19746. * @param vrGamepad the gamepad that the WebVRController should be created from
  19747. */
  19748. constructor(vrGamepad: any);
  19749. /**
  19750. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19751. */
  19752. update(): void;
  19753. /**
  19754. * Function to be called when a button is modified
  19755. */
  19756. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19757. /**
  19758. * Loads a mesh and attaches it to the controller
  19759. * @param scene the scene the mesh should be added to
  19760. * @param meshLoaded callback for when the mesh has been loaded
  19761. */
  19762. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19763. private _setButtonValue;
  19764. private _changes;
  19765. private _checkChanges;
  19766. /**
  19767. * Disposes of th webVRCOntroller
  19768. */
  19769. dispose(): void;
  19770. }
  19771. }
  19772. declare module BABYLON {
  19773. /**
  19774. * The HemisphericLight simulates the ambient environment light,
  19775. * so the passed direction is the light reflection direction, not the incoming direction.
  19776. */
  19777. export class HemisphericLight extends Light {
  19778. /**
  19779. * The groundColor is the light in the opposite direction to the one specified during creation.
  19780. * 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.
  19781. */
  19782. groundColor: Color3;
  19783. /**
  19784. * The light reflection direction, not the incoming direction.
  19785. */
  19786. direction: Vector3;
  19787. /**
  19788. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19789. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19790. * The HemisphericLight can't cast shadows.
  19791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19792. * @param name The friendly name of the light
  19793. * @param direction The direction of the light reflection
  19794. * @param scene The scene the light belongs to
  19795. */
  19796. constructor(name: string, direction: Vector3, scene: Scene);
  19797. protected _buildUniformLayout(): void;
  19798. /**
  19799. * Returns the string "HemisphericLight".
  19800. * @return The class name
  19801. */
  19802. getClassName(): string;
  19803. /**
  19804. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19805. * Returns the updated direction.
  19806. * @param target The target the direction should point to
  19807. * @return The computed direction
  19808. */
  19809. setDirectionToTarget(target: Vector3): Vector3;
  19810. /**
  19811. * Returns the shadow generator associated to the light.
  19812. * @returns Always null for hemispheric lights because it does not support shadows.
  19813. */
  19814. getShadowGenerator(): Nullable<IShadowGenerator>;
  19815. /**
  19816. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19817. * @param effect The effect to update
  19818. * @param lightIndex The index of the light in the effect to update
  19819. * @returns The hemispheric light
  19820. */
  19821. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19822. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19823. /**
  19824. * Computes the world matrix of the node
  19825. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19826. * @param useWasUpdatedFlag defines a reserved property
  19827. * @returns the world matrix
  19828. */
  19829. computeWorldMatrix(): Matrix;
  19830. /**
  19831. * Returns the integer 3.
  19832. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19833. */
  19834. getTypeID(): number;
  19835. /**
  19836. * Prepares the list of defines specific to the light type.
  19837. * @param defines the list of defines
  19838. * @param lightIndex defines the index of the light for the effect
  19839. */
  19840. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19841. }
  19842. }
  19843. declare module BABYLON {
  19844. /** @hidden */
  19845. export var vrMultiviewToSingleviewPixelShader: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module BABYLON {
  19851. /**
  19852. * Renders to multiple views with a single draw call
  19853. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19854. */
  19855. export class MultiviewRenderTarget extends RenderTargetTexture {
  19856. /**
  19857. * Creates a multiview render target
  19858. * @param scene scene used with the render target
  19859. * @param size the size of the render target (used for each view)
  19860. */
  19861. constructor(scene: Scene, size?: number | {
  19862. width: number;
  19863. height: number;
  19864. } | {
  19865. ratio: number;
  19866. });
  19867. /**
  19868. * @hidden
  19869. * @param faceIndex the face index, if its a cube texture
  19870. */
  19871. _bindFrameBuffer(faceIndex?: number): void;
  19872. /**
  19873. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19874. * @returns the view count
  19875. */
  19876. getViewCount(): number;
  19877. }
  19878. }
  19879. declare module BABYLON {
  19880. interface Engine {
  19881. /**
  19882. * Creates a new multiview render target
  19883. * @param width defines the width of the texture
  19884. * @param height defines the height of the texture
  19885. * @returns the created multiview texture
  19886. */
  19887. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19888. /**
  19889. * Binds a multiview framebuffer to be drawn to
  19890. * @param multiviewTexture texture to bind
  19891. */
  19892. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19893. }
  19894. interface Camera {
  19895. /**
  19896. * @hidden
  19897. * 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)
  19898. */
  19899. _useMultiviewToSingleView: boolean;
  19900. /**
  19901. * @hidden
  19902. * 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)
  19903. */
  19904. _multiviewTexture: Nullable<RenderTargetTexture>;
  19905. /**
  19906. * @hidden
  19907. * ensures the multiview texture of the camera exists and has the specified width/height
  19908. * @param width height to set on the multiview texture
  19909. * @param height width to set on the multiview texture
  19910. */
  19911. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19912. }
  19913. interface Scene {
  19914. /** @hidden */
  19915. _transformMatrixR: Matrix;
  19916. /** @hidden */
  19917. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19918. /** @hidden */
  19919. _createMultiviewUbo(): void;
  19920. /** @hidden */
  19921. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19922. /** @hidden */
  19923. _renderMultiviewToSingleView(camera: Camera): void;
  19924. }
  19925. }
  19926. declare module BABYLON {
  19927. /**
  19928. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19929. * This will not be used for webXR as it supports displaying texture arrays directly
  19930. */
  19931. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19932. /**
  19933. * Gets a string identifying the name of the class
  19934. * @returns "VRMultiviewToSingleviewPostProcess" string
  19935. */
  19936. getClassName(): string;
  19937. /**
  19938. * Initializes a VRMultiviewToSingleview
  19939. * @param name name of the post process
  19940. * @param camera camera to be applied to
  19941. * @param scaleFactor scaling factor to the size of the output texture
  19942. */
  19943. constructor(name: string, camera: Camera, scaleFactor: number);
  19944. }
  19945. }
  19946. declare module BABYLON {
  19947. /**
  19948. * Interface used to define additional presentation attributes
  19949. */
  19950. export interface IVRPresentationAttributes {
  19951. /**
  19952. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19953. */
  19954. highRefreshRate: boolean;
  19955. /**
  19956. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19957. */
  19958. foveationLevel: number;
  19959. }
  19960. interface Engine {
  19961. /** @hidden */
  19962. _vrDisplay: any;
  19963. /** @hidden */
  19964. _vrSupported: boolean;
  19965. /** @hidden */
  19966. _oldSize: Size;
  19967. /** @hidden */
  19968. _oldHardwareScaleFactor: number;
  19969. /** @hidden */
  19970. _vrExclusivePointerMode: boolean;
  19971. /** @hidden */
  19972. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19973. /** @hidden */
  19974. _onVRDisplayPointerRestricted: () => void;
  19975. /** @hidden */
  19976. _onVRDisplayPointerUnrestricted: () => void;
  19977. /** @hidden */
  19978. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19979. /** @hidden */
  19980. _onVrDisplayDisconnect: Nullable<() => void>;
  19981. /** @hidden */
  19982. _onVrDisplayPresentChange: Nullable<() => void>;
  19983. /**
  19984. * Observable signaled when VR display mode changes
  19985. */
  19986. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19987. /**
  19988. * Observable signaled when VR request present is complete
  19989. */
  19990. onVRRequestPresentComplete: Observable<boolean>;
  19991. /**
  19992. * Observable signaled when VR request present starts
  19993. */
  19994. onVRRequestPresentStart: Observable<Engine>;
  19995. /**
  19996. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19997. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19998. */
  19999. isInVRExclusivePointerMode: boolean;
  20000. /**
  20001. * Gets a boolean indicating if a webVR device was detected
  20002. * @returns true if a webVR device was detected
  20003. */
  20004. isVRDevicePresent(): boolean;
  20005. /**
  20006. * Gets the current webVR device
  20007. * @returns the current webVR device (or null)
  20008. */
  20009. getVRDevice(): any;
  20010. /**
  20011. * Initializes a webVR display and starts listening to display change events
  20012. * The onVRDisplayChangedObservable will be notified upon these changes
  20013. * @returns A promise containing a VRDisplay and if vr is supported
  20014. */
  20015. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20016. /** @hidden */
  20017. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20018. /**
  20019. * Gets or sets the presentation attributes used to configure VR rendering
  20020. */
  20021. vrPresentationAttributes?: IVRPresentationAttributes;
  20022. /**
  20023. * Call this function to switch to webVR mode
  20024. * Will do nothing if webVR is not supported or if there is no webVR device
  20025. * @param options the webvr options provided to the camera. mainly used for multiview
  20026. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20027. */
  20028. enableVR(options: WebVROptions): void;
  20029. /** @hidden */
  20030. _onVRFullScreenTriggered(): void;
  20031. }
  20032. }
  20033. declare module BABYLON {
  20034. /**
  20035. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20036. * IMPORTANT!! The data is right-hand data.
  20037. * @export
  20038. * @interface DevicePose
  20039. */
  20040. export interface DevicePose {
  20041. /**
  20042. * The position of the device, values in array are [x,y,z].
  20043. */
  20044. readonly position: Nullable<Float32Array>;
  20045. /**
  20046. * The linearVelocity of the device, values in array are [x,y,z].
  20047. */
  20048. readonly linearVelocity: Nullable<Float32Array>;
  20049. /**
  20050. * The linearAcceleration of the device, values in array are [x,y,z].
  20051. */
  20052. readonly linearAcceleration: Nullable<Float32Array>;
  20053. /**
  20054. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20055. */
  20056. readonly orientation: Nullable<Float32Array>;
  20057. /**
  20058. * The angularVelocity of the device, values in array are [x,y,z].
  20059. */
  20060. readonly angularVelocity: Nullable<Float32Array>;
  20061. /**
  20062. * The angularAcceleration of the device, values in array are [x,y,z].
  20063. */
  20064. readonly angularAcceleration: Nullable<Float32Array>;
  20065. }
  20066. /**
  20067. * Interface representing a pose controlled object in Babylon.
  20068. * A pose controlled object has both regular pose values as well as pose values
  20069. * from an external device such as a VR head mounted display
  20070. */
  20071. export interface PoseControlled {
  20072. /**
  20073. * The position of the object in babylon space.
  20074. */
  20075. position: Vector3;
  20076. /**
  20077. * The rotation quaternion of the object in babylon space.
  20078. */
  20079. rotationQuaternion: Quaternion;
  20080. /**
  20081. * The position of the device in babylon space.
  20082. */
  20083. devicePosition?: Vector3;
  20084. /**
  20085. * The rotation quaternion of the device in babylon space.
  20086. */
  20087. deviceRotationQuaternion: Quaternion;
  20088. /**
  20089. * The raw pose coming from the device.
  20090. */
  20091. rawPose: Nullable<DevicePose>;
  20092. /**
  20093. * The scale of the device to be used when translating from device space to babylon space.
  20094. */
  20095. deviceScaleFactor: number;
  20096. /**
  20097. * Updates the poseControlled values based on the input device pose.
  20098. * @param poseData the pose data to update the object with
  20099. */
  20100. updateFromDevice(poseData: DevicePose): void;
  20101. }
  20102. /**
  20103. * Set of options to customize the webVRCamera
  20104. */
  20105. export interface WebVROptions {
  20106. /**
  20107. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20108. */
  20109. trackPosition?: boolean;
  20110. /**
  20111. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20112. */
  20113. positionScale?: number;
  20114. /**
  20115. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20116. */
  20117. displayName?: string;
  20118. /**
  20119. * Should the native controller meshes be initialized. (default: true)
  20120. */
  20121. controllerMeshes?: boolean;
  20122. /**
  20123. * Creating a default HemiLight only on controllers. (default: true)
  20124. */
  20125. defaultLightingOnControllers?: boolean;
  20126. /**
  20127. * If you don't want to use the default VR button of the helper. (default: false)
  20128. */
  20129. useCustomVRButton?: boolean;
  20130. /**
  20131. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20132. */
  20133. customVRButton?: HTMLButtonElement;
  20134. /**
  20135. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20136. */
  20137. rayLength?: number;
  20138. /**
  20139. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20140. */
  20141. defaultHeight?: number;
  20142. /**
  20143. * If multiview should be used if availible (default: false)
  20144. */
  20145. useMultiview?: boolean;
  20146. }
  20147. /**
  20148. * This represents a WebVR camera.
  20149. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20150. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20151. */
  20152. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20153. private webVROptions;
  20154. /**
  20155. * @hidden
  20156. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20157. */
  20158. _vrDevice: any;
  20159. /**
  20160. * The rawPose of the vrDevice.
  20161. */
  20162. rawPose: Nullable<DevicePose>;
  20163. private _onVREnabled;
  20164. private _specsVersion;
  20165. private _attached;
  20166. private _frameData;
  20167. protected _descendants: Array<Node>;
  20168. private _deviceRoomPosition;
  20169. /** @hidden */
  20170. _deviceRoomRotationQuaternion: Quaternion;
  20171. private _standingMatrix;
  20172. /**
  20173. * Represents device position in babylon space.
  20174. */
  20175. devicePosition: Vector3;
  20176. /**
  20177. * Represents device rotation in babylon space.
  20178. */
  20179. deviceRotationQuaternion: Quaternion;
  20180. /**
  20181. * The scale of the device to be used when translating from device space to babylon space.
  20182. */
  20183. deviceScaleFactor: number;
  20184. private _deviceToWorld;
  20185. private _worldToDevice;
  20186. /**
  20187. * References to the webVR controllers for the vrDevice.
  20188. */
  20189. controllers: Array<WebVRController>;
  20190. /**
  20191. * Emits an event when a controller is attached.
  20192. */
  20193. onControllersAttachedObservable: Observable<WebVRController[]>;
  20194. /**
  20195. * Emits an event when a controller's mesh has been loaded;
  20196. */
  20197. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20198. /**
  20199. * Emits an event when the HMD's pose has been updated.
  20200. */
  20201. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20202. private _poseSet;
  20203. /**
  20204. * If the rig cameras be used as parent instead of this camera.
  20205. */
  20206. rigParenting: boolean;
  20207. private _lightOnControllers;
  20208. private _defaultHeight?;
  20209. /**
  20210. * Instantiates a WebVRFreeCamera.
  20211. * @param name The name of the WebVRFreeCamera
  20212. * @param position The starting anchor position for the camera
  20213. * @param scene The scene the camera belongs to
  20214. * @param webVROptions a set of customizable options for the webVRCamera
  20215. */
  20216. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20217. /**
  20218. * Gets the device distance from the ground in meters.
  20219. * @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.
  20220. */
  20221. deviceDistanceToRoomGround(): number;
  20222. /**
  20223. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20224. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20225. */
  20226. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20227. /**
  20228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20229. * @returns A promise with a boolean set to if the standing matrix is supported.
  20230. */
  20231. useStandingMatrixAsync(): Promise<boolean>;
  20232. /**
  20233. * Disposes the camera
  20234. */
  20235. dispose(): void;
  20236. /**
  20237. * Gets a vrController by name.
  20238. * @param name The name of the controller to retreive
  20239. * @returns the controller matching the name specified or null if not found
  20240. */
  20241. getControllerByName(name: string): Nullable<WebVRController>;
  20242. private _leftController;
  20243. /**
  20244. * The controller corresponding to the users left hand.
  20245. */
  20246. get leftController(): Nullable<WebVRController>;
  20247. private _rightController;
  20248. /**
  20249. * The controller corresponding to the users right hand.
  20250. */
  20251. get rightController(): Nullable<WebVRController>;
  20252. /**
  20253. * Casts a ray forward from the vrCamera's gaze.
  20254. * @param length Length of the ray (default: 100)
  20255. * @returns the ray corresponding to the gaze
  20256. */
  20257. getForwardRay(length?: number): Ray;
  20258. /**
  20259. * @hidden
  20260. * Updates the camera based on device's frame data
  20261. */
  20262. _checkInputs(): void;
  20263. /**
  20264. * Updates the poseControlled values based on the input device pose.
  20265. * @param poseData Pose coming from the device
  20266. */
  20267. updateFromDevice(poseData: DevicePose): void;
  20268. private _htmlElementAttached;
  20269. private _detachIfAttached;
  20270. /**
  20271. * WebVR's attach control will start broadcasting frames to the device.
  20272. * Note that in certain browsers (chrome for example) this function must be called
  20273. * within a user-interaction callback. Example:
  20274. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20275. *
  20276. * @param element html element to attach the vrDevice to
  20277. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20278. */
  20279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20280. /**
  20281. * Detaches the camera from the html element and disables VR
  20282. *
  20283. * @param element html element to detach from
  20284. */
  20285. detachControl(element: HTMLElement): void;
  20286. /**
  20287. * @returns the name of this class
  20288. */
  20289. getClassName(): string;
  20290. /**
  20291. * Calls resetPose on the vrDisplay
  20292. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20293. */
  20294. resetToCurrentRotation(): void;
  20295. /**
  20296. * @hidden
  20297. * Updates the rig cameras (left and right eye)
  20298. */
  20299. _updateRigCameras(): void;
  20300. private _workingVector;
  20301. private _oneVector;
  20302. private _workingMatrix;
  20303. private updateCacheCalled;
  20304. private _correctPositionIfNotTrackPosition;
  20305. /**
  20306. * @hidden
  20307. * Updates the cached values of the camera
  20308. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20309. */
  20310. _updateCache(ignoreParentClass?: boolean): void;
  20311. /**
  20312. * @hidden
  20313. * Get current device position in babylon world
  20314. */
  20315. _computeDevicePosition(): void;
  20316. /**
  20317. * Updates the current device position and rotation in the babylon world
  20318. */
  20319. update(): void;
  20320. /**
  20321. * @hidden
  20322. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20323. * @returns an identity matrix
  20324. */
  20325. _getViewMatrix(): Matrix;
  20326. private _tmpMatrix;
  20327. /**
  20328. * This function is called by the two RIG cameras.
  20329. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20330. * @hidden
  20331. */
  20332. _getWebVRViewMatrix(): Matrix;
  20333. /** @hidden */
  20334. _getWebVRProjectionMatrix(): Matrix;
  20335. private _onGamepadConnectedObserver;
  20336. private _onGamepadDisconnectedObserver;
  20337. private _updateCacheWhenTrackingDisabledObserver;
  20338. /**
  20339. * Initializes the controllers and their meshes
  20340. */
  20341. initControllers(): void;
  20342. }
  20343. }
  20344. declare module BABYLON {
  20345. /**
  20346. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20347. *
  20348. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20349. *
  20350. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20351. */
  20352. export class MaterialHelper {
  20353. /**
  20354. * Bind the current view position to an effect.
  20355. * @param effect The effect to be bound
  20356. * @param scene The scene the eyes position is used from
  20357. * @param variableName name of the shader variable that will hold the eye position
  20358. */
  20359. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20360. /**
  20361. * Helps preparing the defines values about the UVs in used in the effect.
  20362. * UVs are shared as much as we can accross channels in the shaders.
  20363. * @param texture The texture we are preparing the UVs for
  20364. * @param defines The defines to update
  20365. * @param key The channel key "diffuse", "specular"... used in the shader
  20366. */
  20367. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20368. /**
  20369. * Binds a texture matrix value to its corrsponding uniform
  20370. * @param texture The texture to bind the matrix for
  20371. * @param uniformBuffer The uniform buffer receivin the data
  20372. * @param key The channel key "diffuse", "specular"... used in the shader
  20373. */
  20374. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20375. /**
  20376. * Gets the current status of the fog (should it be enabled?)
  20377. * @param mesh defines the mesh to evaluate for fog support
  20378. * @param scene defines the hosting scene
  20379. * @returns true if fog must be enabled
  20380. */
  20381. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20382. /**
  20383. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20384. * @param mesh defines the current mesh
  20385. * @param scene defines the current scene
  20386. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20387. * @param pointsCloud defines if point cloud rendering has to be turned on
  20388. * @param fogEnabled defines if fog has to be turned on
  20389. * @param alphaTest defines if alpha testing has to be turned on
  20390. * @param defines defines the current list of defines
  20391. */
  20392. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20393. /**
  20394. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20395. * @param scene defines the current scene
  20396. * @param engine defines the current engine
  20397. * @param defines specifies the list of active defines
  20398. * @param useInstances defines if instances have to be turned on
  20399. * @param useClipPlane defines if clip plane have to be turned on
  20400. * @param useInstances defines if instances have to be turned on
  20401. * @param useThinInstances defines if thin instances have to be turned on
  20402. */
  20403. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20404. /**
  20405. * Prepares the defines for bones
  20406. * @param mesh The mesh containing the geometry data we will draw
  20407. * @param defines The defines to update
  20408. */
  20409. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20410. /**
  20411. * Prepares the defines for morph targets
  20412. * @param mesh The mesh containing the geometry data we will draw
  20413. * @param defines The defines to update
  20414. */
  20415. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20416. /**
  20417. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20418. * @param mesh The mesh containing the geometry data we will draw
  20419. * @param defines The defines to update
  20420. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20421. * @param useBones Precise whether bones should be used or not (override mesh info)
  20422. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20423. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20424. * @returns false if defines are considered not dirty and have not been checked
  20425. */
  20426. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20427. /**
  20428. * Prepares the defines related to multiview
  20429. * @param scene The scene we are intending to draw
  20430. * @param defines The defines to update
  20431. */
  20432. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20433. /**
  20434. * Prepares the defines related to the prepass
  20435. * @param scene The scene we are intending to draw
  20436. * @param defines The defines to update
  20437. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20438. */
  20439. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20440. /**
  20441. * Prepares the defines related to the light information passed in parameter
  20442. * @param scene The scene we are intending to draw
  20443. * @param mesh The mesh the effect is compiling for
  20444. * @param light The light the effect is compiling for
  20445. * @param lightIndex The index of the light
  20446. * @param defines The defines to update
  20447. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20448. * @param state Defines the current state regarding what is needed (normals, etc...)
  20449. */
  20450. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20451. needNormals: boolean;
  20452. needRebuild: boolean;
  20453. shadowEnabled: boolean;
  20454. specularEnabled: boolean;
  20455. lightmapMode: boolean;
  20456. }): void;
  20457. /**
  20458. * Prepares the defines related to the light information passed in parameter
  20459. * @param scene The scene we are intending to draw
  20460. * @param mesh The mesh the effect is compiling for
  20461. * @param defines The defines to update
  20462. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20463. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20464. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20465. * @returns true if normals will be required for the rest of the effect
  20466. */
  20467. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20468. /**
  20469. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20470. * @param lightIndex defines the light index
  20471. * @param uniformsList The uniform list
  20472. * @param samplersList The sampler list
  20473. * @param projectedLightTexture defines if projected texture must be used
  20474. * @param uniformBuffersList defines an optional list of uniform buffers
  20475. */
  20476. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20477. /**
  20478. * Prepares the uniforms and samplers list to be used in the effect
  20479. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20480. * @param samplersList The sampler list
  20481. * @param defines The defines helping in the list generation
  20482. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20483. */
  20484. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20485. /**
  20486. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20487. * @param defines The defines to update while falling back
  20488. * @param fallbacks The authorized effect fallbacks
  20489. * @param maxSimultaneousLights The maximum number of lights allowed
  20490. * @param rank the current rank of the Effect
  20491. * @returns The newly affected rank
  20492. */
  20493. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20494. private static _TmpMorphInfluencers;
  20495. /**
  20496. * Prepares the list of attributes required for morph targets according to the effect defines.
  20497. * @param attribs The current list of supported attribs
  20498. * @param mesh The mesh to prepare the morph targets attributes for
  20499. * @param influencers The number of influencers
  20500. */
  20501. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20502. /**
  20503. * Prepares the list of attributes required for morph targets according to the effect defines.
  20504. * @param attribs The current list of supported attribs
  20505. * @param mesh The mesh to prepare the morph targets attributes for
  20506. * @param defines The current Defines of the effect
  20507. */
  20508. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20509. /**
  20510. * Prepares the list of attributes required for bones according to the effect defines.
  20511. * @param attribs The current list of supported attribs
  20512. * @param mesh The mesh to prepare the bones attributes for
  20513. * @param defines The current Defines of the effect
  20514. * @param fallbacks The current efffect fallback strategy
  20515. */
  20516. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20517. /**
  20518. * Check and prepare the list of attributes required for instances according to the effect defines.
  20519. * @param attribs The current list of supported attribs
  20520. * @param defines The current MaterialDefines of the effect
  20521. */
  20522. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20523. /**
  20524. * Add the list of attributes required for instances to the attribs array.
  20525. * @param attribs The current list of supported attribs
  20526. */
  20527. static PushAttributesForInstances(attribs: string[]): void;
  20528. /**
  20529. * Binds the light information to the effect.
  20530. * @param light The light containing the generator
  20531. * @param effect The effect we are binding the data to
  20532. * @param lightIndex The light index in the effect used to render
  20533. */
  20534. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20535. /**
  20536. * Binds the lights information from the scene to the effect for the given mesh.
  20537. * @param light Light to bind
  20538. * @param lightIndex Light index
  20539. * @param scene The scene where the light belongs to
  20540. * @param effect The effect we are binding the data to
  20541. * @param useSpecular Defines if specular is supported
  20542. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20543. */
  20544. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20545. /**
  20546. * Binds the lights information from the scene to the effect for the given mesh.
  20547. * @param scene The scene the lights belongs to
  20548. * @param mesh The mesh we are binding the information to render
  20549. * @param effect The effect we are binding the data to
  20550. * @param defines The generated defines for the effect
  20551. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20552. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20553. */
  20554. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20555. private static _tempFogColor;
  20556. /**
  20557. * Binds the fog information from the scene to the effect for the given mesh.
  20558. * @param scene The scene the lights belongs to
  20559. * @param mesh The mesh we are binding the information to render
  20560. * @param effect The effect we are binding the data to
  20561. * @param linearSpace Defines if the fog effect is applied in linear space
  20562. */
  20563. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20564. /**
  20565. * Binds the bones information from the mesh to the effect.
  20566. * @param mesh The mesh we are binding the information to render
  20567. * @param effect The effect we are binding the data to
  20568. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20569. */
  20570. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20571. private static _CopyBonesTransformationMatrices;
  20572. /**
  20573. * Binds the morph targets information from the mesh to the effect.
  20574. * @param abstractMesh The mesh we are binding the information to render
  20575. * @param effect The effect we are binding the data to
  20576. */
  20577. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20578. /**
  20579. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20580. * @param defines The generated defines used in the effect
  20581. * @param effect The effect we are binding the data to
  20582. * @param scene The scene we are willing to render with logarithmic scale for
  20583. */
  20584. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20585. /**
  20586. * Binds the clip plane information from the scene to the effect.
  20587. * @param scene The scene the clip plane information are extracted from
  20588. * @param effect The effect we are binding the data to
  20589. */
  20590. static BindClipPlane(effect: Effect, scene: Scene): void;
  20591. }
  20592. }
  20593. declare module BABYLON {
  20594. /**
  20595. * Block used to expose an input value
  20596. */
  20597. export class InputBlock extends NodeMaterialBlock {
  20598. private _mode;
  20599. private _associatedVariableName;
  20600. private _storedValue;
  20601. private _valueCallback;
  20602. private _type;
  20603. private _animationType;
  20604. /** Gets or set a value used to limit the range of float values */
  20605. min: number;
  20606. /** Gets or set a value used to limit the range of float values */
  20607. max: number;
  20608. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20609. isBoolean: boolean;
  20610. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20611. matrixMode: number;
  20612. /** @hidden */
  20613. _systemValue: Nullable<NodeMaterialSystemValues>;
  20614. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20615. isConstant: boolean;
  20616. /** Gets or sets the group to use to display this block in the Inspector */
  20617. groupInInspector: string;
  20618. /** Gets an observable raised when the value is changed */
  20619. onValueChangedObservable: Observable<InputBlock>;
  20620. /**
  20621. * Gets or sets the connection point type (default is float)
  20622. */
  20623. get type(): NodeMaterialBlockConnectionPointTypes;
  20624. /**
  20625. * Creates a new InputBlock
  20626. * @param name defines the block name
  20627. * @param target defines the target of that block (Vertex by default)
  20628. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20629. */
  20630. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20631. /**
  20632. * Validates if a name is a reserve word.
  20633. * @param newName the new name to be given to the node.
  20634. * @returns false if the name is a reserve word, else true.
  20635. */
  20636. validateBlockName(newName: string): boolean;
  20637. /**
  20638. * Gets the output component
  20639. */
  20640. get output(): NodeMaterialConnectionPoint;
  20641. /**
  20642. * Set the source of this connection point to a vertex attribute
  20643. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20644. * @returns the current connection point
  20645. */
  20646. setAsAttribute(attributeName?: string): InputBlock;
  20647. /**
  20648. * Set the source of this connection point to a system value
  20649. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20650. * @returns the current connection point
  20651. */
  20652. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20653. /**
  20654. * Gets or sets the value of that point.
  20655. * Please note that this value will be ignored if valueCallback is defined
  20656. */
  20657. get value(): any;
  20658. set value(value: any);
  20659. /**
  20660. * Gets or sets a callback used to get the value of that point.
  20661. * Please note that setting this value will force the connection point to ignore the value property
  20662. */
  20663. get valueCallback(): () => any;
  20664. set valueCallback(value: () => any);
  20665. /**
  20666. * Gets or sets the associated variable name in the shader
  20667. */
  20668. get associatedVariableName(): string;
  20669. set associatedVariableName(value: string);
  20670. /** Gets or sets the type of animation applied to the input */
  20671. get animationType(): AnimatedInputBlockTypes;
  20672. set animationType(value: AnimatedInputBlockTypes);
  20673. /**
  20674. * Gets a boolean indicating that this connection point not defined yet
  20675. */
  20676. get isUndefined(): boolean;
  20677. /**
  20678. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20679. * In this case the connection point name must be the name of the uniform to use.
  20680. * Can only be set on inputs
  20681. */
  20682. get isUniform(): boolean;
  20683. set isUniform(value: boolean);
  20684. /**
  20685. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20686. * In this case the connection point name must be the name of the attribute to use
  20687. * Can only be set on inputs
  20688. */
  20689. get isAttribute(): boolean;
  20690. set isAttribute(value: boolean);
  20691. /**
  20692. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20693. * Can only be set on exit points
  20694. */
  20695. get isVarying(): boolean;
  20696. set isVarying(value: boolean);
  20697. /**
  20698. * Gets a boolean indicating that the current connection point is a system value
  20699. */
  20700. get isSystemValue(): boolean;
  20701. /**
  20702. * Gets or sets the current well known value or null if not defined as a system value
  20703. */
  20704. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20705. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20706. /**
  20707. * Gets the current class name
  20708. * @returns the class name
  20709. */
  20710. getClassName(): string;
  20711. /**
  20712. * Animate the input if animationType !== None
  20713. * @param scene defines the rendering scene
  20714. */
  20715. animate(scene: Scene): void;
  20716. private _emitDefine;
  20717. initialize(state: NodeMaterialBuildState): void;
  20718. /**
  20719. * Set the input block to its default value (based on its type)
  20720. */
  20721. setDefaultValue(): void;
  20722. private _emitConstant;
  20723. /** @hidden */
  20724. get _noContextSwitch(): boolean;
  20725. private _emit;
  20726. /** @hidden */
  20727. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20728. /** @hidden */
  20729. _transmit(effect: Effect, scene: Scene): void;
  20730. protected _buildBlock(state: NodeMaterialBuildState): void;
  20731. protected _dumpPropertiesCode(): string;
  20732. dispose(): void;
  20733. serialize(): any;
  20734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20735. }
  20736. }
  20737. declare module BABYLON {
  20738. /**
  20739. * Enum used to define the compatibility state between two connection points
  20740. */
  20741. export enum NodeMaterialConnectionPointCompatibilityStates {
  20742. /** Points are compatibles */
  20743. Compatible = 0,
  20744. /** Points are incompatible because of their types */
  20745. TypeIncompatible = 1,
  20746. /** Points are incompatible because of their targets (vertex vs fragment) */
  20747. TargetIncompatible = 2
  20748. }
  20749. /**
  20750. * Defines the direction of a connection point
  20751. */
  20752. export enum NodeMaterialConnectionPointDirection {
  20753. /** Input */
  20754. Input = 0,
  20755. /** Output */
  20756. Output = 1
  20757. }
  20758. /**
  20759. * Defines a connection point for a block
  20760. */
  20761. export class NodeMaterialConnectionPoint {
  20762. /** @hidden */
  20763. _ownerBlock: NodeMaterialBlock;
  20764. /** @hidden */
  20765. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20766. private _endpoints;
  20767. private _associatedVariableName;
  20768. private _direction;
  20769. /** @hidden */
  20770. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20771. /** @hidden */
  20772. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20773. private _type;
  20774. /** @hidden */
  20775. _enforceAssociatedVariableName: boolean;
  20776. /** Gets the direction of the point */
  20777. get direction(): NodeMaterialConnectionPointDirection;
  20778. /** Indicates that this connection point needs dual validation before being connected to another point */
  20779. needDualDirectionValidation: boolean;
  20780. /**
  20781. * Gets or sets the additional types supported by this connection point
  20782. */
  20783. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20784. /**
  20785. * Gets or sets the additional types excluded by this connection point
  20786. */
  20787. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20788. /**
  20789. * Observable triggered when this point is connected
  20790. */
  20791. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20792. /**
  20793. * Gets or sets the associated variable name in the shader
  20794. */
  20795. get associatedVariableName(): string;
  20796. set associatedVariableName(value: string);
  20797. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20798. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20799. /**
  20800. * Gets or sets the connection point type (default is float)
  20801. */
  20802. get type(): NodeMaterialBlockConnectionPointTypes;
  20803. set type(value: NodeMaterialBlockConnectionPointTypes);
  20804. /**
  20805. * Gets or sets the connection point name
  20806. */
  20807. name: string;
  20808. /**
  20809. * Gets or sets the connection point name
  20810. */
  20811. displayName: string;
  20812. /**
  20813. * Gets or sets a boolean indicating that this connection point can be omitted
  20814. */
  20815. isOptional: boolean;
  20816. /**
  20817. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20818. */
  20819. isExposedOnFrame: boolean;
  20820. /**
  20821. * Gets or sets number indicating the position that the port is exposed to on a frame
  20822. */
  20823. exposedPortPosition: number;
  20824. /**
  20825. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20826. */
  20827. define: string;
  20828. /** @hidden */
  20829. _prioritizeVertex: boolean;
  20830. private _target;
  20831. /** Gets or sets the target of that connection point */
  20832. get target(): NodeMaterialBlockTargets;
  20833. set target(value: NodeMaterialBlockTargets);
  20834. /**
  20835. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20836. */
  20837. get isConnected(): boolean;
  20838. /**
  20839. * Gets a boolean indicating that the current point is connected to an input block
  20840. */
  20841. get isConnectedToInputBlock(): boolean;
  20842. /**
  20843. * Gets a the connected input block (if any)
  20844. */
  20845. get connectInputBlock(): Nullable<InputBlock>;
  20846. /** Get the other side of the connection (if any) */
  20847. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20848. /** Get the block that owns this connection point */
  20849. get ownerBlock(): NodeMaterialBlock;
  20850. /** Get the block connected on the other side of this connection (if any) */
  20851. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20852. /** Get the block connected on the endpoints of this connection (if any) */
  20853. get connectedBlocks(): Array<NodeMaterialBlock>;
  20854. /** Gets the list of connected endpoints */
  20855. get endpoints(): NodeMaterialConnectionPoint[];
  20856. /** Gets a boolean indicating if that output point is connected to at least one input */
  20857. get hasEndpoints(): boolean;
  20858. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20859. get isConnectedInVertexShader(): boolean;
  20860. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20861. get isConnectedInFragmentShader(): boolean;
  20862. /**
  20863. * Creates a block suitable to be used as an input for this input point.
  20864. * If null is returned, a block based on the point type will be created.
  20865. * @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
  20866. */
  20867. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20868. /**
  20869. * Creates a new connection point
  20870. * @param name defines the connection point name
  20871. * @param ownerBlock defines the block hosting this connection point
  20872. * @param direction defines the direction of the connection point
  20873. */
  20874. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20875. /**
  20876. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20877. * @returns the class name
  20878. */
  20879. getClassName(): string;
  20880. /**
  20881. * Gets a boolean indicating if the current point can be connected to another point
  20882. * @param connectionPoint defines the other connection point
  20883. * @returns a boolean
  20884. */
  20885. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20886. /**
  20887. * Gets a number indicating if the current point can be connected to another point
  20888. * @param connectionPoint defines the other connection point
  20889. * @returns a number defining the compatibility state
  20890. */
  20891. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20892. /**
  20893. * Connect this point to another connection point
  20894. * @param connectionPoint defines the other connection point
  20895. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20896. * @returns the current connection point
  20897. */
  20898. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Disconnect this point from one of his endpoint
  20901. * @param endpoint defines the other connection point
  20902. * @returns the current connection point
  20903. */
  20904. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20905. /**
  20906. * Serializes this point in a JSON representation
  20907. * @param isInput defines if the connection point is an input (default is true)
  20908. * @returns the serialized point object
  20909. */
  20910. serialize(isInput?: boolean): any;
  20911. /**
  20912. * Release resources
  20913. */
  20914. dispose(): void;
  20915. }
  20916. }
  20917. declare module BABYLON {
  20918. /**
  20919. * Enum used to define the material modes
  20920. */
  20921. export enum NodeMaterialModes {
  20922. /** Regular material */
  20923. Material = 0,
  20924. /** For post process */
  20925. PostProcess = 1,
  20926. /** For particle system */
  20927. Particle = 2,
  20928. /** For procedural texture */
  20929. ProceduralTexture = 3
  20930. }
  20931. }
  20932. declare module BABYLON {
  20933. /**
  20934. * Block used to read a texture from a sampler
  20935. */
  20936. export class TextureBlock extends NodeMaterialBlock {
  20937. private _defineName;
  20938. private _linearDefineName;
  20939. private _gammaDefineName;
  20940. private _tempTextureRead;
  20941. private _samplerName;
  20942. private _transformedUVName;
  20943. private _textureTransformName;
  20944. private _textureInfoName;
  20945. private _mainUVName;
  20946. private _mainUVDefineName;
  20947. private _fragmentOnly;
  20948. /**
  20949. * Gets or sets the texture associated with the node
  20950. */
  20951. texture: Nullable<Texture>;
  20952. /**
  20953. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20954. */
  20955. convertToGammaSpace: boolean;
  20956. /**
  20957. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20958. */
  20959. convertToLinearSpace: boolean;
  20960. /**
  20961. * Create a new TextureBlock
  20962. * @param name defines the block name
  20963. */
  20964. constructor(name: string, fragmentOnly?: boolean);
  20965. /**
  20966. * Gets the current class name
  20967. * @returns the class name
  20968. */
  20969. getClassName(): string;
  20970. /**
  20971. * Gets the uv input component
  20972. */
  20973. get uv(): NodeMaterialConnectionPoint;
  20974. /**
  20975. * Gets the rgba output component
  20976. */
  20977. get rgba(): NodeMaterialConnectionPoint;
  20978. /**
  20979. * Gets the rgb output component
  20980. */
  20981. get rgb(): NodeMaterialConnectionPoint;
  20982. /**
  20983. * Gets the r output component
  20984. */
  20985. get r(): NodeMaterialConnectionPoint;
  20986. /**
  20987. * Gets the g output component
  20988. */
  20989. get g(): NodeMaterialConnectionPoint;
  20990. /**
  20991. * Gets the b output component
  20992. */
  20993. get b(): NodeMaterialConnectionPoint;
  20994. /**
  20995. * Gets the a output component
  20996. */
  20997. get a(): NodeMaterialConnectionPoint;
  20998. get target(): NodeMaterialBlockTargets;
  20999. autoConfigure(material: NodeMaterial): void;
  21000. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21002. isReady(): boolean;
  21003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21004. private get _isMixed();
  21005. private _injectVertexCode;
  21006. private _writeTextureRead;
  21007. private _writeOutput;
  21008. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21009. protected _dumpPropertiesCode(): string;
  21010. serialize(): any;
  21011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21012. }
  21013. }
  21014. declare module BABYLON {
  21015. /** @hidden */
  21016. export var reflectionFunction: {
  21017. name: string;
  21018. shader: string;
  21019. };
  21020. }
  21021. declare module BABYLON {
  21022. /**
  21023. * Base block used to read a reflection texture from a sampler
  21024. */
  21025. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21026. /** @hidden */
  21027. _define3DName: string;
  21028. /** @hidden */
  21029. _defineCubicName: string;
  21030. /** @hidden */
  21031. _defineExplicitName: string;
  21032. /** @hidden */
  21033. _defineProjectionName: string;
  21034. /** @hidden */
  21035. _defineLocalCubicName: string;
  21036. /** @hidden */
  21037. _defineSphericalName: string;
  21038. /** @hidden */
  21039. _definePlanarName: string;
  21040. /** @hidden */
  21041. _defineEquirectangularName: string;
  21042. /** @hidden */
  21043. _defineMirroredEquirectangularFixedName: string;
  21044. /** @hidden */
  21045. _defineEquirectangularFixedName: string;
  21046. /** @hidden */
  21047. _defineSkyboxName: string;
  21048. /** @hidden */
  21049. _defineOppositeZ: string;
  21050. /** @hidden */
  21051. _cubeSamplerName: string;
  21052. /** @hidden */
  21053. _2DSamplerName: string;
  21054. protected _positionUVWName: string;
  21055. protected _directionWName: string;
  21056. protected _reflectionVectorName: string;
  21057. /** @hidden */
  21058. _reflectionCoordsName: string;
  21059. /** @hidden */
  21060. _reflectionMatrixName: string;
  21061. protected _reflectionColorName: string;
  21062. /**
  21063. * Gets or sets the texture associated with the node
  21064. */
  21065. texture: Nullable<BaseTexture>;
  21066. /**
  21067. * Create a new ReflectionTextureBaseBlock
  21068. * @param name defines the block name
  21069. */
  21070. constructor(name: string);
  21071. /**
  21072. * Gets the current class name
  21073. * @returns the class name
  21074. */
  21075. getClassName(): string;
  21076. /**
  21077. * Gets the world position input component
  21078. */
  21079. abstract get position(): NodeMaterialConnectionPoint;
  21080. /**
  21081. * Gets the world position input component
  21082. */
  21083. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21084. /**
  21085. * Gets the world normal input component
  21086. */
  21087. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21088. /**
  21089. * Gets the world input component
  21090. */
  21091. abstract get world(): NodeMaterialConnectionPoint;
  21092. /**
  21093. * Gets the camera (or eye) position component
  21094. */
  21095. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21096. /**
  21097. * Gets the view input component
  21098. */
  21099. abstract get view(): NodeMaterialConnectionPoint;
  21100. protected _getTexture(): Nullable<BaseTexture>;
  21101. autoConfigure(material: NodeMaterial): void;
  21102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21103. isReady(): boolean;
  21104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21105. /**
  21106. * Gets the code to inject in the vertex shader
  21107. * @param state current state of the node material building
  21108. * @returns the shader code
  21109. */
  21110. handleVertexSide(state: NodeMaterialBuildState): string;
  21111. /**
  21112. * Handles the inits for the fragment code path
  21113. * @param state node material build state
  21114. */
  21115. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21116. /**
  21117. * Generates the reflection coords code for the fragment code path
  21118. * @param worldNormalVarName name of the world normal variable
  21119. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21120. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21121. * @returns the shader code
  21122. */
  21123. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21124. /**
  21125. * Generates the reflection color code for the fragment code path
  21126. * @param lodVarName name of the lod variable
  21127. * @param swizzleLookupTexture swizzle to use for the final color variable
  21128. * @returns the shader code
  21129. */
  21130. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21131. /**
  21132. * Generates the code corresponding to the connected output points
  21133. * @param state node material build state
  21134. * @param varName name of the variable to output
  21135. * @returns the shader code
  21136. */
  21137. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21138. protected _buildBlock(state: NodeMaterialBuildState): this;
  21139. protected _dumpPropertiesCode(): string;
  21140. serialize(): any;
  21141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21142. }
  21143. }
  21144. declare module BABYLON {
  21145. /**
  21146. * Defines a connection point to be used for points with a custom object type
  21147. */
  21148. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21149. private _blockType;
  21150. private _blockName;
  21151. private _nameForCheking?;
  21152. /**
  21153. * Creates a new connection point
  21154. * @param name defines the connection point name
  21155. * @param ownerBlock defines the block hosting this connection point
  21156. * @param direction defines the direction of the connection point
  21157. */
  21158. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21159. /**
  21160. * Gets a number indicating if the current point can be connected to another point
  21161. * @param connectionPoint defines the other connection point
  21162. * @returns a number defining the compatibility state
  21163. */
  21164. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21165. /**
  21166. * Creates a block suitable to be used as an input for this input point.
  21167. * If null is returned, a block based on the point type will be created.
  21168. * @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
  21169. */
  21170. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21171. }
  21172. }
  21173. declare module BABYLON {
  21174. /**
  21175. * Enum defining the type of properties that can be edited in the property pages in the NME
  21176. */
  21177. export enum PropertyTypeForEdition {
  21178. /** property is a boolean */
  21179. Boolean = 0,
  21180. /** property is a float */
  21181. Float = 1,
  21182. /** property is a Vector2 */
  21183. Vector2 = 2,
  21184. /** property is a list of values */
  21185. List = 3
  21186. }
  21187. /**
  21188. * Interface that defines an option in a variable of type list
  21189. */
  21190. export interface IEditablePropertyListOption {
  21191. /** label of the option */
  21192. "label": string;
  21193. /** value of the option */
  21194. "value": number;
  21195. }
  21196. /**
  21197. * Interface that defines the options available for an editable property
  21198. */
  21199. export interface IEditablePropertyOption {
  21200. /** min value */
  21201. "min"?: number;
  21202. /** max value */
  21203. "max"?: number;
  21204. /** notifiers: indicates which actions to take when the property is changed */
  21205. "notifiers"?: {
  21206. /** the material should be rebuilt */
  21207. "rebuild"?: boolean;
  21208. /** the preview should be updated */
  21209. "update"?: boolean;
  21210. };
  21211. /** list of the options for a variable of type list */
  21212. "options"?: IEditablePropertyListOption[];
  21213. }
  21214. /**
  21215. * Interface that describes an editable property
  21216. */
  21217. export interface IPropertyDescriptionForEdition {
  21218. /** name of the property */
  21219. "propertyName": string;
  21220. /** display name of the property */
  21221. "displayName": string;
  21222. /** type of the property */
  21223. "type": PropertyTypeForEdition;
  21224. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21225. "groupName": string;
  21226. /** options for the property */
  21227. "options": IEditablePropertyOption;
  21228. }
  21229. /**
  21230. * Decorator that flags a property in a node material block as being editable
  21231. */
  21232. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21233. }
  21234. declare module BABYLON {
  21235. /**
  21236. * Block used to implement the refraction part of the sub surface module of the PBR material
  21237. */
  21238. export class RefractionBlock extends NodeMaterialBlock {
  21239. /** @hidden */
  21240. _define3DName: string;
  21241. /** @hidden */
  21242. _refractionMatrixName: string;
  21243. /** @hidden */
  21244. _defineLODRefractionAlpha: string;
  21245. /** @hidden */
  21246. _defineLinearSpecularRefraction: string;
  21247. /** @hidden */
  21248. _defineOppositeZ: string;
  21249. /** @hidden */
  21250. _cubeSamplerName: string;
  21251. /** @hidden */
  21252. _2DSamplerName: string;
  21253. /** @hidden */
  21254. _vRefractionMicrosurfaceInfosName: string;
  21255. /** @hidden */
  21256. _vRefractionInfosName: string;
  21257. private _scene;
  21258. /**
  21259. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21260. * Materials half opaque for instance using refraction could benefit from this control.
  21261. */
  21262. linkRefractionWithTransparency: boolean;
  21263. /**
  21264. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21265. */
  21266. invertRefractionY: boolean;
  21267. /**
  21268. * Gets or sets the texture associated with the node
  21269. */
  21270. texture: Nullable<BaseTexture>;
  21271. /**
  21272. * Create a new RefractionBlock
  21273. * @param name defines the block name
  21274. */
  21275. constructor(name: string);
  21276. /**
  21277. * Gets the current class name
  21278. * @returns the class name
  21279. */
  21280. getClassName(): string;
  21281. /**
  21282. * Gets the intensity input component
  21283. */
  21284. get intensity(): NodeMaterialConnectionPoint;
  21285. /**
  21286. * Gets the index of refraction input component
  21287. */
  21288. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21289. /**
  21290. * Gets the tint at distance input component
  21291. */
  21292. get tintAtDistance(): NodeMaterialConnectionPoint;
  21293. /**
  21294. * Gets the view input component
  21295. */
  21296. get view(): NodeMaterialConnectionPoint;
  21297. /**
  21298. * Gets the refraction object output component
  21299. */
  21300. get refraction(): NodeMaterialConnectionPoint;
  21301. /**
  21302. * Returns true if the block has a texture
  21303. */
  21304. get hasTexture(): boolean;
  21305. protected _getTexture(): Nullable<BaseTexture>;
  21306. autoConfigure(material: NodeMaterial): void;
  21307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21308. isReady(): boolean;
  21309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21310. /**
  21311. * Gets the main code of the block (fragment side)
  21312. * @param state current state of the node material building
  21313. * @returns the shader code
  21314. */
  21315. getCode(state: NodeMaterialBuildState): string;
  21316. protected _buildBlock(state: NodeMaterialBuildState): this;
  21317. protected _dumpPropertiesCode(): string;
  21318. serialize(): any;
  21319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21320. }
  21321. }
  21322. declare module BABYLON {
  21323. /**
  21324. * Base block used as input for post process
  21325. */
  21326. export class CurrentScreenBlock extends NodeMaterialBlock {
  21327. private _samplerName;
  21328. private _linearDefineName;
  21329. private _gammaDefineName;
  21330. private _mainUVName;
  21331. private _tempTextureRead;
  21332. /**
  21333. * Gets or sets the texture associated with the node
  21334. */
  21335. texture: Nullable<BaseTexture>;
  21336. /**
  21337. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21338. */
  21339. convertToGammaSpace: boolean;
  21340. /**
  21341. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21342. */
  21343. convertToLinearSpace: boolean;
  21344. /**
  21345. * Create a new CurrentScreenBlock
  21346. * @param name defines the block name
  21347. */
  21348. constructor(name: string);
  21349. /**
  21350. * Gets the current class name
  21351. * @returns the class name
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Gets the uv input component
  21356. */
  21357. get uv(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the rgba output component
  21360. */
  21361. get rgba(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Gets the rgb output component
  21364. */
  21365. get rgb(): NodeMaterialConnectionPoint;
  21366. /**
  21367. * Gets the r output component
  21368. */
  21369. get r(): NodeMaterialConnectionPoint;
  21370. /**
  21371. * Gets the g output component
  21372. */
  21373. get g(): NodeMaterialConnectionPoint;
  21374. /**
  21375. * Gets the b output component
  21376. */
  21377. get b(): NodeMaterialConnectionPoint;
  21378. /**
  21379. * Gets the a output component
  21380. */
  21381. get a(): NodeMaterialConnectionPoint;
  21382. /**
  21383. * Initialize the block and prepare the context for build
  21384. * @param state defines the state that will be used for the build
  21385. */
  21386. initialize(state: NodeMaterialBuildState): void;
  21387. get target(): NodeMaterialBlockTargets;
  21388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21389. isReady(): boolean;
  21390. private _injectVertexCode;
  21391. private _writeTextureRead;
  21392. private _writeOutput;
  21393. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21394. serialize(): any;
  21395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21396. }
  21397. }
  21398. declare module BABYLON {
  21399. /**
  21400. * Base block used for the particle texture
  21401. */
  21402. export class ParticleTextureBlock extends NodeMaterialBlock {
  21403. private _samplerName;
  21404. private _linearDefineName;
  21405. private _gammaDefineName;
  21406. private _tempTextureRead;
  21407. /**
  21408. * Gets or sets the texture associated with the node
  21409. */
  21410. texture: Nullable<BaseTexture>;
  21411. /**
  21412. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21413. */
  21414. convertToGammaSpace: boolean;
  21415. /**
  21416. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21417. */
  21418. convertToLinearSpace: boolean;
  21419. /**
  21420. * Create a new ParticleTextureBlock
  21421. * @param name defines the block name
  21422. */
  21423. constructor(name: string);
  21424. /**
  21425. * Gets the current class name
  21426. * @returns the class name
  21427. */
  21428. getClassName(): string;
  21429. /**
  21430. * Gets the uv input component
  21431. */
  21432. get uv(): NodeMaterialConnectionPoint;
  21433. /**
  21434. * Gets the rgba output component
  21435. */
  21436. get rgba(): NodeMaterialConnectionPoint;
  21437. /**
  21438. * Gets the rgb output component
  21439. */
  21440. get rgb(): NodeMaterialConnectionPoint;
  21441. /**
  21442. * Gets the r output component
  21443. */
  21444. get r(): NodeMaterialConnectionPoint;
  21445. /**
  21446. * Gets the g output component
  21447. */
  21448. get g(): NodeMaterialConnectionPoint;
  21449. /**
  21450. * Gets the b output component
  21451. */
  21452. get b(): NodeMaterialConnectionPoint;
  21453. /**
  21454. * Gets the a output component
  21455. */
  21456. get a(): NodeMaterialConnectionPoint;
  21457. /**
  21458. * Initialize the block and prepare the context for build
  21459. * @param state defines the state that will be used for the build
  21460. */
  21461. initialize(state: NodeMaterialBuildState): void;
  21462. autoConfigure(material: NodeMaterial): void;
  21463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21464. isReady(): boolean;
  21465. private _writeOutput;
  21466. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21467. serialize(): any;
  21468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21469. }
  21470. }
  21471. declare module BABYLON {
  21472. /**
  21473. * Class used to store shared data between 2 NodeMaterialBuildState
  21474. */
  21475. export class NodeMaterialBuildStateSharedData {
  21476. /**
  21477. * Gets the list of emitted varyings
  21478. */
  21479. temps: string[];
  21480. /**
  21481. * Gets the list of emitted varyings
  21482. */
  21483. varyings: string[];
  21484. /**
  21485. * Gets the varying declaration string
  21486. */
  21487. varyingDeclaration: string;
  21488. /**
  21489. * Input blocks
  21490. */
  21491. inputBlocks: InputBlock[];
  21492. /**
  21493. * Input blocks
  21494. */
  21495. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21496. /**
  21497. * Bindable blocks (Blocks that need to set data to the effect)
  21498. */
  21499. bindableBlocks: NodeMaterialBlock[];
  21500. /**
  21501. * List of blocks that can provide a compilation fallback
  21502. */
  21503. blocksWithFallbacks: NodeMaterialBlock[];
  21504. /**
  21505. * List of blocks that can provide a define update
  21506. */
  21507. blocksWithDefines: NodeMaterialBlock[];
  21508. /**
  21509. * List of blocks that can provide a repeatable content
  21510. */
  21511. repeatableContentBlocks: NodeMaterialBlock[];
  21512. /**
  21513. * List of blocks that can provide a dynamic list of uniforms
  21514. */
  21515. dynamicUniformBlocks: NodeMaterialBlock[];
  21516. /**
  21517. * List of blocks that can block the isReady function for the material
  21518. */
  21519. blockingBlocks: NodeMaterialBlock[];
  21520. /**
  21521. * Gets the list of animated inputs
  21522. */
  21523. animatedInputs: InputBlock[];
  21524. /**
  21525. * Build Id used to avoid multiple recompilations
  21526. */
  21527. buildId: number;
  21528. /** List of emitted variables */
  21529. variableNames: {
  21530. [key: string]: number;
  21531. };
  21532. /** List of emitted defines */
  21533. defineNames: {
  21534. [key: string]: number;
  21535. };
  21536. /** Should emit comments? */
  21537. emitComments: boolean;
  21538. /** Emit build activity */
  21539. verbose: boolean;
  21540. /** Gets or sets the hosting scene */
  21541. scene: Scene;
  21542. /**
  21543. * Gets the compilation hints emitted at compilation time
  21544. */
  21545. hints: {
  21546. needWorldViewMatrix: boolean;
  21547. needWorldViewProjectionMatrix: boolean;
  21548. needAlphaBlending: boolean;
  21549. needAlphaTesting: boolean;
  21550. };
  21551. /**
  21552. * List of compilation checks
  21553. */
  21554. checks: {
  21555. emitVertex: boolean;
  21556. emitFragment: boolean;
  21557. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21558. };
  21559. /**
  21560. * Is vertex program allowed to be empty?
  21561. */
  21562. allowEmptyVertexProgram: boolean;
  21563. /** Creates a new shared data */
  21564. constructor();
  21565. /**
  21566. * Emits console errors and exceptions if there is a failing check
  21567. */
  21568. emitErrors(): void;
  21569. }
  21570. }
  21571. declare module BABYLON {
  21572. /**
  21573. * Class used to store node based material build state
  21574. */
  21575. export class NodeMaterialBuildState {
  21576. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21577. supportUniformBuffers: boolean;
  21578. /**
  21579. * Gets the list of emitted attributes
  21580. */
  21581. attributes: string[];
  21582. /**
  21583. * Gets the list of emitted uniforms
  21584. */
  21585. uniforms: string[];
  21586. /**
  21587. * Gets the list of emitted constants
  21588. */
  21589. constants: string[];
  21590. /**
  21591. * Gets the list of emitted samplers
  21592. */
  21593. samplers: string[];
  21594. /**
  21595. * Gets the list of emitted functions
  21596. */
  21597. functions: {
  21598. [key: string]: string;
  21599. };
  21600. /**
  21601. * Gets the list of emitted extensions
  21602. */
  21603. extensions: {
  21604. [key: string]: string;
  21605. };
  21606. /**
  21607. * Gets the target of the compilation state
  21608. */
  21609. target: NodeMaterialBlockTargets;
  21610. /**
  21611. * Gets the list of emitted counters
  21612. */
  21613. counters: {
  21614. [key: string]: number;
  21615. };
  21616. /**
  21617. * Shared data between multiple NodeMaterialBuildState instances
  21618. */
  21619. sharedData: NodeMaterialBuildStateSharedData;
  21620. /** @hidden */
  21621. _vertexState: NodeMaterialBuildState;
  21622. /** @hidden */
  21623. _attributeDeclaration: string;
  21624. /** @hidden */
  21625. _uniformDeclaration: string;
  21626. /** @hidden */
  21627. _constantDeclaration: string;
  21628. /** @hidden */
  21629. _samplerDeclaration: string;
  21630. /** @hidden */
  21631. _varyingTransfer: string;
  21632. /** @hidden */
  21633. _injectAtEnd: string;
  21634. private _repeatableContentAnchorIndex;
  21635. /** @hidden */
  21636. _builtCompilationString: string;
  21637. /**
  21638. * Gets the emitted compilation strings
  21639. */
  21640. compilationString: string;
  21641. /**
  21642. * Finalize the compilation strings
  21643. * @param state defines the current compilation state
  21644. */
  21645. finalize(state: NodeMaterialBuildState): void;
  21646. /** @hidden */
  21647. get _repeatableContentAnchor(): string;
  21648. /** @hidden */
  21649. _getFreeVariableName(prefix: string): string;
  21650. /** @hidden */
  21651. _getFreeDefineName(prefix: string): string;
  21652. /** @hidden */
  21653. _excludeVariableName(name: string): void;
  21654. /** @hidden */
  21655. _emit2DSampler(name: string): void;
  21656. /** @hidden */
  21657. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21658. /** @hidden */
  21659. _emitExtension(name: string, extension: string, define?: string): void;
  21660. /** @hidden */
  21661. _emitFunction(name: string, code: string, comments: string): void;
  21662. /** @hidden */
  21663. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21664. replaceStrings?: {
  21665. search: RegExp;
  21666. replace: string;
  21667. }[];
  21668. repeatKey?: string;
  21669. }): string;
  21670. /** @hidden */
  21671. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21672. repeatKey?: string;
  21673. removeAttributes?: boolean;
  21674. removeUniforms?: boolean;
  21675. removeVaryings?: boolean;
  21676. removeIfDef?: boolean;
  21677. replaceStrings?: {
  21678. search: RegExp;
  21679. replace: string;
  21680. }[];
  21681. }, storeKey?: string): void;
  21682. /** @hidden */
  21683. _registerTempVariable(name: string): boolean;
  21684. /** @hidden */
  21685. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21686. /** @hidden */
  21687. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21688. /** @hidden */
  21689. _emitFloat(value: number): string;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. /**
  21694. * Helper class used to generate session unique ID
  21695. */
  21696. export class UniqueIdGenerator {
  21697. private static _UniqueIdCounter;
  21698. /**
  21699. * Gets an unique (relatively to the current scene) Id
  21700. */
  21701. static get UniqueId(): number;
  21702. }
  21703. }
  21704. declare module BABYLON {
  21705. /**
  21706. * Defines a block that can be used inside a node based material
  21707. */
  21708. export class NodeMaterialBlock {
  21709. private _buildId;
  21710. private _buildTarget;
  21711. private _target;
  21712. private _isFinalMerger;
  21713. private _isInput;
  21714. private _name;
  21715. protected _isUnique: boolean;
  21716. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21717. inputsAreExclusive: boolean;
  21718. /** @hidden */
  21719. _codeVariableName: string;
  21720. /** @hidden */
  21721. _inputs: NodeMaterialConnectionPoint[];
  21722. /** @hidden */
  21723. _outputs: NodeMaterialConnectionPoint[];
  21724. /** @hidden */
  21725. _preparationId: number;
  21726. /**
  21727. * Gets the name of the block
  21728. */
  21729. get name(): string;
  21730. /**
  21731. * Sets the name of the block. Will check if the name is valid.
  21732. */
  21733. set name(newName: string);
  21734. /**
  21735. * Gets or sets the unique id of the node
  21736. */
  21737. uniqueId: number;
  21738. /**
  21739. * Gets or sets the comments associated with this block
  21740. */
  21741. comments: string;
  21742. /**
  21743. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21744. */
  21745. get isUnique(): boolean;
  21746. /**
  21747. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21748. */
  21749. get isFinalMerger(): boolean;
  21750. /**
  21751. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21752. */
  21753. get isInput(): boolean;
  21754. /**
  21755. * Gets or sets the build Id
  21756. */
  21757. get buildId(): number;
  21758. set buildId(value: number);
  21759. /**
  21760. * Gets or sets the target of the block
  21761. */
  21762. get target(): NodeMaterialBlockTargets;
  21763. set target(value: NodeMaterialBlockTargets);
  21764. /**
  21765. * Gets the list of input points
  21766. */
  21767. get inputs(): NodeMaterialConnectionPoint[];
  21768. /** Gets the list of output points */
  21769. get outputs(): NodeMaterialConnectionPoint[];
  21770. /**
  21771. * Find an input by its name
  21772. * @param name defines the name of the input to look for
  21773. * @returns the input or null if not found
  21774. */
  21775. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21776. /**
  21777. * Find an output by its name
  21778. * @param name defines the name of the outputto look for
  21779. * @returns the output or null if not found
  21780. */
  21781. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21782. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21783. visibleInInspector: boolean;
  21784. /**
  21785. * Creates a new NodeMaterialBlock
  21786. * @param name defines the block name
  21787. * @param target defines the target of that block (Vertex by default)
  21788. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21789. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21790. */
  21791. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21792. /**
  21793. * Initialize the block and prepare the context for build
  21794. * @param state defines the state that will be used for the build
  21795. */
  21796. initialize(state: NodeMaterialBuildState): void;
  21797. /**
  21798. * Bind data to effect. Will only be called for blocks with isBindable === true
  21799. * @param effect defines the effect to bind data to
  21800. * @param nodeMaterial defines the hosting NodeMaterial
  21801. * @param mesh defines the mesh that will be rendered
  21802. * @param subMesh defines the submesh that will be rendered
  21803. */
  21804. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21805. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21806. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21807. protected _writeFloat(value: number): string;
  21808. /**
  21809. * Gets the current class name e.g. "NodeMaterialBlock"
  21810. * @returns the class name
  21811. */
  21812. getClassName(): string;
  21813. /**
  21814. * Register a new input. Must be called inside a block constructor
  21815. * @param name defines the connection point name
  21816. * @param type defines the connection point type
  21817. * @param isOptional defines a boolean indicating that this input can be omitted
  21818. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21819. * @param point an already created connection point. If not provided, create a new one
  21820. * @returns the current block
  21821. */
  21822. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21823. /**
  21824. * Register a new output. Must be called inside a block constructor
  21825. * @param name defines the connection point name
  21826. * @param type defines the connection point type
  21827. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21828. * @param point an already created connection point. If not provided, create a new one
  21829. * @returns the current block
  21830. */
  21831. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21832. /**
  21833. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21834. * @param forOutput defines an optional connection point to check compatibility with
  21835. * @returns the first available input or null
  21836. */
  21837. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21838. /**
  21839. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21840. * @param forBlock defines an optional block to check compatibility with
  21841. * @returns the first available input or null
  21842. */
  21843. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21844. /**
  21845. * Gets the sibling of the given output
  21846. * @param current defines the current output
  21847. * @returns the next output in the list or null
  21848. */
  21849. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21850. /**
  21851. * Connect current block with another block
  21852. * @param other defines the block to connect with
  21853. * @param options define the various options to help pick the right connections
  21854. * @returns the current block
  21855. */
  21856. connectTo(other: NodeMaterialBlock, options?: {
  21857. input?: string;
  21858. output?: string;
  21859. outputSwizzle?: string;
  21860. }): this | undefined;
  21861. protected _buildBlock(state: NodeMaterialBuildState): void;
  21862. /**
  21863. * Add uniforms, samplers and uniform buffers at compilation time
  21864. * @param state defines the state to update
  21865. * @param nodeMaterial defines the node material requesting the update
  21866. * @param defines defines the material defines to update
  21867. * @param uniformBuffers defines the list of uniform buffer names
  21868. */
  21869. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21870. /**
  21871. * Add potential fallbacks if shader compilation fails
  21872. * @param mesh defines the mesh to be rendered
  21873. * @param fallbacks defines the current prioritized list of fallbacks
  21874. */
  21875. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21876. /**
  21877. * Initialize defines for shader compilation
  21878. * @param mesh defines the mesh to be rendered
  21879. * @param nodeMaterial defines the node material requesting the update
  21880. * @param defines defines the material defines to update
  21881. * @param useInstances specifies that instances should be used
  21882. */
  21883. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21884. /**
  21885. * Update defines for shader compilation
  21886. * @param mesh defines the mesh to be rendered
  21887. * @param nodeMaterial defines the node material requesting the update
  21888. * @param defines defines the material defines to update
  21889. * @param useInstances specifies that instances should be used
  21890. * @param subMesh defines which submesh to render
  21891. */
  21892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21893. /**
  21894. * Lets the block try to connect some inputs automatically
  21895. * @param material defines the hosting NodeMaterial
  21896. */
  21897. autoConfigure(material: NodeMaterial): void;
  21898. /**
  21899. * Function called when a block is declared as repeatable content generator
  21900. * @param vertexShaderState defines the current compilation state for the vertex shader
  21901. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21902. * @param mesh defines the mesh to be rendered
  21903. * @param defines defines the material defines to update
  21904. */
  21905. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21906. /**
  21907. * Checks if the block is ready
  21908. * @param mesh defines the mesh to be rendered
  21909. * @param nodeMaterial defines the node material requesting the update
  21910. * @param defines defines the material defines to update
  21911. * @param useInstances specifies that instances should be used
  21912. * @returns true if the block is ready
  21913. */
  21914. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21915. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21916. private _processBuild;
  21917. /**
  21918. * Validates the new name for the block node.
  21919. * @param newName the new name to be given to the node.
  21920. * @returns false if the name is a reserve word, else true.
  21921. */
  21922. validateBlockName(newName: string): boolean;
  21923. /**
  21924. * Compile the current node and generate the shader code
  21925. * @param state defines the current compilation state (uniforms, samplers, current string)
  21926. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21927. * @returns true if already built
  21928. */
  21929. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21930. protected _inputRename(name: string): string;
  21931. protected _outputRename(name: string): string;
  21932. protected _dumpPropertiesCode(): string;
  21933. /** @hidden */
  21934. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21935. /** @hidden */
  21936. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21937. /**
  21938. * Clone the current block to a new identical block
  21939. * @param scene defines the hosting scene
  21940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21941. * @returns a copy of the current block
  21942. */
  21943. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21944. /**
  21945. * Serializes this block in a JSON representation
  21946. * @returns the serialized block object
  21947. */
  21948. serialize(): any;
  21949. /** @hidden */
  21950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21951. private _deserializePortDisplayNamesAndExposedOnFrame;
  21952. /**
  21953. * Release resources
  21954. */
  21955. dispose(): void;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /**
  21960. * Base class of materials working in push mode in babylon JS
  21961. * @hidden
  21962. */
  21963. export class PushMaterial extends Material {
  21964. protected _activeEffect: Effect;
  21965. protected _normalMatrix: Matrix;
  21966. constructor(name: string, scene: Scene);
  21967. getEffect(): Effect;
  21968. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21969. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21970. /**
  21971. * Binds the given world matrix to the active effect
  21972. *
  21973. * @param world the matrix to bind
  21974. */
  21975. bindOnlyWorldMatrix(world: Matrix): void;
  21976. /**
  21977. * Binds the given normal matrix to the active effect
  21978. *
  21979. * @param normalMatrix the matrix to bind
  21980. */
  21981. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21982. bind(world: Matrix, mesh?: Mesh): void;
  21983. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21984. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21985. }
  21986. }
  21987. declare module BABYLON {
  21988. /**
  21989. * Root class for all node material optimizers
  21990. */
  21991. export class NodeMaterialOptimizer {
  21992. /**
  21993. * Function used to optimize a NodeMaterial graph
  21994. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21995. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21996. */
  21997. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21998. }
  21999. }
  22000. declare module BABYLON {
  22001. /**
  22002. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22003. */
  22004. export class TransformBlock extends NodeMaterialBlock {
  22005. /**
  22006. * Defines the value to use to complement W value to transform it to a Vector4
  22007. */
  22008. complementW: number;
  22009. /**
  22010. * Defines the value to use to complement z value to transform it to a Vector4
  22011. */
  22012. complementZ: number;
  22013. /**
  22014. * Creates a new TransformBlock
  22015. * @param name defines the block name
  22016. */
  22017. constructor(name: string);
  22018. /**
  22019. * Gets the current class name
  22020. * @returns the class name
  22021. */
  22022. getClassName(): string;
  22023. /**
  22024. * Gets the vector input
  22025. */
  22026. get vector(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the output component
  22029. */
  22030. get output(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Gets the xyz output component
  22033. */
  22034. get xyz(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the matrix transform input
  22037. */
  22038. get transform(): NodeMaterialConnectionPoint;
  22039. protected _buildBlock(state: NodeMaterialBuildState): this;
  22040. /**
  22041. * Update defines for shader compilation
  22042. * @param mesh defines the mesh to be rendered
  22043. * @param nodeMaterial defines the node material requesting the update
  22044. * @param defines defines the material defines to update
  22045. * @param useInstances specifies that instances should be used
  22046. * @param subMesh defines which submesh to render
  22047. */
  22048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22049. serialize(): any;
  22050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22051. protected _dumpPropertiesCode(): string;
  22052. }
  22053. }
  22054. declare module BABYLON {
  22055. /**
  22056. * Block used to output the vertex position
  22057. */
  22058. export class VertexOutputBlock extends NodeMaterialBlock {
  22059. /**
  22060. * Creates a new VertexOutputBlock
  22061. * @param name defines the block name
  22062. */
  22063. constructor(name: string);
  22064. /**
  22065. * Gets the current class name
  22066. * @returns the class name
  22067. */
  22068. getClassName(): string;
  22069. /**
  22070. * Gets the vector input component
  22071. */
  22072. get vector(): NodeMaterialConnectionPoint;
  22073. protected _buildBlock(state: NodeMaterialBuildState): this;
  22074. }
  22075. }
  22076. declare module BABYLON {
  22077. /**
  22078. * Block used to output the final color
  22079. */
  22080. export class FragmentOutputBlock extends NodeMaterialBlock {
  22081. /**
  22082. * Create a new FragmentOutputBlock
  22083. * @param name defines the block name
  22084. */
  22085. constructor(name: string);
  22086. /**
  22087. * Gets the current class name
  22088. * @returns the class name
  22089. */
  22090. getClassName(): string;
  22091. /**
  22092. * Gets the rgba input component
  22093. */
  22094. get rgba(): NodeMaterialConnectionPoint;
  22095. /**
  22096. * Gets the rgb input component
  22097. */
  22098. get rgb(): NodeMaterialConnectionPoint;
  22099. /**
  22100. * Gets the a input component
  22101. */
  22102. get a(): NodeMaterialConnectionPoint;
  22103. protected _buildBlock(state: NodeMaterialBuildState): this;
  22104. }
  22105. }
  22106. declare module BABYLON {
  22107. /**
  22108. * Block used for the particle ramp gradient section
  22109. */
  22110. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22111. /**
  22112. * Create a new ParticleRampGradientBlock
  22113. * @param name defines the block name
  22114. */
  22115. constructor(name: string);
  22116. /**
  22117. * Gets the current class name
  22118. * @returns the class name
  22119. */
  22120. getClassName(): string;
  22121. /**
  22122. * Gets the color input component
  22123. */
  22124. get color(): NodeMaterialConnectionPoint;
  22125. /**
  22126. * Gets the rampColor output component
  22127. */
  22128. get rampColor(): NodeMaterialConnectionPoint;
  22129. /**
  22130. * Initialize the block and prepare the context for build
  22131. * @param state defines the state that will be used for the build
  22132. */
  22133. initialize(state: NodeMaterialBuildState): void;
  22134. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22135. }
  22136. }
  22137. declare module BABYLON {
  22138. /**
  22139. * Block used for the particle blend multiply section
  22140. */
  22141. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22142. /**
  22143. * Create a new ParticleBlendMultiplyBlock
  22144. * @param name defines the block name
  22145. */
  22146. constructor(name: string);
  22147. /**
  22148. * Gets the current class name
  22149. * @returns the class name
  22150. */
  22151. getClassName(): string;
  22152. /**
  22153. * Gets the color input component
  22154. */
  22155. get color(): NodeMaterialConnectionPoint;
  22156. /**
  22157. * Gets the alphaTexture input component
  22158. */
  22159. get alphaTexture(): NodeMaterialConnectionPoint;
  22160. /**
  22161. * Gets the alphaColor input component
  22162. */
  22163. get alphaColor(): NodeMaterialConnectionPoint;
  22164. /**
  22165. * Gets the blendColor output component
  22166. */
  22167. get blendColor(): NodeMaterialConnectionPoint;
  22168. /**
  22169. * Initialize the block and prepare the context for build
  22170. * @param state defines the state that will be used for the build
  22171. */
  22172. initialize(state: NodeMaterialBuildState): void;
  22173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22174. }
  22175. }
  22176. declare module BABYLON {
  22177. /**
  22178. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22179. */
  22180. export class VectorMergerBlock extends NodeMaterialBlock {
  22181. /**
  22182. * Create a new VectorMergerBlock
  22183. * @param name defines the block name
  22184. */
  22185. constructor(name: string);
  22186. /**
  22187. * Gets the current class name
  22188. * @returns the class name
  22189. */
  22190. getClassName(): string;
  22191. /**
  22192. * Gets the xyz component (input)
  22193. */
  22194. get xyzIn(): NodeMaterialConnectionPoint;
  22195. /**
  22196. * Gets the xy component (input)
  22197. */
  22198. get xyIn(): NodeMaterialConnectionPoint;
  22199. /**
  22200. * Gets the x component (input)
  22201. */
  22202. get x(): NodeMaterialConnectionPoint;
  22203. /**
  22204. * Gets the y component (input)
  22205. */
  22206. get y(): NodeMaterialConnectionPoint;
  22207. /**
  22208. * Gets the z component (input)
  22209. */
  22210. get z(): NodeMaterialConnectionPoint;
  22211. /**
  22212. * Gets the w component (input)
  22213. */
  22214. get w(): NodeMaterialConnectionPoint;
  22215. /**
  22216. * Gets the xyzw component (output)
  22217. */
  22218. get xyzw(): NodeMaterialConnectionPoint;
  22219. /**
  22220. * Gets the xyz component (output)
  22221. */
  22222. get xyzOut(): NodeMaterialConnectionPoint;
  22223. /**
  22224. * Gets the xy component (output)
  22225. */
  22226. get xyOut(): NodeMaterialConnectionPoint;
  22227. /**
  22228. * Gets the xy component (output)
  22229. * @deprecated Please use xyOut instead.
  22230. */
  22231. get xy(): NodeMaterialConnectionPoint;
  22232. /**
  22233. * Gets the xyz component (output)
  22234. * @deprecated Please use xyzOut instead.
  22235. */
  22236. get xyz(): NodeMaterialConnectionPoint;
  22237. protected _buildBlock(state: NodeMaterialBuildState): this;
  22238. }
  22239. }
  22240. declare module BABYLON {
  22241. /**
  22242. * Block used to remap a float from a range to a new one
  22243. */
  22244. export class RemapBlock extends NodeMaterialBlock {
  22245. /**
  22246. * Gets or sets the source range
  22247. */
  22248. sourceRange: Vector2;
  22249. /**
  22250. * Gets or sets the target range
  22251. */
  22252. targetRange: Vector2;
  22253. /**
  22254. * Creates a new RemapBlock
  22255. * @param name defines the block name
  22256. */
  22257. constructor(name: string);
  22258. /**
  22259. * Gets the current class name
  22260. * @returns the class name
  22261. */
  22262. getClassName(): string;
  22263. /**
  22264. * Gets the input component
  22265. */
  22266. get input(): NodeMaterialConnectionPoint;
  22267. /**
  22268. * Gets the source min input component
  22269. */
  22270. get sourceMin(): NodeMaterialConnectionPoint;
  22271. /**
  22272. * Gets the source max input component
  22273. */
  22274. get sourceMax(): NodeMaterialConnectionPoint;
  22275. /**
  22276. * Gets the target min input component
  22277. */
  22278. get targetMin(): NodeMaterialConnectionPoint;
  22279. /**
  22280. * Gets the target max input component
  22281. */
  22282. get targetMax(): NodeMaterialConnectionPoint;
  22283. /**
  22284. * Gets the output component
  22285. */
  22286. get output(): NodeMaterialConnectionPoint;
  22287. protected _buildBlock(state: NodeMaterialBuildState): this;
  22288. protected _dumpPropertiesCode(): string;
  22289. serialize(): any;
  22290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22291. }
  22292. }
  22293. declare module BABYLON {
  22294. /**
  22295. * Block used to multiply 2 values
  22296. */
  22297. export class MultiplyBlock extends NodeMaterialBlock {
  22298. /**
  22299. * Creates a new MultiplyBlock
  22300. * @param name defines the block name
  22301. */
  22302. constructor(name: string);
  22303. /**
  22304. * Gets the current class name
  22305. * @returns the class name
  22306. */
  22307. getClassName(): string;
  22308. /**
  22309. * Gets the left operand input component
  22310. */
  22311. get left(): NodeMaterialConnectionPoint;
  22312. /**
  22313. * Gets the right operand input component
  22314. */
  22315. get right(): NodeMaterialConnectionPoint;
  22316. /**
  22317. * Gets the output component
  22318. */
  22319. get output(): NodeMaterialConnectionPoint;
  22320. protected _buildBlock(state: NodeMaterialBuildState): this;
  22321. }
  22322. }
  22323. declare module BABYLON {
  22324. /**
  22325. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22326. */
  22327. export class ColorSplitterBlock extends NodeMaterialBlock {
  22328. /**
  22329. * Create a new ColorSplitterBlock
  22330. * @param name defines the block name
  22331. */
  22332. constructor(name: string);
  22333. /**
  22334. * Gets the current class name
  22335. * @returns the class name
  22336. */
  22337. getClassName(): string;
  22338. /**
  22339. * Gets the rgba component (input)
  22340. */
  22341. get rgba(): NodeMaterialConnectionPoint;
  22342. /**
  22343. * Gets the rgb component (input)
  22344. */
  22345. get rgbIn(): NodeMaterialConnectionPoint;
  22346. /**
  22347. * Gets the rgb component (output)
  22348. */
  22349. get rgbOut(): NodeMaterialConnectionPoint;
  22350. /**
  22351. * Gets the r component (output)
  22352. */
  22353. get r(): NodeMaterialConnectionPoint;
  22354. /**
  22355. * Gets the g component (output)
  22356. */
  22357. get g(): NodeMaterialConnectionPoint;
  22358. /**
  22359. * Gets the b component (output)
  22360. */
  22361. get b(): NodeMaterialConnectionPoint;
  22362. /**
  22363. * Gets the a component (output)
  22364. */
  22365. get a(): NodeMaterialConnectionPoint;
  22366. protected _inputRename(name: string): string;
  22367. protected _outputRename(name: string): string;
  22368. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22369. }
  22370. }
  22371. declare module BABYLON {
  22372. /**
  22373. * Operations supported by the Trigonometry block
  22374. */
  22375. export enum TrigonometryBlockOperations {
  22376. /** Cos */
  22377. Cos = 0,
  22378. /** Sin */
  22379. Sin = 1,
  22380. /** Abs */
  22381. Abs = 2,
  22382. /** Exp */
  22383. Exp = 3,
  22384. /** Exp2 */
  22385. Exp2 = 4,
  22386. /** Round */
  22387. Round = 5,
  22388. /** Floor */
  22389. Floor = 6,
  22390. /** Ceiling */
  22391. Ceiling = 7,
  22392. /** Square root */
  22393. Sqrt = 8,
  22394. /** Log */
  22395. Log = 9,
  22396. /** Tangent */
  22397. Tan = 10,
  22398. /** Arc tangent */
  22399. ArcTan = 11,
  22400. /** Arc cosinus */
  22401. ArcCos = 12,
  22402. /** Arc sinus */
  22403. ArcSin = 13,
  22404. /** Fraction */
  22405. Fract = 14,
  22406. /** Sign */
  22407. Sign = 15,
  22408. /** To radians (from degrees) */
  22409. Radians = 16,
  22410. /** To degrees (from radians) */
  22411. Degrees = 17
  22412. }
  22413. /**
  22414. * Block used to apply trigonometry operation to floats
  22415. */
  22416. export class TrigonometryBlock extends NodeMaterialBlock {
  22417. /**
  22418. * Gets or sets the operation applied by the block
  22419. */
  22420. operation: TrigonometryBlockOperations;
  22421. /**
  22422. * Creates a new TrigonometryBlock
  22423. * @param name defines the block name
  22424. */
  22425. constructor(name: string);
  22426. /**
  22427. * Gets the current class name
  22428. * @returns the class name
  22429. */
  22430. getClassName(): string;
  22431. /**
  22432. * Gets the input component
  22433. */
  22434. get input(): NodeMaterialConnectionPoint;
  22435. /**
  22436. * Gets the output component
  22437. */
  22438. get output(): NodeMaterialConnectionPoint;
  22439. protected _buildBlock(state: NodeMaterialBuildState): this;
  22440. serialize(): any;
  22441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22442. protected _dumpPropertiesCode(): string;
  22443. }
  22444. }
  22445. declare module BABYLON {
  22446. /**
  22447. * Interface used to configure the node material editor
  22448. */
  22449. export interface INodeMaterialEditorOptions {
  22450. /** Define the URl to load node editor script */
  22451. editorURL?: string;
  22452. }
  22453. /** @hidden */
  22454. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22455. NORMAL: boolean;
  22456. TANGENT: boolean;
  22457. UV1: boolean;
  22458. /** BONES */
  22459. NUM_BONE_INFLUENCERS: number;
  22460. BonesPerMesh: number;
  22461. BONETEXTURE: boolean;
  22462. /** MORPH TARGETS */
  22463. MORPHTARGETS: boolean;
  22464. MORPHTARGETS_NORMAL: boolean;
  22465. MORPHTARGETS_TANGENT: boolean;
  22466. MORPHTARGETS_UV: boolean;
  22467. NUM_MORPH_INFLUENCERS: number;
  22468. /** IMAGE PROCESSING */
  22469. IMAGEPROCESSING: boolean;
  22470. VIGNETTE: boolean;
  22471. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22472. VIGNETTEBLENDMODEOPAQUE: boolean;
  22473. TONEMAPPING: boolean;
  22474. TONEMAPPING_ACES: boolean;
  22475. CONTRAST: boolean;
  22476. EXPOSURE: boolean;
  22477. COLORCURVES: boolean;
  22478. COLORGRADING: boolean;
  22479. COLORGRADING3D: boolean;
  22480. SAMPLER3DGREENDEPTH: boolean;
  22481. SAMPLER3DBGRMAP: boolean;
  22482. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22483. /** MISC. */
  22484. BUMPDIRECTUV: number;
  22485. constructor();
  22486. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22487. }
  22488. /**
  22489. * Class used to configure NodeMaterial
  22490. */
  22491. export interface INodeMaterialOptions {
  22492. /**
  22493. * Defines if blocks should emit comments
  22494. */
  22495. emitComments: boolean;
  22496. }
  22497. /**
  22498. * Class used to create a node based material built by assembling shader blocks
  22499. */
  22500. export class NodeMaterial extends PushMaterial {
  22501. private static _BuildIdGenerator;
  22502. private _options;
  22503. private _vertexCompilationState;
  22504. private _fragmentCompilationState;
  22505. private _sharedData;
  22506. private _buildId;
  22507. private _buildWasSuccessful;
  22508. private _cachedWorldViewMatrix;
  22509. private _cachedWorldViewProjectionMatrix;
  22510. private _optimizers;
  22511. private _animationFrame;
  22512. /** Define the Url to load node editor script */
  22513. static EditorURL: string;
  22514. /** Define the Url to load snippets */
  22515. static SnippetUrl: string;
  22516. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22517. static IgnoreTexturesAtLoadTime: boolean;
  22518. private BJSNODEMATERIALEDITOR;
  22519. /** Get the inspector from bundle or global */
  22520. private _getGlobalNodeMaterialEditor;
  22521. /**
  22522. * Snippet ID if the material was created from the snippet server
  22523. */
  22524. snippetId: string;
  22525. /**
  22526. * Gets or sets data used by visual editor
  22527. * @see https://nme.babylonjs.com
  22528. */
  22529. editorData: any;
  22530. /**
  22531. * 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)
  22532. */
  22533. ignoreAlpha: boolean;
  22534. /**
  22535. * Defines the maximum number of lights that can be used in the material
  22536. */
  22537. maxSimultaneousLights: number;
  22538. /**
  22539. * Observable raised when the material is built
  22540. */
  22541. onBuildObservable: Observable<NodeMaterial>;
  22542. /**
  22543. * Gets or sets the root nodes of the material vertex shader
  22544. */
  22545. _vertexOutputNodes: NodeMaterialBlock[];
  22546. /**
  22547. * Gets or sets the root nodes of the material fragment (pixel) shader
  22548. */
  22549. _fragmentOutputNodes: NodeMaterialBlock[];
  22550. /** Gets or sets options to control the node material overall behavior */
  22551. get options(): INodeMaterialOptions;
  22552. set options(options: INodeMaterialOptions);
  22553. /**
  22554. * Default configuration related to image processing available in the standard Material.
  22555. */
  22556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22557. /**
  22558. * Gets the image processing configuration used either in this material.
  22559. */
  22560. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22561. /**
  22562. * Sets the Default image processing configuration used either in the this material.
  22563. *
  22564. * If sets to null, the scene one is in use.
  22565. */
  22566. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22567. /**
  22568. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22569. */
  22570. attachedBlocks: NodeMaterialBlock[];
  22571. /**
  22572. * Specifies the mode of the node material
  22573. * @hidden
  22574. */
  22575. _mode: NodeMaterialModes;
  22576. /**
  22577. * Gets the mode property
  22578. */
  22579. get mode(): NodeMaterialModes;
  22580. /**
  22581. * Create a new node based material
  22582. * @param name defines the material name
  22583. * @param scene defines the hosting scene
  22584. * @param options defines creation option
  22585. */
  22586. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22587. /**
  22588. * Gets the current class name of the material e.g. "NodeMaterial"
  22589. * @returns the class name
  22590. */
  22591. getClassName(): string;
  22592. /**
  22593. * Keep track of the image processing observer to allow dispose and replace.
  22594. */
  22595. private _imageProcessingObserver;
  22596. /**
  22597. * Attaches a new image processing configuration to the Standard Material.
  22598. * @param configuration
  22599. */
  22600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22601. /**
  22602. * Get a block by its name
  22603. * @param name defines the name of the block to retrieve
  22604. * @returns the required block or null if not found
  22605. */
  22606. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22607. /**
  22608. * Get a block by its name
  22609. * @param predicate defines the predicate used to find the good candidate
  22610. * @returns the required block or null if not found
  22611. */
  22612. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22613. /**
  22614. * Get an input block by its name
  22615. * @param predicate defines the predicate used to find the good candidate
  22616. * @returns the required input block or null if not found
  22617. */
  22618. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22619. /**
  22620. * Gets the list of input blocks attached to this material
  22621. * @returns an array of InputBlocks
  22622. */
  22623. getInputBlocks(): InputBlock[];
  22624. /**
  22625. * Adds a new optimizer to the list of optimizers
  22626. * @param optimizer defines the optimizers to add
  22627. * @returns the current material
  22628. */
  22629. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22630. /**
  22631. * Remove an optimizer from the list of optimizers
  22632. * @param optimizer defines the optimizers to remove
  22633. * @returns the current material
  22634. */
  22635. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22636. /**
  22637. * Add a new block to the list of output nodes
  22638. * @param node defines the node to add
  22639. * @returns the current material
  22640. */
  22641. addOutputNode(node: NodeMaterialBlock): this;
  22642. /**
  22643. * Remove a block from the list of root nodes
  22644. * @param node defines the node to remove
  22645. * @returns the current material
  22646. */
  22647. removeOutputNode(node: NodeMaterialBlock): this;
  22648. private _addVertexOutputNode;
  22649. private _removeVertexOutputNode;
  22650. private _addFragmentOutputNode;
  22651. private _removeFragmentOutputNode;
  22652. /**
  22653. * Specifies if the material will require alpha blending
  22654. * @returns a boolean specifying if alpha blending is needed
  22655. */
  22656. needAlphaBlending(): boolean;
  22657. /**
  22658. * Specifies if this material should be rendered in alpha test mode
  22659. * @returns a boolean specifying if an alpha test is needed.
  22660. */
  22661. needAlphaTesting(): boolean;
  22662. private _initializeBlock;
  22663. private _resetDualBlocks;
  22664. /**
  22665. * Remove a block from the current node material
  22666. * @param block defines the block to remove
  22667. */
  22668. removeBlock(block: NodeMaterialBlock): void;
  22669. /**
  22670. * Build the material and generates the inner effect
  22671. * @param verbose defines if the build should log activity
  22672. */
  22673. build(verbose?: boolean): void;
  22674. /**
  22675. * Runs an otpimization phase to try to improve the shader code
  22676. */
  22677. optimize(): void;
  22678. private _prepareDefinesForAttributes;
  22679. /**
  22680. * Create a post process from the material
  22681. * @param camera The camera to apply the render pass to.
  22682. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22684. * @param engine The engine which the post process will be applied. (default: current engine)
  22685. * @param reusable If the post process can be reused on the same frame. (default: false)
  22686. * @param textureType Type of textures used when performing the post process. (default: 0)
  22687. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22688. * @returns the post process created
  22689. */
  22690. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22691. /**
  22692. * Create the post process effect from the material
  22693. * @param postProcess The post process to create the effect for
  22694. */
  22695. createEffectForPostProcess(postProcess: PostProcess): void;
  22696. private _createEffectForPostProcess;
  22697. /**
  22698. * Create a new procedural texture based on this node material
  22699. * @param size defines the size of the texture
  22700. * @param scene defines the hosting scene
  22701. * @returns the new procedural texture attached to this node material
  22702. */
  22703. createProceduralTexture(size: number | {
  22704. width: number;
  22705. height: number;
  22706. layers?: number;
  22707. }, scene: Scene): Nullable<ProceduralTexture>;
  22708. private _createEffectForParticles;
  22709. private _checkInternals;
  22710. /**
  22711. * Create the effect to be used as the custom effect for a particle system
  22712. * @param particleSystem Particle system to create the effect for
  22713. * @param onCompiled defines a function to call when the effect creation is successful
  22714. * @param onError defines a function to call when the effect creation has failed
  22715. */
  22716. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22717. private _processDefines;
  22718. /**
  22719. * Get if the submesh is ready to be used and all its information available.
  22720. * Child classes can use it to update shaders
  22721. * @param mesh defines the mesh to check
  22722. * @param subMesh defines which submesh to check
  22723. * @param useInstances specifies that instances should be used
  22724. * @returns a boolean indicating that the submesh is ready or not
  22725. */
  22726. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22727. /**
  22728. * Get a string representing the shaders built by the current node graph
  22729. */
  22730. get compiledShaders(): string;
  22731. /**
  22732. * Binds the world matrix to the material
  22733. * @param world defines the world transformation matrix
  22734. */
  22735. bindOnlyWorldMatrix(world: Matrix): void;
  22736. /**
  22737. * Binds the submesh to this material by preparing the effect and shader to draw
  22738. * @param world defines the world transformation matrix
  22739. * @param mesh defines the mesh containing the submesh
  22740. * @param subMesh defines the submesh to bind the material to
  22741. */
  22742. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22743. /**
  22744. * Gets the active textures from the material
  22745. * @returns an array of textures
  22746. */
  22747. getActiveTextures(): BaseTexture[];
  22748. /**
  22749. * Gets the list of texture blocks
  22750. * @returns an array of texture blocks
  22751. */
  22752. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22753. /**
  22754. * Specifies if the material uses a texture
  22755. * @param texture defines the texture to check against the material
  22756. * @returns a boolean specifying if the material uses the texture
  22757. */
  22758. hasTexture(texture: BaseTexture): boolean;
  22759. /**
  22760. * Disposes the material
  22761. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22762. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22763. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22764. */
  22765. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22766. /** Creates the node editor window. */
  22767. private _createNodeEditor;
  22768. /**
  22769. * Launch the node material editor
  22770. * @param config Define the configuration of the editor
  22771. * @return a promise fulfilled when the node editor is visible
  22772. */
  22773. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22774. /**
  22775. * Clear the current material
  22776. */
  22777. clear(): void;
  22778. /**
  22779. * Clear the current material and set it to a default state
  22780. */
  22781. setToDefault(): void;
  22782. /**
  22783. * Clear the current material and set it to a default state for post process
  22784. */
  22785. setToDefaultPostProcess(): void;
  22786. /**
  22787. * Clear the current material and set it to a default state for procedural texture
  22788. */
  22789. setToDefaultProceduralTexture(): void;
  22790. /**
  22791. * Clear the current material and set it to a default state for particle
  22792. */
  22793. setToDefaultParticle(): void;
  22794. /**
  22795. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22796. * @param url defines the url to load from
  22797. * @returns a promise that will fullfil when the material is fully loaded
  22798. */
  22799. loadAsync(url: string): Promise<void>;
  22800. private _gatherBlocks;
  22801. /**
  22802. * Generate a string containing the code declaration required to create an equivalent of this material
  22803. * @returns a string
  22804. */
  22805. generateCode(): string;
  22806. /**
  22807. * Serializes this material in a JSON representation
  22808. * @returns the serialized material object
  22809. */
  22810. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22811. private _restoreConnections;
  22812. /**
  22813. * Clear the current graph and load a new one from a serialization object
  22814. * @param source defines the JSON representation of the material
  22815. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22816. * @param merge defines whether or not the source must be merged or replace the current content
  22817. */
  22818. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22819. /**
  22820. * Makes a duplicate of the current material.
  22821. * @param name - name to use for the new material.
  22822. */
  22823. clone(name: string): NodeMaterial;
  22824. /**
  22825. * Creates a node material from parsed material data
  22826. * @param source defines the JSON representation of the material
  22827. * @param scene defines the hosting scene
  22828. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22829. * @returns a new node material
  22830. */
  22831. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22832. /**
  22833. * Creates a node material from a snippet saved in a remote file
  22834. * @param name defines the name of the material to create
  22835. * @param url defines the url to load from
  22836. * @param scene defines the hosting scene
  22837. * @returns a promise that will resolve to the new node material
  22838. */
  22839. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22840. /**
  22841. * Creates a node material from a snippet saved by the node material editor
  22842. * @param snippetId defines the snippet to load
  22843. * @param scene defines the hosting scene
  22844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22845. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22846. * @returns a promise that will resolve to the new node material
  22847. */
  22848. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22849. /**
  22850. * Creates a new node material set to default basic configuration
  22851. * @param name defines the name of the material
  22852. * @param scene defines the hosting scene
  22853. * @returns a new NodeMaterial
  22854. */
  22855. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22856. }
  22857. }
  22858. declare module BABYLON {
  22859. interface ThinEngine {
  22860. /**
  22861. * Unbind a list of render target textures from the webGL context
  22862. * This is used only when drawBuffer extension or webGL2 are active
  22863. * @param textures defines the render target textures to unbind
  22864. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22865. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22866. */
  22867. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22868. /**
  22869. * Create a multi render target texture
  22870. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22871. * @param size defines the size of the texture
  22872. * @param options defines the creation options
  22873. * @returns the cube texture as an InternalTexture
  22874. */
  22875. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22876. /**
  22877. * Update the sample count for a given multiple render target texture
  22878. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22879. * @param textures defines the textures to update
  22880. * @param samples defines the sample count to set
  22881. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22882. */
  22883. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22884. /**
  22885. * Select a subsets of attachments to draw to.
  22886. * @param attachments gl attachments
  22887. */
  22888. bindAttachments(attachments: number[]): void;
  22889. /**
  22890. * Creates a layout object to draw/clear on specific textures in a MRT
  22891. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22892. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22893. */
  22894. buildTextureLayout(textureStatus: boolean[]): number[];
  22895. /**
  22896. * Restores the webgl state to only draw on the main color attachment
  22897. */
  22898. restoreSingleAttachment(): void;
  22899. }
  22900. }
  22901. declare module BABYLON {
  22902. /**
  22903. * Creation options of the multi render target texture.
  22904. */
  22905. export interface IMultiRenderTargetOptions {
  22906. /**
  22907. * Define if the texture needs to create mip maps after render.
  22908. */
  22909. generateMipMaps?: boolean;
  22910. /**
  22911. * Define the types of all the draw buffers we want to create
  22912. */
  22913. types?: number[];
  22914. /**
  22915. * Define the sampling modes of all the draw buffers we want to create
  22916. */
  22917. samplingModes?: number[];
  22918. /**
  22919. * Define if a depth buffer is required
  22920. */
  22921. generateDepthBuffer?: boolean;
  22922. /**
  22923. * Define if a stencil buffer is required
  22924. */
  22925. generateStencilBuffer?: boolean;
  22926. /**
  22927. * Define if a depth texture is required instead of a depth buffer
  22928. */
  22929. generateDepthTexture?: boolean;
  22930. /**
  22931. * Define the number of desired draw buffers
  22932. */
  22933. textureCount?: number;
  22934. /**
  22935. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22936. */
  22937. doNotChangeAspectRatio?: boolean;
  22938. /**
  22939. * Define the default type of the buffers we are creating
  22940. */
  22941. defaultType?: number;
  22942. }
  22943. /**
  22944. * A multi render target, like a render target provides the ability to render to a texture.
  22945. * Unlike the render target, it can render to several draw buffers in one draw.
  22946. * This is specially interesting in deferred rendering or for any effects requiring more than
  22947. * just one color from a single pass.
  22948. */
  22949. export class MultiRenderTarget extends RenderTargetTexture {
  22950. private _internalTextures;
  22951. private _textures;
  22952. private _multiRenderTargetOptions;
  22953. private _count;
  22954. /**
  22955. * Get if draw buffers are currently supported by the used hardware and browser.
  22956. */
  22957. get isSupported(): boolean;
  22958. /**
  22959. * Get the list of textures generated by the multi render target.
  22960. */
  22961. get textures(): Texture[];
  22962. /**
  22963. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22964. */
  22965. get count(): number;
  22966. /**
  22967. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22968. */
  22969. get depthTexture(): Texture;
  22970. /**
  22971. * Set the wrapping mode on U of all the textures we are rendering to.
  22972. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22973. */
  22974. set wrapU(wrap: number);
  22975. /**
  22976. * Set the wrapping mode on V of all the textures we are rendering to.
  22977. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22978. */
  22979. set wrapV(wrap: number);
  22980. /**
  22981. * Instantiate a new multi render target texture.
  22982. * A multi render target, like a render target provides the ability to render to a texture.
  22983. * Unlike the render target, it can render to several draw buffers in one draw.
  22984. * This is specially interesting in deferred rendering or for any effects requiring more than
  22985. * just one color from a single pass.
  22986. * @param name Define the name of the texture
  22987. * @param size Define the size of the buffers to render to
  22988. * @param count Define the number of target we are rendering into
  22989. * @param scene Define the scene the texture belongs to
  22990. * @param options Define the options used to create the multi render target
  22991. */
  22992. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22993. private _initTypes;
  22994. /** @hidden */
  22995. _rebuild(forceFullRebuild?: boolean): void;
  22996. private _createInternalTextures;
  22997. private _createTextures;
  22998. /**
  22999. * Replaces a texture within the MRT.
  23000. * @param texture The new texture to insert in the MRT
  23001. * @param index The index of the texture to replace
  23002. */
  23003. replaceTexture(texture: Texture, index: number): void;
  23004. /**
  23005. * Define the number of samples used if MSAA is enabled.
  23006. */
  23007. get samples(): number;
  23008. set samples(value: number);
  23009. /**
  23010. * Resize all the textures in the multi render target.
  23011. * Be careful as it will recreate all the data in the new texture.
  23012. * @param size Define the new size
  23013. */
  23014. resize(size: any): void;
  23015. /**
  23016. * Changes the number of render targets in this MRT
  23017. * Be careful as it will recreate all the data in the new texture.
  23018. * @param count new texture count
  23019. * @param options Specifies texture types and sampling modes for new textures
  23020. */
  23021. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23022. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23023. /**
  23024. * Dispose the render targets and their associated resources
  23025. */
  23026. dispose(): void;
  23027. /**
  23028. * Release all the underlying texture used as draw buffers.
  23029. */
  23030. releaseInternalTextures(): void;
  23031. }
  23032. }
  23033. declare module BABYLON {
  23034. /** @hidden */
  23035. export var imageProcessingPixelShader: {
  23036. name: string;
  23037. shader: string;
  23038. };
  23039. }
  23040. declare module BABYLON {
  23041. /**
  23042. * ImageProcessingPostProcess
  23043. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23044. */
  23045. export class ImageProcessingPostProcess extends PostProcess {
  23046. /**
  23047. * Default configuration related to image processing available in the PBR Material.
  23048. */
  23049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23050. /**
  23051. * Gets the image processing configuration used either in this material.
  23052. */
  23053. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23054. /**
  23055. * Sets the Default image processing configuration used either in the this material.
  23056. *
  23057. * If sets to null, the scene one is in use.
  23058. */
  23059. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23060. /**
  23061. * Keep track of the image processing observer to allow dispose and replace.
  23062. */
  23063. private _imageProcessingObserver;
  23064. /**
  23065. * Attaches a new image processing configuration to the PBR Material.
  23066. * @param configuration
  23067. */
  23068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23069. /**
  23070. * If the post process is supported.
  23071. */
  23072. get isSupported(): boolean;
  23073. /**
  23074. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23075. */
  23076. get colorCurves(): Nullable<ColorCurves>;
  23077. /**
  23078. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23079. */
  23080. set colorCurves(value: Nullable<ColorCurves>);
  23081. /**
  23082. * Gets wether the color curves effect is enabled.
  23083. */
  23084. get colorCurvesEnabled(): boolean;
  23085. /**
  23086. * Sets wether the color curves effect is enabled.
  23087. */
  23088. set colorCurvesEnabled(value: boolean);
  23089. /**
  23090. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23091. */
  23092. get colorGradingTexture(): Nullable<BaseTexture>;
  23093. /**
  23094. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23095. */
  23096. set colorGradingTexture(value: Nullable<BaseTexture>);
  23097. /**
  23098. * Gets wether the color grading effect is enabled.
  23099. */
  23100. get colorGradingEnabled(): boolean;
  23101. /**
  23102. * Gets wether the color grading effect is enabled.
  23103. */
  23104. set colorGradingEnabled(value: boolean);
  23105. /**
  23106. * Gets exposure used in the effect.
  23107. */
  23108. get exposure(): number;
  23109. /**
  23110. * Sets exposure used in the effect.
  23111. */
  23112. set exposure(value: number);
  23113. /**
  23114. * Gets wether tonemapping is enabled or not.
  23115. */
  23116. get toneMappingEnabled(): boolean;
  23117. /**
  23118. * Sets wether tonemapping is enabled or not
  23119. */
  23120. set toneMappingEnabled(value: boolean);
  23121. /**
  23122. * Gets the type of tone mapping effect.
  23123. */
  23124. get toneMappingType(): number;
  23125. /**
  23126. * Sets the type of tone mapping effect.
  23127. */
  23128. set toneMappingType(value: number);
  23129. /**
  23130. * Gets contrast used in the effect.
  23131. */
  23132. get contrast(): number;
  23133. /**
  23134. * Sets contrast used in the effect.
  23135. */
  23136. set contrast(value: number);
  23137. /**
  23138. * Gets Vignette stretch size.
  23139. */
  23140. get vignetteStretch(): number;
  23141. /**
  23142. * Sets Vignette stretch size.
  23143. */
  23144. set vignetteStretch(value: number);
  23145. /**
  23146. * Gets Vignette centre X Offset.
  23147. */
  23148. get vignetteCentreX(): number;
  23149. /**
  23150. * Sets Vignette centre X Offset.
  23151. */
  23152. set vignetteCentreX(value: number);
  23153. /**
  23154. * Gets Vignette centre Y Offset.
  23155. */
  23156. get vignetteCentreY(): number;
  23157. /**
  23158. * Sets Vignette centre Y Offset.
  23159. */
  23160. set vignetteCentreY(value: number);
  23161. /**
  23162. * Gets Vignette weight or intensity of the vignette effect.
  23163. */
  23164. get vignetteWeight(): number;
  23165. /**
  23166. * Sets Vignette weight or intensity of the vignette effect.
  23167. */
  23168. set vignetteWeight(value: number);
  23169. /**
  23170. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23171. * if vignetteEnabled is set to true.
  23172. */
  23173. get vignetteColor(): Color4;
  23174. /**
  23175. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23176. * if vignetteEnabled is set to true.
  23177. */
  23178. set vignetteColor(value: Color4);
  23179. /**
  23180. * Gets Camera field of view used by the Vignette effect.
  23181. */
  23182. get vignetteCameraFov(): number;
  23183. /**
  23184. * Sets Camera field of view used by the Vignette effect.
  23185. */
  23186. set vignetteCameraFov(value: number);
  23187. /**
  23188. * Gets the vignette blend mode allowing different kind of effect.
  23189. */
  23190. get vignetteBlendMode(): number;
  23191. /**
  23192. * Sets the vignette blend mode allowing different kind of effect.
  23193. */
  23194. set vignetteBlendMode(value: number);
  23195. /**
  23196. * Gets wether the vignette effect is enabled.
  23197. */
  23198. get vignetteEnabled(): boolean;
  23199. /**
  23200. * Sets wether the vignette effect is enabled.
  23201. */
  23202. set vignetteEnabled(value: boolean);
  23203. private _fromLinearSpace;
  23204. /**
  23205. * Gets wether the input of the processing is in Gamma or Linear Space.
  23206. */
  23207. get fromLinearSpace(): boolean;
  23208. /**
  23209. * Sets wether the input of the processing is in Gamma or Linear Space.
  23210. */
  23211. set fromLinearSpace(value: boolean);
  23212. /**
  23213. * Defines cache preventing GC.
  23214. */
  23215. private _defines;
  23216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23217. /**
  23218. * "ImageProcessingPostProcess"
  23219. * @returns "ImageProcessingPostProcess"
  23220. */
  23221. getClassName(): string;
  23222. /**
  23223. * @hidden
  23224. */
  23225. _updateParameters(): void;
  23226. dispose(camera?: Camera): void;
  23227. }
  23228. }
  23229. declare module BABYLON {
  23230. /**
  23231. * Interface for defining prepass effects in the prepass post-process pipeline
  23232. */
  23233. export interface PrePassEffectConfiguration {
  23234. /**
  23235. * Name of the effect
  23236. */
  23237. name: string;
  23238. /**
  23239. * Post process to attach for this effect
  23240. */
  23241. postProcess?: PostProcess;
  23242. /**
  23243. * Textures required in the MRT
  23244. */
  23245. texturesRequired: number[];
  23246. /**
  23247. * Is the effect enabled
  23248. */
  23249. enabled: boolean;
  23250. /**
  23251. * Disposes the effect configuration
  23252. */
  23253. dispose?: () => void;
  23254. /**
  23255. * Creates the associated post process
  23256. */
  23257. createPostProcess?: () => PostProcess;
  23258. }
  23259. }
  23260. declare module BABYLON {
  23261. /**
  23262. * Options to be used when creating a FresnelParameters.
  23263. */
  23264. export type IFresnelParametersCreationOptions = {
  23265. /**
  23266. * Define the color used on edges (grazing angle)
  23267. */
  23268. leftColor?: Color3;
  23269. /**
  23270. * Define the color used on center
  23271. */
  23272. rightColor?: Color3;
  23273. /**
  23274. * Define bias applied to computed fresnel term
  23275. */
  23276. bias?: number;
  23277. /**
  23278. * Defined the power exponent applied to fresnel term
  23279. */
  23280. power?: number;
  23281. /**
  23282. * Define if the fresnel effect is enable or not.
  23283. */
  23284. isEnabled?: boolean;
  23285. };
  23286. /**
  23287. * Serialized format for FresnelParameters.
  23288. */
  23289. export type IFresnelParametersSerialized = {
  23290. /**
  23291. * Define the color used on edges (grazing angle) [as an array]
  23292. */
  23293. leftColor: number[];
  23294. /**
  23295. * Define the color used on center [as an array]
  23296. */
  23297. rightColor: number[];
  23298. /**
  23299. * Define bias applied to computed fresnel term
  23300. */
  23301. bias: number;
  23302. /**
  23303. * Defined the power exponent applied to fresnel term
  23304. */
  23305. power?: number;
  23306. /**
  23307. * Define if the fresnel effect is enable or not.
  23308. */
  23309. isEnabled: boolean;
  23310. };
  23311. /**
  23312. * This represents all the required information to add a fresnel effect on a material:
  23313. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23314. */
  23315. export class FresnelParameters {
  23316. private _isEnabled;
  23317. /**
  23318. * Define if the fresnel effect is enable or not.
  23319. */
  23320. get isEnabled(): boolean;
  23321. set isEnabled(value: boolean);
  23322. /**
  23323. * Define the color used on edges (grazing angle)
  23324. */
  23325. leftColor: Color3;
  23326. /**
  23327. * Define the color used on center
  23328. */
  23329. rightColor: Color3;
  23330. /**
  23331. * Define bias applied to computed fresnel term
  23332. */
  23333. bias: number;
  23334. /**
  23335. * Defined the power exponent applied to fresnel term
  23336. */
  23337. power: number;
  23338. /**
  23339. * Creates a new FresnelParameters object.
  23340. *
  23341. * @param options provide your own settings to optionally to override defaults
  23342. */
  23343. constructor(options?: IFresnelParametersCreationOptions);
  23344. /**
  23345. * Clones the current fresnel and its valuues
  23346. * @returns a clone fresnel configuration
  23347. */
  23348. clone(): FresnelParameters;
  23349. /**
  23350. * Determines equality between FresnelParameters objects
  23351. * @param otherFresnelParameters defines the second operand
  23352. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23353. */
  23354. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23355. /**
  23356. * Serializes the current fresnel parameters to a JSON representation.
  23357. * @return the JSON serialization
  23358. */
  23359. serialize(): IFresnelParametersSerialized;
  23360. /**
  23361. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23362. * @param parsedFresnelParameters Define the JSON representation
  23363. * @returns the parsed parameters
  23364. */
  23365. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23366. }
  23367. }
  23368. declare module BABYLON {
  23369. /**
  23370. * This groups all the flags used to control the materials channel.
  23371. */
  23372. export class MaterialFlags {
  23373. private static _DiffuseTextureEnabled;
  23374. /**
  23375. * Are diffuse textures enabled in the application.
  23376. */
  23377. static get DiffuseTextureEnabled(): boolean;
  23378. static set DiffuseTextureEnabled(value: boolean);
  23379. private static _DetailTextureEnabled;
  23380. /**
  23381. * Are detail textures enabled in the application.
  23382. */
  23383. static get DetailTextureEnabled(): boolean;
  23384. static set DetailTextureEnabled(value: boolean);
  23385. private static _AmbientTextureEnabled;
  23386. /**
  23387. * Are ambient textures enabled in the application.
  23388. */
  23389. static get AmbientTextureEnabled(): boolean;
  23390. static set AmbientTextureEnabled(value: boolean);
  23391. private static _OpacityTextureEnabled;
  23392. /**
  23393. * Are opacity textures enabled in the application.
  23394. */
  23395. static get OpacityTextureEnabled(): boolean;
  23396. static set OpacityTextureEnabled(value: boolean);
  23397. private static _ReflectionTextureEnabled;
  23398. /**
  23399. * Are reflection textures enabled in the application.
  23400. */
  23401. static get ReflectionTextureEnabled(): boolean;
  23402. static set ReflectionTextureEnabled(value: boolean);
  23403. private static _EmissiveTextureEnabled;
  23404. /**
  23405. * Are emissive textures enabled in the application.
  23406. */
  23407. static get EmissiveTextureEnabled(): boolean;
  23408. static set EmissiveTextureEnabled(value: boolean);
  23409. private static _SpecularTextureEnabled;
  23410. /**
  23411. * Are specular textures enabled in the application.
  23412. */
  23413. static get SpecularTextureEnabled(): boolean;
  23414. static set SpecularTextureEnabled(value: boolean);
  23415. private static _BumpTextureEnabled;
  23416. /**
  23417. * Are bump textures enabled in the application.
  23418. */
  23419. static get BumpTextureEnabled(): boolean;
  23420. static set BumpTextureEnabled(value: boolean);
  23421. private static _LightmapTextureEnabled;
  23422. /**
  23423. * Are lightmap textures enabled in the application.
  23424. */
  23425. static get LightmapTextureEnabled(): boolean;
  23426. static set LightmapTextureEnabled(value: boolean);
  23427. private static _RefractionTextureEnabled;
  23428. /**
  23429. * Are refraction textures enabled in the application.
  23430. */
  23431. static get RefractionTextureEnabled(): boolean;
  23432. static set RefractionTextureEnabled(value: boolean);
  23433. private static _ColorGradingTextureEnabled;
  23434. /**
  23435. * Are color grading textures enabled in the application.
  23436. */
  23437. static get ColorGradingTextureEnabled(): boolean;
  23438. static set ColorGradingTextureEnabled(value: boolean);
  23439. private static _FresnelEnabled;
  23440. /**
  23441. * Are fresnels enabled in the application.
  23442. */
  23443. static get FresnelEnabled(): boolean;
  23444. static set FresnelEnabled(value: boolean);
  23445. private static _ClearCoatTextureEnabled;
  23446. /**
  23447. * Are clear coat textures enabled in the application.
  23448. */
  23449. static get ClearCoatTextureEnabled(): boolean;
  23450. static set ClearCoatTextureEnabled(value: boolean);
  23451. private static _ClearCoatBumpTextureEnabled;
  23452. /**
  23453. * Are clear coat bump textures enabled in the application.
  23454. */
  23455. static get ClearCoatBumpTextureEnabled(): boolean;
  23456. static set ClearCoatBumpTextureEnabled(value: boolean);
  23457. private static _ClearCoatTintTextureEnabled;
  23458. /**
  23459. * Are clear coat tint textures enabled in the application.
  23460. */
  23461. static get ClearCoatTintTextureEnabled(): boolean;
  23462. static set ClearCoatTintTextureEnabled(value: boolean);
  23463. private static _SheenTextureEnabled;
  23464. /**
  23465. * Are sheen textures enabled in the application.
  23466. */
  23467. static get SheenTextureEnabled(): boolean;
  23468. static set SheenTextureEnabled(value: boolean);
  23469. private static _AnisotropicTextureEnabled;
  23470. /**
  23471. * Are anisotropic textures enabled in the application.
  23472. */
  23473. static get AnisotropicTextureEnabled(): boolean;
  23474. static set AnisotropicTextureEnabled(value: boolean);
  23475. private static _ThicknessTextureEnabled;
  23476. /**
  23477. * Are thickness textures enabled in the application.
  23478. */
  23479. static get ThicknessTextureEnabled(): boolean;
  23480. static set ThicknessTextureEnabled(value: boolean);
  23481. }
  23482. }
  23483. declare module BABYLON {
  23484. /** @hidden */
  23485. export var defaultFragmentDeclaration: {
  23486. name: string;
  23487. shader: string;
  23488. };
  23489. }
  23490. declare module BABYLON {
  23491. /** @hidden */
  23492. export var defaultUboDeclaration: {
  23493. name: string;
  23494. shader: string;
  23495. };
  23496. }
  23497. declare module BABYLON {
  23498. /** @hidden */
  23499. export var prePassDeclaration: {
  23500. name: string;
  23501. shader: string;
  23502. };
  23503. }
  23504. declare module BABYLON {
  23505. /** @hidden */
  23506. export var lightFragmentDeclaration: {
  23507. name: string;
  23508. shader: string;
  23509. };
  23510. }
  23511. declare module BABYLON {
  23512. /** @hidden */
  23513. export var lightUboDeclaration: {
  23514. name: string;
  23515. shader: string;
  23516. };
  23517. }
  23518. declare module BABYLON {
  23519. /** @hidden */
  23520. export var lightsFragmentFunctions: {
  23521. name: string;
  23522. shader: string;
  23523. };
  23524. }
  23525. declare module BABYLON {
  23526. /** @hidden */
  23527. export var shadowsFragmentFunctions: {
  23528. name: string;
  23529. shader: string;
  23530. };
  23531. }
  23532. declare module BABYLON {
  23533. /** @hidden */
  23534. export var fresnelFunction: {
  23535. name: string;
  23536. shader: string;
  23537. };
  23538. }
  23539. declare module BABYLON {
  23540. /** @hidden */
  23541. export var bumpFragmentMainFunctions: {
  23542. name: string;
  23543. shader: string;
  23544. };
  23545. }
  23546. declare module BABYLON {
  23547. /** @hidden */
  23548. export var bumpFragmentFunctions: {
  23549. name: string;
  23550. shader: string;
  23551. };
  23552. }
  23553. declare module BABYLON {
  23554. /** @hidden */
  23555. export var logDepthDeclaration: {
  23556. name: string;
  23557. shader: string;
  23558. };
  23559. }
  23560. declare module BABYLON {
  23561. /** @hidden */
  23562. export var bumpFragment: {
  23563. name: string;
  23564. shader: string;
  23565. };
  23566. }
  23567. declare module BABYLON {
  23568. /** @hidden */
  23569. export var depthPrePass: {
  23570. name: string;
  23571. shader: string;
  23572. };
  23573. }
  23574. declare module BABYLON {
  23575. /** @hidden */
  23576. export var lightFragment: {
  23577. name: string;
  23578. shader: string;
  23579. };
  23580. }
  23581. declare module BABYLON {
  23582. /** @hidden */
  23583. export var logDepthFragment: {
  23584. name: string;
  23585. shader: string;
  23586. };
  23587. }
  23588. declare module BABYLON {
  23589. /** @hidden */
  23590. export var defaultPixelShader: {
  23591. name: string;
  23592. shader: string;
  23593. };
  23594. }
  23595. declare module BABYLON {
  23596. /** @hidden */
  23597. export var defaultVertexDeclaration: {
  23598. name: string;
  23599. shader: string;
  23600. };
  23601. }
  23602. declare module BABYLON {
  23603. /** @hidden */
  23604. export var prePassVertexDeclaration: {
  23605. name: string;
  23606. shader: string;
  23607. };
  23608. }
  23609. declare module BABYLON {
  23610. /** @hidden */
  23611. export var bumpVertexDeclaration: {
  23612. name: string;
  23613. shader: string;
  23614. };
  23615. }
  23616. declare module BABYLON {
  23617. /** @hidden */
  23618. export var prePassVertex: {
  23619. name: string;
  23620. shader: string;
  23621. };
  23622. }
  23623. declare module BABYLON {
  23624. /** @hidden */
  23625. export var bumpVertex: {
  23626. name: string;
  23627. shader: string;
  23628. };
  23629. }
  23630. declare module BABYLON {
  23631. /** @hidden */
  23632. export var fogVertex: {
  23633. name: string;
  23634. shader: string;
  23635. };
  23636. }
  23637. declare module BABYLON {
  23638. /** @hidden */
  23639. export var shadowsVertex: {
  23640. name: string;
  23641. shader: string;
  23642. };
  23643. }
  23644. declare module BABYLON {
  23645. /** @hidden */
  23646. export var pointCloudVertex: {
  23647. name: string;
  23648. shader: string;
  23649. };
  23650. }
  23651. declare module BABYLON {
  23652. /** @hidden */
  23653. export var logDepthVertex: {
  23654. name: string;
  23655. shader: string;
  23656. };
  23657. }
  23658. declare module BABYLON {
  23659. /** @hidden */
  23660. export var defaultVertexShader: {
  23661. name: string;
  23662. shader: string;
  23663. };
  23664. }
  23665. declare module BABYLON {
  23666. /**
  23667. * @hidden
  23668. */
  23669. export interface IMaterialDetailMapDefines {
  23670. DETAIL: boolean;
  23671. DETAILDIRECTUV: number;
  23672. DETAIL_NORMALBLENDMETHOD: number;
  23673. /** @hidden */
  23674. _areTexturesDirty: boolean;
  23675. }
  23676. /**
  23677. * Define the code related to the detail map parameters of a material
  23678. *
  23679. * Inspired from:
  23680. * 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
  23681. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23682. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23683. */
  23684. export class DetailMapConfiguration {
  23685. private _texture;
  23686. /**
  23687. * The detail texture of the material.
  23688. */
  23689. texture: Nullable<BaseTexture>;
  23690. /**
  23691. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23692. * Bigger values mean stronger blending
  23693. */
  23694. diffuseBlendLevel: number;
  23695. /**
  23696. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23697. * Bigger values mean stronger blending. Only used with PBR materials
  23698. */
  23699. roughnessBlendLevel: number;
  23700. /**
  23701. * Defines how strong the bump effect from the detail map is
  23702. * Bigger values mean stronger effect
  23703. */
  23704. bumpLevel: number;
  23705. private _normalBlendMethod;
  23706. /**
  23707. * The method used to blend the bump and detail normals together
  23708. */
  23709. normalBlendMethod: number;
  23710. private _isEnabled;
  23711. /**
  23712. * Enable or disable the detail map on this material
  23713. */
  23714. isEnabled: boolean;
  23715. /** @hidden */
  23716. private _internalMarkAllSubMeshesAsTexturesDirty;
  23717. /** @hidden */
  23718. _markAllSubMeshesAsTexturesDirty(): void;
  23719. /**
  23720. * Instantiate a new detail map
  23721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23722. */
  23723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23724. /**
  23725. * Gets whether the submesh is ready to be used or not.
  23726. * @param defines the list of "defines" to update.
  23727. * @param scene defines the scene the material belongs to.
  23728. * @returns - boolean indicating that the submesh is ready or not.
  23729. */
  23730. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23731. /**
  23732. * Update the defines for detail map usage
  23733. * @param defines the list of "defines" to update.
  23734. * @param scene defines the scene the material belongs to.
  23735. */
  23736. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23737. /**
  23738. * Binds the material data.
  23739. * @param uniformBuffer defines the Uniform buffer to fill in.
  23740. * @param scene defines the scene the material belongs to.
  23741. * @param isFrozen defines whether the material is frozen or not.
  23742. */
  23743. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23744. /**
  23745. * Checks to see if a texture is used in the material.
  23746. * @param texture - Base texture to use.
  23747. * @returns - Boolean specifying if a texture is used in the material.
  23748. */
  23749. hasTexture(texture: BaseTexture): boolean;
  23750. /**
  23751. * Returns an array of the actively used textures.
  23752. * @param activeTextures Array of BaseTextures
  23753. */
  23754. getActiveTextures(activeTextures: BaseTexture[]): void;
  23755. /**
  23756. * Returns the animatable textures.
  23757. * @param animatables Array of animatable textures.
  23758. */
  23759. getAnimatables(animatables: IAnimatable[]): void;
  23760. /**
  23761. * Disposes the resources of the material.
  23762. * @param forceDisposeTextures - Forces the disposal of all textures.
  23763. */
  23764. dispose(forceDisposeTextures?: boolean): void;
  23765. /**
  23766. * Get the current class name useful for serialization or dynamic coding.
  23767. * @returns "DetailMap"
  23768. */
  23769. getClassName(): string;
  23770. /**
  23771. * Add the required uniforms to the current list.
  23772. * @param uniforms defines the current uniform list.
  23773. */
  23774. static AddUniforms(uniforms: string[]): void;
  23775. /**
  23776. * Add the required samplers to the current list.
  23777. * @param samplers defines the current sampler list.
  23778. */
  23779. static AddSamplers(samplers: string[]): void;
  23780. /**
  23781. * Add the required uniforms to the current buffer.
  23782. * @param uniformBuffer defines the current uniform buffer.
  23783. */
  23784. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23785. /**
  23786. * Makes a duplicate of the current instance into another one.
  23787. * @param detailMap define the instance where to copy the info
  23788. */
  23789. copyTo(detailMap: DetailMapConfiguration): void;
  23790. /**
  23791. * Serializes this detail map instance
  23792. * @returns - An object with the serialized instance.
  23793. */
  23794. serialize(): any;
  23795. /**
  23796. * Parses a detail map setting from a serialized object.
  23797. * @param source - Serialized object.
  23798. * @param scene Defines the scene we are parsing for
  23799. * @param rootUrl Defines the rootUrl to load from
  23800. */
  23801. parse(source: any, scene: Scene, rootUrl: string): void;
  23802. }
  23803. }
  23804. declare module BABYLON {
  23805. /** @hidden */
  23806. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23807. MAINUV1: boolean;
  23808. MAINUV2: boolean;
  23809. DIFFUSE: boolean;
  23810. DIFFUSEDIRECTUV: number;
  23811. DETAIL: boolean;
  23812. DETAILDIRECTUV: number;
  23813. DETAIL_NORMALBLENDMETHOD: number;
  23814. AMBIENT: boolean;
  23815. AMBIENTDIRECTUV: number;
  23816. OPACITY: boolean;
  23817. OPACITYDIRECTUV: number;
  23818. OPACITYRGB: boolean;
  23819. REFLECTION: boolean;
  23820. EMISSIVE: boolean;
  23821. EMISSIVEDIRECTUV: number;
  23822. SPECULAR: boolean;
  23823. SPECULARDIRECTUV: number;
  23824. BUMP: boolean;
  23825. BUMPDIRECTUV: number;
  23826. PARALLAX: boolean;
  23827. PARALLAXOCCLUSION: boolean;
  23828. SPECULAROVERALPHA: boolean;
  23829. CLIPPLANE: boolean;
  23830. CLIPPLANE2: boolean;
  23831. CLIPPLANE3: boolean;
  23832. CLIPPLANE4: boolean;
  23833. CLIPPLANE5: boolean;
  23834. CLIPPLANE6: boolean;
  23835. ALPHATEST: boolean;
  23836. DEPTHPREPASS: boolean;
  23837. ALPHAFROMDIFFUSE: boolean;
  23838. POINTSIZE: boolean;
  23839. FOG: boolean;
  23840. SPECULARTERM: boolean;
  23841. DIFFUSEFRESNEL: boolean;
  23842. OPACITYFRESNEL: boolean;
  23843. REFLECTIONFRESNEL: boolean;
  23844. REFRACTIONFRESNEL: boolean;
  23845. EMISSIVEFRESNEL: boolean;
  23846. FRESNEL: boolean;
  23847. NORMAL: boolean;
  23848. UV1: boolean;
  23849. UV2: boolean;
  23850. VERTEXCOLOR: boolean;
  23851. VERTEXALPHA: boolean;
  23852. NUM_BONE_INFLUENCERS: number;
  23853. BonesPerMesh: number;
  23854. BONETEXTURE: boolean;
  23855. BONES_VELOCITY_ENABLED: boolean;
  23856. INSTANCES: boolean;
  23857. THIN_INSTANCES: boolean;
  23858. GLOSSINESS: boolean;
  23859. ROUGHNESS: boolean;
  23860. EMISSIVEASILLUMINATION: boolean;
  23861. LINKEMISSIVEWITHDIFFUSE: boolean;
  23862. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23863. LIGHTMAP: boolean;
  23864. LIGHTMAPDIRECTUV: number;
  23865. OBJECTSPACE_NORMALMAP: boolean;
  23866. USELIGHTMAPASSHADOWMAP: boolean;
  23867. REFLECTIONMAP_3D: boolean;
  23868. REFLECTIONMAP_SPHERICAL: boolean;
  23869. REFLECTIONMAP_PLANAR: boolean;
  23870. REFLECTIONMAP_CUBIC: boolean;
  23871. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23872. REFLECTIONMAP_PROJECTION: boolean;
  23873. REFLECTIONMAP_SKYBOX: boolean;
  23874. REFLECTIONMAP_EXPLICIT: boolean;
  23875. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23876. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23877. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23878. INVERTCUBICMAP: boolean;
  23879. LOGARITHMICDEPTH: boolean;
  23880. REFRACTION: boolean;
  23881. REFRACTIONMAP_3D: boolean;
  23882. REFLECTIONOVERALPHA: boolean;
  23883. TWOSIDEDLIGHTING: boolean;
  23884. SHADOWFLOAT: boolean;
  23885. MORPHTARGETS: boolean;
  23886. MORPHTARGETS_NORMAL: boolean;
  23887. MORPHTARGETS_TANGENT: boolean;
  23888. MORPHTARGETS_UV: boolean;
  23889. NUM_MORPH_INFLUENCERS: number;
  23890. NONUNIFORMSCALING: boolean;
  23891. PREMULTIPLYALPHA: boolean;
  23892. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23893. ALPHABLEND: boolean;
  23894. PREPASS: boolean;
  23895. PREPASS_IRRADIANCE: boolean;
  23896. PREPASS_IRRADIANCE_INDEX: number;
  23897. PREPASS_ALBEDO: boolean;
  23898. PREPASS_ALBEDO_INDEX: number;
  23899. PREPASS_DEPTHNORMAL: boolean;
  23900. PREPASS_DEPTHNORMAL_INDEX: number;
  23901. PREPASS_POSITION: boolean;
  23902. PREPASS_POSITION_INDEX: number;
  23903. PREPASS_VELOCITY: boolean;
  23904. PREPASS_VELOCITY_INDEX: number;
  23905. PREPASS_REFLECTIVITY: boolean;
  23906. PREPASS_REFLECTIVITY_INDEX: number;
  23907. SCENE_MRT_COUNT: number;
  23908. RGBDLIGHTMAP: boolean;
  23909. RGBDREFLECTION: boolean;
  23910. RGBDREFRACTION: boolean;
  23911. IMAGEPROCESSING: boolean;
  23912. VIGNETTE: boolean;
  23913. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23914. VIGNETTEBLENDMODEOPAQUE: boolean;
  23915. TONEMAPPING: boolean;
  23916. TONEMAPPING_ACES: boolean;
  23917. CONTRAST: boolean;
  23918. COLORCURVES: boolean;
  23919. COLORGRADING: boolean;
  23920. COLORGRADING3D: boolean;
  23921. SAMPLER3DGREENDEPTH: boolean;
  23922. SAMPLER3DBGRMAP: boolean;
  23923. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23924. MULTIVIEW: boolean;
  23925. /**
  23926. * If the reflection texture on this material is in linear color space
  23927. * @hidden
  23928. */
  23929. IS_REFLECTION_LINEAR: boolean;
  23930. /**
  23931. * If the refraction texture on this material is in linear color space
  23932. * @hidden
  23933. */
  23934. IS_REFRACTION_LINEAR: boolean;
  23935. EXPOSURE: boolean;
  23936. constructor();
  23937. setReflectionMode(modeToEnable: string): void;
  23938. }
  23939. /**
  23940. * This is the default material used in Babylon. It is the best trade off between quality
  23941. * and performances.
  23942. * @see https://doc.babylonjs.com/babylon101/materials
  23943. */
  23944. export class StandardMaterial extends PushMaterial {
  23945. private _diffuseTexture;
  23946. /**
  23947. * The basic texture of the material as viewed under a light.
  23948. */
  23949. diffuseTexture: Nullable<BaseTexture>;
  23950. private _ambientTexture;
  23951. /**
  23952. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23953. */
  23954. ambientTexture: Nullable<BaseTexture>;
  23955. private _opacityTexture;
  23956. /**
  23957. * Define the transparency of the material from a texture.
  23958. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23959. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23960. */
  23961. opacityTexture: Nullable<BaseTexture>;
  23962. private _reflectionTexture;
  23963. /**
  23964. * Define the texture used to display the reflection.
  23965. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23966. */
  23967. reflectionTexture: Nullable<BaseTexture>;
  23968. private _emissiveTexture;
  23969. /**
  23970. * Define texture of the material as if self lit.
  23971. * This will be mixed in the final result even in the absence of light.
  23972. */
  23973. emissiveTexture: Nullable<BaseTexture>;
  23974. private _specularTexture;
  23975. /**
  23976. * Define how the color and intensity of the highlight given by the light in the material.
  23977. */
  23978. specularTexture: Nullable<BaseTexture>;
  23979. private _bumpTexture;
  23980. /**
  23981. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23982. * 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.
  23983. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23984. */
  23985. bumpTexture: Nullable<BaseTexture>;
  23986. private _lightmapTexture;
  23987. /**
  23988. * Complex lighting can be computationally expensive to compute at runtime.
  23989. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23990. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23991. */
  23992. lightmapTexture: Nullable<BaseTexture>;
  23993. private _refractionTexture;
  23994. /**
  23995. * Define the texture used to display the refraction.
  23996. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23997. */
  23998. refractionTexture: Nullable<BaseTexture>;
  23999. /**
  24000. * The color of the material lit by the environmental background lighting.
  24001. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24002. */
  24003. ambientColor: Color3;
  24004. /**
  24005. * The basic color of the material as viewed under a light.
  24006. */
  24007. diffuseColor: Color3;
  24008. /**
  24009. * Define how the color and intensity of the highlight given by the light in the material.
  24010. */
  24011. specularColor: Color3;
  24012. /**
  24013. * Define the color of the material as if self lit.
  24014. * This will be mixed in the final result even in the absence of light.
  24015. */
  24016. emissiveColor: Color3;
  24017. /**
  24018. * Defines how sharp are the highlights in the material.
  24019. * The bigger the value the sharper giving a more glossy feeling to the result.
  24020. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24021. */
  24022. specularPower: number;
  24023. private _useAlphaFromDiffuseTexture;
  24024. /**
  24025. * Does the transparency come from the diffuse texture alpha channel.
  24026. */
  24027. useAlphaFromDiffuseTexture: boolean;
  24028. private _useEmissiveAsIllumination;
  24029. /**
  24030. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24031. */
  24032. useEmissiveAsIllumination: boolean;
  24033. private _linkEmissiveWithDiffuse;
  24034. /**
  24035. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24036. * the emissive level when the final color is close to one.
  24037. */
  24038. linkEmissiveWithDiffuse: boolean;
  24039. private _useSpecularOverAlpha;
  24040. /**
  24041. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24042. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24043. */
  24044. useSpecularOverAlpha: boolean;
  24045. private _useReflectionOverAlpha;
  24046. /**
  24047. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24048. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24049. */
  24050. useReflectionOverAlpha: boolean;
  24051. private _disableLighting;
  24052. /**
  24053. * Does lights from the scene impacts this material.
  24054. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24055. */
  24056. disableLighting: boolean;
  24057. private _useObjectSpaceNormalMap;
  24058. /**
  24059. * Allows using an object space normal map (instead of tangent space).
  24060. */
  24061. useObjectSpaceNormalMap: boolean;
  24062. private _useParallax;
  24063. /**
  24064. * Is parallax enabled or not.
  24065. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24066. */
  24067. useParallax: boolean;
  24068. private _useParallaxOcclusion;
  24069. /**
  24070. * Is parallax occlusion enabled or not.
  24071. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24072. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24073. */
  24074. useParallaxOcclusion: boolean;
  24075. /**
  24076. * 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.
  24077. */
  24078. parallaxScaleBias: number;
  24079. private _roughness;
  24080. /**
  24081. * Helps to define how blurry the reflections should appears in the material.
  24082. */
  24083. roughness: number;
  24084. /**
  24085. * In case of refraction, define the value of the index of refraction.
  24086. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24087. */
  24088. indexOfRefraction: number;
  24089. /**
  24090. * Invert the refraction texture alongside the y axis.
  24091. * It can be useful with procedural textures or probe for instance.
  24092. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24093. */
  24094. invertRefractionY: boolean;
  24095. /**
  24096. * Defines the alpha limits in alpha test mode.
  24097. */
  24098. alphaCutOff: number;
  24099. private _useLightmapAsShadowmap;
  24100. /**
  24101. * In case of light mapping, define whether the map contains light or shadow informations.
  24102. */
  24103. useLightmapAsShadowmap: boolean;
  24104. private _diffuseFresnelParameters;
  24105. /**
  24106. * Define the diffuse fresnel parameters of the material.
  24107. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24108. */
  24109. diffuseFresnelParameters: FresnelParameters;
  24110. private _opacityFresnelParameters;
  24111. /**
  24112. * Define the opacity fresnel parameters of the material.
  24113. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24114. */
  24115. opacityFresnelParameters: FresnelParameters;
  24116. private _reflectionFresnelParameters;
  24117. /**
  24118. * Define the reflection fresnel parameters of the material.
  24119. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24120. */
  24121. reflectionFresnelParameters: FresnelParameters;
  24122. private _refractionFresnelParameters;
  24123. /**
  24124. * Define the refraction fresnel parameters of the material.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24126. */
  24127. refractionFresnelParameters: FresnelParameters;
  24128. private _emissiveFresnelParameters;
  24129. /**
  24130. * Define the emissive fresnel parameters of the material.
  24131. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24132. */
  24133. emissiveFresnelParameters: FresnelParameters;
  24134. private _useReflectionFresnelFromSpecular;
  24135. /**
  24136. * If true automatically deducts the fresnels values from the material specularity.
  24137. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24138. */
  24139. useReflectionFresnelFromSpecular: boolean;
  24140. private _useGlossinessFromSpecularMapAlpha;
  24141. /**
  24142. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24143. */
  24144. useGlossinessFromSpecularMapAlpha: boolean;
  24145. private _maxSimultaneousLights;
  24146. /**
  24147. * Defines the maximum number of lights that can be used in the material
  24148. */
  24149. maxSimultaneousLights: number;
  24150. private _invertNormalMapX;
  24151. /**
  24152. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24153. */
  24154. invertNormalMapX: boolean;
  24155. private _invertNormalMapY;
  24156. /**
  24157. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24158. */
  24159. invertNormalMapY: boolean;
  24160. private _twoSidedLighting;
  24161. /**
  24162. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24163. */
  24164. twoSidedLighting: boolean;
  24165. /**
  24166. * Default configuration related to image processing available in the standard Material.
  24167. */
  24168. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24169. /**
  24170. * Gets the image processing configuration used either in this material.
  24171. */
  24172. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24173. /**
  24174. * Sets the Default image processing configuration used either in the this material.
  24175. *
  24176. * If sets to null, the scene one is in use.
  24177. */
  24178. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24179. /**
  24180. * Keep track of the image processing observer to allow dispose and replace.
  24181. */
  24182. private _imageProcessingObserver;
  24183. /**
  24184. * Attaches a new image processing configuration to the Standard Material.
  24185. * @param configuration
  24186. */
  24187. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24188. /**
  24189. * Defines additionnal PrePass parameters for the material.
  24190. */
  24191. readonly prePassConfiguration: PrePassConfiguration;
  24192. /**
  24193. * Gets wether the color curves effect is enabled.
  24194. */
  24195. get cameraColorCurvesEnabled(): boolean;
  24196. /**
  24197. * Sets wether the color curves effect is enabled.
  24198. */
  24199. set cameraColorCurvesEnabled(value: boolean);
  24200. /**
  24201. * Gets wether the color grading effect is enabled.
  24202. */
  24203. get cameraColorGradingEnabled(): boolean;
  24204. /**
  24205. * Gets wether the color grading effect is enabled.
  24206. */
  24207. set cameraColorGradingEnabled(value: boolean);
  24208. /**
  24209. * Gets wether tonemapping is enabled or not.
  24210. */
  24211. get cameraToneMappingEnabled(): boolean;
  24212. /**
  24213. * Sets wether tonemapping is enabled or not
  24214. */
  24215. set cameraToneMappingEnabled(value: boolean);
  24216. /**
  24217. * The camera exposure used on this material.
  24218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24219. * This corresponds to a photographic exposure.
  24220. */
  24221. get cameraExposure(): number;
  24222. /**
  24223. * The camera exposure used on this material.
  24224. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24225. * This corresponds to a photographic exposure.
  24226. */
  24227. set cameraExposure(value: number);
  24228. /**
  24229. * Gets The camera contrast used on this material.
  24230. */
  24231. get cameraContrast(): number;
  24232. /**
  24233. * Sets The camera contrast used on this material.
  24234. */
  24235. set cameraContrast(value: number);
  24236. /**
  24237. * Gets the Color Grading 2D Lookup Texture.
  24238. */
  24239. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24240. /**
  24241. * Sets the Color Grading 2D Lookup Texture.
  24242. */
  24243. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24244. /**
  24245. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24246. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24247. * 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;
  24248. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24249. */
  24250. get cameraColorCurves(): Nullable<ColorCurves>;
  24251. /**
  24252. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24253. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24254. * 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;
  24255. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24256. */
  24257. set cameraColorCurves(value: Nullable<ColorCurves>);
  24258. /**
  24259. * Can this material render to several textures at once
  24260. */
  24261. get canRenderToMRT(): boolean;
  24262. /**
  24263. * Defines the detail map parameters for the material.
  24264. */
  24265. readonly detailMap: DetailMapConfiguration;
  24266. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24267. protected _worldViewProjectionMatrix: Matrix;
  24268. protected _globalAmbientColor: Color3;
  24269. protected _useLogarithmicDepth: boolean;
  24270. protected _rebuildInParallel: boolean;
  24271. /**
  24272. * Instantiates a new standard material.
  24273. * This is the default material used in Babylon. It is the best trade off between quality
  24274. * and performances.
  24275. * @see https://doc.babylonjs.com/babylon101/materials
  24276. * @param name Define the name of the material in the scene
  24277. * @param scene Define the scene the material belong to
  24278. */
  24279. constructor(name: string, scene: Scene);
  24280. /**
  24281. * Gets a boolean indicating that current material needs to register RTT
  24282. */
  24283. get hasRenderTargetTextures(): boolean;
  24284. /**
  24285. * Gets the current class name of the material e.g. "StandardMaterial"
  24286. * Mainly use in serialization.
  24287. * @returns the class name
  24288. */
  24289. getClassName(): string;
  24290. /**
  24291. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24292. * You can try switching to logarithmic depth.
  24293. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24294. */
  24295. get useLogarithmicDepth(): boolean;
  24296. set useLogarithmicDepth(value: boolean);
  24297. /**
  24298. * Specifies if the material will require alpha blending
  24299. * @returns a boolean specifying if alpha blending is needed
  24300. */
  24301. needAlphaBlending(): boolean;
  24302. /**
  24303. * Specifies if this material should be rendered in alpha test mode
  24304. * @returns a boolean specifying if an alpha test is needed.
  24305. */
  24306. needAlphaTesting(): boolean;
  24307. /**
  24308. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24309. */
  24310. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24311. /**
  24312. * Specifies whether or not there is a usable alpha channel for transparency.
  24313. */
  24314. protected _hasAlphaChannel(): boolean;
  24315. /**
  24316. * Get the texture used for alpha test purpose.
  24317. * @returns the diffuse texture in case of the standard material.
  24318. */
  24319. getAlphaTestTexture(): Nullable<BaseTexture>;
  24320. /**
  24321. * Get if the submesh is ready to be used and all its information available.
  24322. * Child classes can use it to update shaders
  24323. * @param mesh defines the mesh to check
  24324. * @param subMesh defines which submesh to check
  24325. * @param useInstances specifies that instances should be used
  24326. * @returns a boolean indicating that the submesh is ready or not
  24327. */
  24328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24329. /**
  24330. * Builds the material UBO layouts.
  24331. * Used internally during the effect preparation.
  24332. */
  24333. buildUniformLayout(): void;
  24334. /**
  24335. * Unbinds the material from the mesh
  24336. */
  24337. unbind(): void;
  24338. /**
  24339. * Binds the submesh to this material by preparing the effect and shader to draw
  24340. * @param world defines the world transformation matrix
  24341. * @param mesh defines the mesh containing the submesh
  24342. * @param subMesh defines the submesh to bind the material to
  24343. */
  24344. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24345. /**
  24346. * Get the list of animatables in the material.
  24347. * @returns the list of animatables object used in the material
  24348. */
  24349. getAnimatables(): IAnimatable[];
  24350. /**
  24351. * Gets the active textures from the material
  24352. * @returns an array of textures
  24353. */
  24354. getActiveTextures(): BaseTexture[];
  24355. /**
  24356. * Specifies if the material uses a texture
  24357. * @param texture defines the texture to check against the material
  24358. * @returns a boolean specifying if the material uses the texture
  24359. */
  24360. hasTexture(texture: BaseTexture): boolean;
  24361. /**
  24362. * Disposes the material
  24363. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24364. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24365. */
  24366. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24367. /**
  24368. * Makes a duplicate of the material, and gives it a new name
  24369. * @param name defines the new name for the duplicated material
  24370. * @returns the cloned material
  24371. */
  24372. clone(name: string): StandardMaterial;
  24373. /**
  24374. * Serializes this material in a JSON representation
  24375. * @returns the serialized material object
  24376. */
  24377. serialize(): any;
  24378. /**
  24379. * Creates a standard material from parsed material data
  24380. * @param source defines the JSON representation of the material
  24381. * @param scene defines the hosting scene
  24382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24383. * @returns a new standard material
  24384. */
  24385. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24386. /**
  24387. * Are diffuse textures enabled in the application.
  24388. */
  24389. static get DiffuseTextureEnabled(): boolean;
  24390. static set DiffuseTextureEnabled(value: boolean);
  24391. /**
  24392. * Are detail textures enabled in the application.
  24393. */
  24394. static get DetailTextureEnabled(): boolean;
  24395. static set DetailTextureEnabled(value: boolean);
  24396. /**
  24397. * Are ambient textures enabled in the application.
  24398. */
  24399. static get AmbientTextureEnabled(): boolean;
  24400. static set AmbientTextureEnabled(value: boolean);
  24401. /**
  24402. * Are opacity textures enabled in the application.
  24403. */
  24404. static get OpacityTextureEnabled(): boolean;
  24405. static set OpacityTextureEnabled(value: boolean);
  24406. /**
  24407. * Are reflection textures enabled in the application.
  24408. */
  24409. static get ReflectionTextureEnabled(): boolean;
  24410. static set ReflectionTextureEnabled(value: boolean);
  24411. /**
  24412. * Are emissive textures enabled in the application.
  24413. */
  24414. static get EmissiveTextureEnabled(): boolean;
  24415. static set EmissiveTextureEnabled(value: boolean);
  24416. /**
  24417. * Are specular textures enabled in the application.
  24418. */
  24419. static get SpecularTextureEnabled(): boolean;
  24420. static set SpecularTextureEnabled(value: boolean);
  24421. /**
  24422. * Are bump textures enabled in the application.
  24423. */
  24424. static get BumpTextureEnabled(): boolean;
  24425. static set BumpTextureEnabled(value: boolean);
  24426. /**
  24427. * Are lightmap textures enabled in the application.
  24428. */
  24429. static get LightmapTextureEnabled(): boolean;
  24430. static set LightmapTextureEnabled(value: boolean);
  24431. /**
  24432. * Are refraction textures enabled in the application.
  24433. */
  24434. static get RefractionTextureEnabled(): boolean;
  24435. static set RefractionTextureEnabled(value: boolean);
  24436. /**
  24437. * Are color grading textures enabled in the application.
  24438. */
  24439. static get ColorGradingTextureEnabled(): boolean;
  24440. static set ColorGradingTextureEnabled(value: boolean);
  24441. /**
  24442. * Are fresnels enabled in the application.
  24443. */
  24444. static get FresnelEnabled(): boolean;
  24445. static set FresnelEnabled(value: boolean);
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. /** @hidden */
  24450. export var rgbdDecodePixelShader: {
  24451. name: string;
  24452. shader: string;
  24453. };
  24454. }
  24455. declare module BABYLON {
  24456. /**
  24457. * Class used to host RGBD texture specific utilities
  24458. */
  24459. export class RGBDTextureTools {
  24460. /**
  24461. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24462. * @param texture the texture to expand.
  24463. */
  24464. static ExpandRGBDTexture(texture: Texture): void;
  24465. }
  24466. }
  24467. declare module BABYLON {
  24468. /**
  24469. * Class used to host texture specific utilities
  24470. */
  24471. export class BRDFTextureTools {
  24472. /**
  24473. * Prevents texture cache collision
  24474. */
  24475. private static _instanceNumber;
  24476. /**
  24477. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24478. * @param scene defines the hosting scene
  24479. * @returns the environment BRDF texture
  24480. */
  24481. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24482. private static _environmentBRDFBase64Texture;
  24483. }
  24484. }
  24485. declare module BABYLON {
  24486. /**
  24487. * @hidden
  24488. */
  24489. export interface IMaterialClearCoatDefines {
  24490. CLEARCOAT: boolean;
  24491. CLEARCOAT_DEFAULTIOR: boolean;
  24492. CLEARCOAT_TEXTURE: boolean;
  24493. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24494. CLEARCOAT_TEXTUREDIRECTUV: number;
  24495. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24496. CLEARCOAT_BUMP: boolean;
  24497. CLEARCOAT_BUMPDIRECTUV: number;
  24498. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24499. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24500. CLEARCOAT_REMAP_F0: boolean;
  24501. CLEARCOAT_TINT: boolean;
  24502. CLEARCOAT_TINT_TEXTURE: boolean;
  24503. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24504. /** @hidden */
  24505. _areTexturesDirty: boolean;
  24506. }
  24507. /**
  24508. * Define the code related to the clear coat parameters of the pbr material.
  24509. */
  24510. export class PBRClearCoatConfiguration {
  24511. /**
  24512. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24513. * The default fits with a polyurethane material.
  24514. */
  24515. private static readonly _DefaultIndexOfRefraction;
  24516. private _isEnabled;
  24517. /**
  24518. * Defines if the clear coat is enabled in the material.
  24519. */
  24520. isEnabled: boolean;
  24521. /**
  24522. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24523. */
  24524. intensity: number;
  24525. /**
  24526. * Defines the clear coat layer roughness.
  24527. */
  24528. roughness: number;
  24529. private _indexOfRefraction;
  24530. /**
  24531. * Defines the index of refraction of the clear coat.
  24532. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24533. * The default fits with a polyurethane material.
  24534. * Changing the default value is more performance intensive.
  24535. */
  24536. indexOfRefraction: number;
  24537. private _texture;
  24538. /**
  24539. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24540. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24541. * if textureRoughness is not empty, else no texture roughness is used
  24542. */
  24543. texture: Nullable<BaseTexture>;
  24544. private _useRoughnessFromMainTexture;
  24545. /**
  24546. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24547. * If false, the green channel from textureRoughness is used for roughness
  24548. */
  24549. useRoughnessFromMainTexture: boolean;
  24550. private _textureRoughness;
  24551. /**
  24552. * Stores the clear coat roughness in a texture (green channel)
  24553. * Not used if useRoughnessFromMainTexture is true
  24554. */
  24555. textureRoughness: Nullable<BaseTexture>;
  24556. private _remapF0OnInterfaceChange;
  24557. /**
  24558. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24559. */
  24560. remapF0OnInterfaceChange: boolean;
  24561. private _bumpTexture;
  24562. /**
  24563. * Define the clear coat specific bump texture.
  24564. */
  24565. bumpTexture: Nullable<BaseTexture>;
  24566. private _isTintEnabled;
  24567. /**
  24568. * Defines if the clear coat tint is enabled in the material.
  24569. */
  24570. isTintEnabled: boolean;
  24571. /**
  24572. * Defines the clear coat tint of the material.
  24573. * This is only use if tint is enabled
  24574. */
  24575. tintColor: Color3;
  24576. /**
  24577. * Defines the distance at which the tint color should be found in the
  24578. * clear coat media.
  24579. * This is only use if tint is enabled
  24580. */
  24581. tintColorAtDistance: number;
  24582. /**
  24583. * Defines the clear coat layer thickness.
  24584. * This is only use if tint is enabled
  24585. */
  24586. tintThickness: number;
  24587. private _tintTexture;
  24588. /**
  24589. * Stores the clear tint values in a texture.
  24590. * rgb is tint
  24591. * a is a thickness factor
  24592. */
  24593. tintTexture: Nullable<BaseTexture>;
  24594. /** @hidden */
  24595. private _internalMarkAllSubMeshesAsTexturesDirty;
  24596. /** @hidden */
  24597. _markAllSubMeshesAsTexturesDirty(): void;
  24598. /**
  24599. * Instantiate a new istance of clear coat configuration.
  24600. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24601. */
  24602. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24603. /**
  24604. * Gets wehter the submesh is ready to be used or not.
  24605. * @param defines the list of "defines" to update.
  24606. * @param scene defines the scene the material belongs to.
  24607. * @param engine defines the engine the material belongs to.
  24608. * @param disableBumpMap defines wether the material disables bump or not.
  24609. * @returns - boolean indicating that the submesh is ready or not.
  24610. */
  24611. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24612. /**
  24613. * Checks to see if a texture is used in the material.
  24614. * @param defines the list of "defines" to update.
  24615. * @param scene defines the scene to the material belongs to.
  24616. */
  24617. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24618. /**
  24619. * Binds the material data.
  24620. * @param uniformBuffer defines the Uniform buffer to fill in.
  24621. * @param scene defines the scene the material belongs to.
  24622. * @param engine defines the engine the material belongs to.
  24623. * @param disableBumpMap defines wether the material disables bump or not.
  24624. * @param isFrozen defines wether the material is frozen or not.
  24625. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24626. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24627. * @param subMesh the submesh to bind data for
  24628. */
  24629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24630. /**
  24631. * Checks to see if a texture is used in the material.
  24632. * @param texture - Base texture to use.
  24633. * @returns - Boolean specifying if a texture is used in the material.
  24634. */
  24635. hasTexture(texture: BaseTexture): boolean;
  24636. /**
  24637. * Returns an array of the actively used textures.
  24638. * @param activeTextures Array of BaseTextures
  24639. */
  24640. getActiveTextures(activeTextures: BaseTexture[]): void;
  24641. /**
  24642. * Returns the animatable textures.
  24643. * @param animatables Array of animatable textures.
  24644. */
  24645. getAnimatables(animatables: IAnimatable[]): void;
  24646. /**
  24647. * Disposes the resources of the material.
  24648. * @param forceDisposeTextures - Forces the disposal of all textures.
  24649. */
  24650. dispose(forceDisposeTextures?: boolean): void;
  24651. /**
  24652. * Get the current class name of the texture useful for serialization or dynamic coding.
  24653. * @returns "PBRClearCoatConfiguration"
  24654. */
  24655. getClassName(): string;
  24656. /**
  24657. * Add fallbacks to the effect fallbacks list.
  24658. * @param defines defines the Base texture to use.
  24659. * @param fallbacks defines the current fallback list.
  24660. * @param currentRank defines the current fallback rank.
  24661. * @returns the new fallback rank.
  24662. */
  24663. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24664. /**
  24665. * Add the required uniforms to the current list.
  24666. * @param uniforms defines the current uniform list.
  24667. */
  24668. static AddUniforms(uniforms: string[]): void;
  24669. /**
  24670. * Add the required samplers to the current list.
  24671. * @param samplers defines the current sampler list.
  24672. */
  24673. static AddSamplers(samplers: string[]): void;
  24674. /**
  24675. * Add the required uniforms to the current buffer.
  24676. * @param uniformBuffer defines the current uniform buffer.
  24677. */
  24678. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24679. /**
  24680. * Makes a duplicate of the current configuration into another one.
  24681. * @param clearCoatConfiguration define the config where to copy the info
  24682. */
  24683. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24684. /**
  24685. * Serializes this clear coat configuration.
  24686. * @returns - An object with the serialized config.
  24687. */
  24688. serialize(): any;
  24689. /**
  24690. * Parses a anisotropy Configuration from a serialized object.
  24691. * @param source - Serialized object.
  24692. * @param scene Defines the scene we are parsing for
  24693. * @param rootUrl Defines the rootUrl to load from
  24694. */
  24695. parse(source: any, scene: Scene, rootUrl: string): void;
  24696. }
  24697. }
  24698. declare module BABYLON {
  24699. /**
  24700. * @hidden
  24701. */
  24702. export interface IMaterialAnisotropicDefines {
  24703. ANISOTROPIC: boolean;
  24704. ANISOTROPIC_TEXTURE: boolean;
  24705. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24706. MAINUV1: boolean;
  24707. _areTexturesDirty: boolean;
  24708. _needUVs: boolean;
  24709. }
  24710. /**
  24711. * Define the code related to the anisotropic parameters of the pbr material.
  24712. */
  24713. export class PBRAnisotropicConfiguration {
  24714. private _isEnabled;
  24715. /**
  24716. * Defines if the anisotropy is enabled in the material.
  24717. */
  24718. isEnabled: boolean;
  24719. /**
  24720. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24721. */
  24722. intensity: number;
  24723. /**
  24724. * Defines if the effect is along the tangents, bitangents or in between.
  24725. * By default, the effect is "strectching" the highlights along the tangents.
  24726. */
  24727. direction: Vector2;
  24728. private _texture;
  24729. /**
  24730. * Stores the anisotropy values in a texture.
  24731. * rg is direction (like normal from -1 to 1)
  24732. * b is a intensity
  24733. */
  24734. texture: Nullable<BaseTexture>;
  24735. /** @hidden */
  24736. private _internalMarkAllSubMeshesAsTexturesDirty;
  24737. /** @hidden */
  24738. _markAllSubMeshesAsTexturesDirty(): void;
  24739. /**
  24740. * Instantiate a new istance of anisotropy configuration.
  24741. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24742. */
  24743. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24744. /**
  24745. * Specifies that the submesh is ready to be used.
  24746. * @param defines the list of "defines" to update.
  24747. * @param scene defines the scene the material belongs to.
  24748. * @returns - boolean indicating that the submesh is ready or not.
  24749. */
  24750. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24751. /**
  24752. * Checks to see if a texture is used in the material.
  24753. * @param defines the list of "defines" to update.
  24754. * @param mesh the mesh we are preparing the defines for.
  24755. * @param scene defines the scene the material belongs to.
  24756. */
  24757. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24758. /**
  24759. * Binds the material data.
  24760. * @param uniformBuffer defines the Uniform buffer to fill in.
  24761. * @param scene defines the scene the material belongs to.
  24762. * @param isFrozen defines wether the material is frozen or not.
  24763. */
  24764. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24765. /**
  24766. * Checks to see if a texture is used in the material.
  24767. * @param texture - Base texture to use.
  24768. * @returns - Boolean specifying if a texture is used in the material.
  24769. */
  24770. hasTexture(texture: BaseTexture): boolean;
  24771. /**
  24772. * Returns an array of the actively used textures.
  24773. * @param activeTextures Array of BaseTextures
  24774. */
  24775. getActiveTextures(activeTextures: BaseTexture[]): void;
  24776. /**
  24777. * Returns the animatable textures.
  24778. * @param animatables Array of animatable textures.
  24779. */
  24780. getAnimatables(animatables: IAnimatable[]): void;
  24781. /**
  24782. * Disposes the resources of the material.
  24783. * @param forceDisposeTextures - Forces the disposal of all textures.
  24784. */
  24785. dispose(forceDisposeTextures?: boolean): void;
  24786. /**
  24787. * Get the current class name of the texture useful for serialization or dynamic coding.
  24788. * @returns "PBRAnisotropicConfiguration"
  24789. */
  24790. getClassName(): string;
  24791. /**
  24792. * Add fallbacks to the effect fallbacks list.
  24793. * @param defines defines the Base texture to use.
  24794. * @param fallbacks defines the current fallback list.
  24795. * @param currentRank defines the current fallback rank.
  24796. * @returns the new fallback rank.
  24797. */
  24798. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24799. /**
  24800. * Add the required uniforms to the current list.
  24801. * @param uniforms defines the current uniform list.
  24802. */
  24803. static AddUniforms(uniforms: string[]): void;
  24804. /**
  24805. * Add the required uniforms to the current buffer.
  24806. * @param uniformBuffer defines the current uniform buffer.
  24807. */
  24808. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24809. /**
  24810. * Add the required samplers to the current list.
  24811. * @param samplers defines the current sampler list.
  24812. */
  24813. static AddSamplers(samplers: string[]): void;
  24814. /**
  24815. * Makes a duplicate of the current configuration into another one.
  24816. * @param anisotropicConfiguration define the config where to copy the info
  24817. */
  24818. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24819. /**
  24820. * Serializes this anisotropy configuration.
  24821. * @returns - An object with the serialized config.
  24822. */
  24823. serialize(): any;
  24824. /**
  24825. * Parses a anisotropy Configuration from a serialized object.
  24826. * @param source - Serialized object.
  24827. * @param scene Defines the scene we are parsing for
  24828. * @param rootUrl Defines the rootUrl to load from
  24829. */
  24830. parse(source: any, scene: Scene, rootUrl: string): void;
  24831. }
  24832. }
  24833. declare module BABYLON {
  24834. /**
  24835. * @hidden
  24836. */
  24837. export interface IMaterialBRDFDefines {
  24838. BRDF_V_HEIGHT_CORRELATED: boolean;
  24839. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24840. SPHERICAL_HARMONICS: boolean;
  24841. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24842. /** @hidden */
  24843. _areMiscDirty: boolean;
  24844. }
  24845. /**
  24846. * Define the code related to the BRDF parameters of the pbr material.
  24847. */
  24848. export class PBRBRDFConfiguration {
  24849. /**
  24850. * Default value used for the energy conservation.
  24851. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24852. */
  24853. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24854. /**
  24855. * Default value used for the Smith Visibility Height Correlated mode.
  24856. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24857. */
  24858. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24859. /**
  24860. * Default value used for the IBL diffuse part.
  24861. * This can help switching back to the polynomials mode globally which is a tiny bit
  24862. * less GPU intensive at the drawback of a lower quality.
  24863. */
  24864. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24865. /**
  24866. * Default value used for activating energy conservation for the specular workflow.
  24867. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24868. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24869. */
  24870. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24871. private _useEnergyConservation;
  24872. /**
  24873. * Defines if the material uses energy conservation.
  24874. */
  24875. useEnergyConservation: boolean;
  24876. private _useSmithVisibilityHeightCorrelated;
  24877. /**
  24878. * LEGACY Mode set to false
  24879. * Defines if the material uses height smith correlated visibility term.
  24880. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24881. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24882. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24883. * Not relying on height correlated will also disable energy conservation.
  24884. */
  24885. useSmithVisibilityHeightCorrelated: boolean;
  24886. private _useSphericalHarmonics;
  24887. /**
  24888. * LEGACY Mode set to false
  24889. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24890. * diffuse part of the IBL.
  24891. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24892. * to the ground truth.
  24893. */
  24894. useSphericalHarmonics: boolean;
  24895. private _useSpecularGlossinessInputEnergyConservation;
  24896. /**
  24897. * Defines if the material uses energy conservation, when the specular workflow is active.
  24898. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24899. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24900. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24901. */
  24902. useSpecularGlossinessInputEnergyConservation: boolean;
  24903. /** @hidden */
  24904. private _internalMarkAllSubMeshesAsMiscDirty;
  24905. /** @hidden */
  24906. _markAllSubMeshesAsMiscDirty(): void;
  24907. /**
  24908. * Instantiate a new istance of clear coat configuration.
  24909. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24910. */
  24911. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24912. /**
  24913. * Checks to see if a texture is used in the material.
  24914. * @param defines the list of "defines" to update.
  24915. */
  24916. prepareDefines(defines: IMaterialBRDFDefines): void;
  24917. /**
  24918. * Get the current class name of the texture useful for serialization or dynamic coding.
  24919. * @returns "PBRClearCoatConfiguration"
  24920. */
  24921. getClassName(): string;
  24922. /**
  24923. * Makes a duplicate of the current configuration into another one.
  24924. * @param brdfConfiguration define the config where to copy the info
  24925. */
  24926. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24927. /**
  24928. * Serializes this BRDF configuration.
  24929. * @returns - An object with the serialized config.
  24930. */
  24931. serialize(): any;
  24932. /**
  24933. * Parses a anisotropy Configuration from a serialized object.
  24934. * @param source - Serialized object.
  24935. * @param scene Defines the scene we are parsing for
  24936. * @param rootUrl Defines the rootUrl to load from
  24937. */
  24938. parse(source: any, scene: Scene, rootUrl: string): void;
  24939. }
  24940. }
  24941. declare module BABYLON {
  24942. /**
  24943. * @hidden
  24944. */
  24945. export interface IMaterialSheenDefines {
  24946. SHEEN: boolean;
  24947. SHEEN_TEXTURE: boolean;
  24948. SHEEN_TEXTURE_ROUGHNESS: boolean;
  24949. SHEEN_TEXTUREDIRECTUV: number;
  24950. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  24951. SHEEN_LINKWITHALBEDO: boolean;
  24952. SHEEN_ROUGHNESS: boolean;
  24953. SHEEN_ALBEDOSCALING: boolean;
  24954. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24955. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24956. /** @hidden */
  24957. _areTexturesDirty: boolean;
  24958. }
  24959. /**
  24960. * Define the code related to the Sheen parameters of the pbr material.
  24961. */
  24962. export class PBRSheenConfiguration {
  24963. private _isEnabled;
  24964. /**
  24965. * Defines if the material uses sheen.
  24966. */
  24967. isEnabled: boolean;
  24968. private _linkSheenWithAlbedo;
  24969. /**
  24970. * Defines if the sheen is linked to the sheen color.
  24971. */
  24972. linkSheenWithAlbedo: boolean;
  24973. /**
  24974. * Defines the sheen intensity.
  24975. */
  24976. intensity: number;
  24977. /**
  24978. * Defines the sheen color.
  24979. */
  24980. color: Color3;
  24981. private _texture;
  24982. /**
  24983. * Stores the sheen tint values in a texture.
  24984. * rgb is tint
  24985. * 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)
  24986. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  24987. */
  24988. texture: Nullable<BaseTexture>;
  24989. private _useRoughnessFromMainTexture;
  24990. /**
  24991. * Indicates that the alpha channel of the texture property will be used for roughness.
  24992. * Has no effect if the roughness (and texture!) property is not defined
  24993. */
  24994. useRoughnessFromMainTexture: boolean;
  24995. private _roughness;
  24996. /**
  24997. * Defines the sheen roughness.
  24998. * It is not taken into account if linkSheenWithAlbedo is true.
  24999. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25000. */
  25001. roughness: Nullable<number>;
  25002. private _textureRoughness;
  25003. /**
  25004. * Stores the sheen roughness in a texture.
  25005. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25006. */
  25007. textureRoughness: Nullable<BaseTexture>;
  25008. private _albedoScaling;
  25009. /**
  25010. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25011. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25012. * making it easier to setup and tweak the effect
  25013. */
  25014. albedoScaling: boolean;
  25015. /** @hidden */
  25016. private _internalMarkAllSubMeshesAsTexturesDirty;
  25017. /** @hidden */
  25018. _markAllSubMeshesAsTexturesDirty(): void;
  25019. /**
  25020. * Instantiate a new istance of clear coat configuration.
  25021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25022. */
  25023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25024. /**
  25025. * Specifies that the submesh is ready to be used.
  25026. * @param defines the list of "defines" to update.
  25027. * @param scene defines the scene the material belongs to.
  25028. * @returns - boolean indicating that the submesh is ready or not.
  25029. */
  25030. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25031. /**
  25032. * Checks to see if a texture is used in the material.
  25033. * @param defines the list of "defines" to update.
  25034. * @param scene defines the scene the material belongs to.
  25035. */
  25036. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25037. /**
  25038. * Binds the material data.
  25039. * @param uniformBuffer defines the Uniform buffer to fill in.
  25040. * @param scene defines the scene the material belongs to.
  25041. * @param isFrozen defines wether the material is frozen or not.
  25042. * @param subMesh the submesh to bind data for
  25043. */
  25044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25045. /**
  25046. * Checks to see if a texture is used in the material.
  25047. * @param texture - Base texture to use.
  25048. * @returns - Boolean specifying if a texture is used in the material.
  25049. */
  25050. hasTexture(texture: BaseTexture): boolean;
  25051. /**
  25052. * Returns an array of the actively used textures.
  25053. * @param activeTextures Array of BaseTextures
  25054. */
  25055. getActiveTextures(activeTextures: BaseTexture[]): void;
  25056. /**
  25057. * Returns the animatable textures.
  25058. * @param animatables Array of animatable textures.
  25059. */
  25060. getAnimatables(animatables: IAnimatable[]): void;
  25061. /**
  25062. * Disposes the resources of the material.
  25063. * @param forceDisposeTextures - Forces the disposal of all textures.
  25064. */
  25065. dispose(forceDisposeTextures?: boolean): void;
  25066. /**
  25067. * Get the current class name of the texture useful for serialization or dynamic coding.
  25068. * @returns "PBRSheenConfiguration"
  25069. */
  25070. getClassName(): string;
  25071. /**
  25072. * Add fallbacks to the effect fallbacks list.
  25073. * @param defines defines the Base texture to use.
  25074. * @param fallbacks defines the current fallback list.
  25075. * @param currentRank defines the current fallback rank.
  25076. * @returns the new fallback rank.
  25077. */
  25078. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25079. /**
  25080. * Add the required uniforms to the current list.
  25081. * @param uniforms defines the current uniform list.
  25082. */
  25083. static AddUniforms(uniforms: string[]): void;
  25084. /**
  25085. * Add the required uniforms to the current buffer.
  25086. * @param uniformBuffer defines the current uniform buffer.
  25087. */
  25088. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25089. /**
  25090. * Add the required samplers to the current list.
  25091. * @param samplers defines the current sampler list.
  25092. */
  25093. static AddSamplers(samplers: string[]): void;
  25094. /**
  25095. * Makes a duplicate of the current configuration into another one.
  25096. * @param sheenConfiguration define the config where to copy the info
  25097. */
  25098. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25099. /**
  25100. * Serializes this BRDF configuration.
  25101. * @returns - An object with the serialized config.
  25102. */
  25103. serialize(): any;
  25104. /**
  25105. * Parses a anisotropy Configuration from a serialized object.
  25106. * @param source - Serialized object.
  25107. * @param scene Defines the scene we are parsing for
  25108. * @param rootUrl Defines the rootUrl to load from
  25109. */
  25110. parse(source: any, scene: Scene, rootUrl: string): void;
  25111. }
  25112. }
  25113. declare module BABYLON {
  25114. /**
  25115. * @hidden
  25116. */
  25117. export interface IMaterialSubSurfaceDefines {
  25118. SUBSURFACE: boolean;
  25119. SS_REFRACTION: boolean;
  25120. SS_TRANSLUCENCY: boolean;
  25121. SS_SCATTERING: boolean;
  25122. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25123. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25124. SS_REFRACTIONMAP_3D: boolean;
  25125. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25126. SS_LODINREFRACTIONALPHA: boolean;
  25127. SS_GAMMAREFRACTION: boolean;
  25128. SS_RGBDREFRACTION: boolean;
  25129. SS_LINEARSPECULARREFRACTION: boolean;
  25130. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25131. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25132. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25133. /** @hidden */
  25134. _areTexturesDirty: boolean;
  25135. }
  25136. /**
  25137. * Define the code related to the sub surface parameters of the pbr material.
  25138. */
  25139. export class PBRSubSurfaceConfiguration {
  25140. private _isRefractionEnabled;
  25141. /**
  25142. * Defines if the refraction is enabled in the material.
  25143. */
  25144. isRefractionEnabled: boolean;
  25145. private _isTranslucencyEnabled;
  25146. /**
  25147. * Defines if the translucency is enabled in the material.
  25148. */
  25149. isTranslucencyEnabled: boolean;
  25150. private _isScatteringEnabled;
  25151. /**
  25152. * Defines if the sub surface scattering is enabled in the material.
  25153. */
  25154. isScatteringEnabled: boolean;
  25155. private _scatteringDiffusionProfileIndex;
  25156. /**
  25157. * Diffusion profile for subsurface scattering.
  25158. * Useful for better scattering in the skins or foliages.
  25159. */
  25160. get scatteringDiffusionProfile(): Nullable<Color3>;
  25161. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25162. /**
  25163. * Defines the refraction intensity of the material.
  25164. * The refraction when enabled replaces the Diffuse part of the material.
  25165. * The intensity helps transitionning between diffuse and refraction.
  25166. */
  25167. refractionIntensity: number;
  25168. /**
  25169. * Defines the translucency intensity of the material.
  25170. * When translucency has been enabled, this defines how much of the "translucency"
  25171. * is addded to the diffuse part of the material.
  25172. */
  25173. translucencyIntensity: number;
  25174. /**
  25175. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25176. */
  25177. useAlbedoToTintRefraction: boolean;
  25178. private _thicknessTexture;
  25179. /**
  25180. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25181. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25182. * 0 would mean minimumThickness
  25183. * 1 would mean maximumThickness
  25184. * The other channels might be use as a mask to vary the different effects intensity.
  25185. */
  25186. thicknessTexture: Nullable<BaseTexture>;
  25187. private _refractionTexture;
  25188. /**
  25189. * Defines the texture to use for refraction.
  25190. */
  25191. refractionTexture: Nullable<BaseTexture>;
  25192. private _indexOfRefraction;
  25193. /**
  25194. * Index of refraction of the material base layer.
  25195. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25196. *
  25197. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25198. *
  25199. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25200. */
  25201. indexOfRefraction: number;
  25202. private _volumeIndexOfRefraction;
  25203. /**
  25204. * Index of refraction of the material's volume.
  25205. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25206. *
  25207. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25208. * the volume will use the same IOR as the surface.
  25209. */
  25210. get volumeIndexOfRefraction(): number;
  25211. set volumeIndexOfRefraction(value: number);
  25212. private _invertRefractionY;
  25213. /**
  25214. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25215. */
  25216. invertRefractionY: boolean;
  25217. private _linkRefractionWithTransparency;
  25218. /**
  25219. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25220. * Materials half opaque for instance using refraction could benefit from this control.
  25221. */
  25222. linkRefractionWithTransparency: boolean;
  25223. /**
  25224. * Defines the minimum thickness stored in the thickness map.
  25225. * If no thickness map is defined, this value will be used to simulate thickness.
  25226. */
  25227. minimumThickness: number;
  25228. /**
  25229. * Defines the maximum thickness stored in the thickness map.
  25230. */
  25231. maximumThickness: number;
  25232. /**
  25233. * Defines the volume tint of the material.
  25234. * This is used for both translucency and scattering.
  25235. */
  25236. tintColor: Color3;
  25237. /**
  25238. * Defines the distance at which the tint color should be found in the media.
  25239. * This is used for refraction only.
  25240. */
  25241. tintColorAtDistance: number;
  25242. /**
  25243. * Defines how far each channel transmit through the media.
  25244. * It is defined as a color to simplify it selection.
  25245. */
  25246. diffusionDistance: Color3;
  25247. private _useMaskFromThicknessTexture;
  25248. /**
  25249. * Stores the intensity of the different subsurface effects in the thickness texture.
  25250. * * the green channel is the translucency intensity.
  25251. * * the blue channel is the scattering intensity.
  25252. * * the alpha channel is the refraction intensity.
  25253. */
  25254. useMaskFromThicknessTexture: boolean;
  25255. private _scene;
  25256. /** @hidden */
  25257. private _internalMarkAllSubMeshesAsTexturesDirty;
  25258. private _internalMarkScenePrePassDirty;
  25259. /** @hidden */
  25260. _markAllSubMeshesAsTexturesDirty(): void;
  25261. /** @hidden */
  25262. _markScenePrePassDirty(): void;
  25263. /**
  25264. * Instantiate a new istance of sub surface configuration.
  25265. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25266. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25267. * @param scene The scene
  25268. */
  25269. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25270. /**
  25271. * Gets wehter the submesh is ready to be used or not.
  25272. * @param defines the list of "defines" to update.
  25273. * @param scene defines the scene the material belongs to.
  25274. * @returns - boolean indicating that the submesh is ready or not.
  25275. */
  25276. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25277. /**
  25278. * Checks to see if a texture is used in the material.
  25279. * @param defines the list of "defines" to update.
  25280. * @param scene defines the scene to the material belongs to.
  25281. */
  25282. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25283. /**
  25284. * Binds the material data.
  25285. * @param uniformBuffer defines the Uniform buffer to fill in.
  25286. * @param scene defines the scene the material belongs to.
  25287. * @param engine defines the engine the material belongs to.
  25288. * @param isFrozen defines whether the material is frozen or not.
  25289. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25290. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25291. */
  25292. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25293. /**
  25294. * Unbinds the material from the mesh.
  25295. * @param activeEffect defines the effect that should be unbound from.
  25296. * @returns true if unbound, otherwise false
  25297. */
  25298. unbind(activeEffect: Effect): boolean;
  25299. /**
  25300. * Returns the texture used for refraction or null if none is used.
  25301. * @param scene defines the scene the material belongs to.
  25302. * @returns - Refraction texture if present. If no refraction texture and refraction
  25303. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25304. */
  25305. private _getRefractionTexture;
  25306. /**
  25307. * Returns true if alpha blending should be disabled.
  25308. */
  25309. get disableAlphaBlending(): boolean;
  25310. /**
  25311. * Fills the list of render target textures.
  25312. * @param renderTargets the list of render targets to update
  25313. */
  25314. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25315. /**
  25316. * Checks to see if a texture is used in the material.
  25317. * @param texture - Base texture to use.
  25318. * @returns - Boolean specifying if a texture is used in the material.
  25319. */
  25320. hasTexture(texture: BaseTexture): boolean;
  25321. /**
  25322. * Gets a boolean indicating that current material needs to register RTT
  25323. * @returns true if this uses a render target otherwise false.
  25324. */
  25325. hasRenderTargetTextures(): boolean;
  25326. /**
  25327. * Returns an array of the actively used textures.
  25328. * @param activeTextures Array of BaseTextures
  25329. */
  25330. getActiveTextures(activeTextures: BaseTexture[]): void;
  25331. /**
  25332. * Returns the animatable textures.
  25333. * @param animatables Array of animatable textures.
  25334. */
  25335. getAnimatables(animatables: IAnimatable[]): void;
  25336. /**
  25337. * Disposes the resources of the material.
  25338. * @param forceDisposeTextures - Forces the disposal of all textures.
  25339. */
  25340. dispose(forceDisposeTextures?: boolean): void;
  25341. /**
  25342. * Get the current class name of the texture useful for serialization or dynamic coding.
  25343. * @returns "PBRSubSurfaceConfiguration"
  25344. */
  25345. getClassName(): string;
  25346. /**
  25347. * Add fallbacks to the effect fallbacks list.
  25348. * @param defines defines the Base texture to use.
  25349. * @param fallbacks defines the current fallback list.
  25350. * @param currentRank defines the current fallback rank.
  25351. * @returns the new fallback rank.
  25352. */
  25353. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25354. /**
  25355. * Add the required uniforms to the current list.
  25356. * @param uniforms defines the current uniform list.
  25357. */
  25358. static AddUniforms(uniforms: string[]): void;
  25359. /**
  25360. * Add the required samplers to the current list.
  25361. * @param samplers defines the current sampler list.
  25362. */
  25363. static AddSamplers(samplers: string[]): void;
  25364. /**
  25365. * Add the required uniforms to the current buffer.
  25366. * @param uniformBuffer defines the current uniform buffer.
  25367. */
  25368. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25369. /**
  25370. * Makes a duplicate of the current configuration into another one.
  25371. * @param configuration define the config where to copy the info
  25372. */
  25373. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25374. /**
  25375. * Serializes this Sub Surface configuration.
  25376. * @returns - An object with the serialized config.
  25377. */
  25378. serialize(): any;
  25379. /**
  25380. * Parses a anisotropy Configuration from a serialized object.
  25381. * @param source - Serialized object.
  25382. * @param scene Defines the scene we are parsing for
  25383. * @param rootUrl Defines the rootUrl to load from
  25384. */
  25385. parse(source: any, scene: Scene, rootUrl: string): void;
  25386. }
  25387. }
  25388. declare module BABYLON {
  25389. /**
  25390. * Class representing spherical harmonics coefficients to the 3rd degree
  25391. */
  25392. export class SphericalHarmonics {
  25393. /**
  25394. * Defines whether or not the harmonics have been prescaled for rendering.
  25395. */
  25396. preScaled: boolean;
  25397. /**
  25398. * The l0,0 coefficients of the spherical harmonics
  25399. */
  25400. l00: Vector3;
  25401. /**
  25402. * The l1,-1 coefficients of the spherical harmonics
  25403. */
  25404. l1_1: Vector3;
  25405. /**
  25406. * The l1,0 coefficients of the spherical harmonics
  25407. */
  25408. l10: Vector3;
  25409. /**
  25410. * The l1,1 coefficients of the spherical harmonics
  25411. */
  25412. l11: Vector3;
  25413. /**
  25414. * The l2,-2 coefficients of the spherical harmonics
  25415. */
  25416. l2_2: Vector3;
  25417. /**
  25418. * The l2,-1 coefficients of the spherical harmonics
  25419. */
  25420. l2_1: Vector3;
  25421. /**
  25422. * The l2,0 coefficients of the spherical harmonics
  25423. */
  25424. l20: Vector3;
  25425. /**
  25426. * The l2,1 coefficients of the spherical harmonics
  25427. */
  25428. l21: Vector3;
  25429. /**
  25430. * The l2,2 coefficients of the spherical harmonics
  25431. */
  25432. l22: Vector3;
  25433. /**
  25434. * Adds a light to the spherical harmonics
  25435. * @param direction the direction of the light
  25436. * @param color the color of the light
  25437. * @param deltaSolidAngle the delta solid angle of the light
  25438. */
  25439. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25440. /**
  25441. * Scales the spherical harmonics by the given amount
  25442. * @param scale the amount to scale
  25443. */
  25444. scaleInPlace(scale: number): void;
  25445. /**
  25446. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25447. *
  25448. * ```
  25449. * E_lm = A_l * L_lm
  25450. * ```
  25451. *
  25452. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25453. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25454. * the scaling factors are given in equation 9.
  25455. */
  25456. convertIncidentRadianceToIrradiance(): void;
  25457. /**
  25458. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25459. *
  25460. * ```
  25461. * L = (1/pi) * E * rho
  25462. * ```
  25463. *
  25464. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25465. */
  25466. convertIrradianceToLambertianRadiance(): void;
  25467. /**
  25468. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25469. * required operations at run time.
  25470. *
  25471. * This is simply done by scaling back the SH with Ylm constants parameter.
  25472. * The trigonometric part being applied by the shader at run time.
  25473. */
  25474. preScaleForRendering(): void;
  25475. /**
  25476. * Constructs a spherical harmonics from an array.
  25477. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25478. * @returns the spherical harmonics
  25479. */
  25480. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25481. /**
  25482. * Gets the spherical harmonics from polynomial
  25483. * @param polynomial the spherical polynomial
  25484. * @returns the spherical harmonics
  25485. */
  25486. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25487. }
  25488. /**
  25489. * Class representing spherical polynomial coefficients to the 3rd degree
  25490. */
  25491. export class SphericalPolynomial {
  25492. private _harmonics;
  25493. /**
  25494. * The spherical harmonics used to create the polynomials.
  25495. */
  25496. get preScaledHarmonics(): SphericalHarmonics;
  25497. /**
  25498. * The x coefficients of the spherical polynomial
  25499. */
  25500. x: Vector3;
  25501. /**
  25502. * The y coefficients of the spherical polynomial
  25503. */
  25504. y: Vector3;
  25505. /**
  25506. * The z coefficients of the spherical polynomial
  25507. */
  25508. z: Vector3;
  25509. /**
  25510. * The xx coefficients of the spherical polynomial
  25511. */
  25512. xx: Vector3;
  25513. /**
  25514. * The yy coefficients of the spherical polynomial
  25515. */
  25516. yy: Vector3;
  25517. /**
  25518. * The zz coefficients of the spherical polynomial
  25519. */
  25520. zz: Vector3;
  25521. /**
  25522. * The xy coefficients of the spherical polynomial
  25523. */
  25524. xy: Vector3;
  25525. /**
  25526. * The yz coefficients of the spherical polynomial
  25527. */
  25528. yz: Vector3;
  25529. /**
  25530. * The zx coefficients of the spherical polynomial
  25531. */
  25532. zx: Vector3;
  25533. /**
  25534. * Adds an ambient color to the spherical polynomial
  25535. * @param color the color to add
  25536. */
  25537. addAmbient(color: Color3): void;
  25538. /**
  25539. * Scales the spherical polynomial by the given amount
  25540. * @param scale the amount to scale
  25541. */
  25542. scaleInPlace(scale: number): void;
  25543. /**
  25544. * Gets the spherical polynomial from harmonics
  25545. * @param harmonics the spherical harmonics
  25546. * @returns the spherical polynomial
  25547. */
  25548. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25549. /**
  25550. * Constructs a spherical polynomial from an array.
  25551. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25552. * @returns the spherical polynomial
  25553. */
  25554. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25555. }
  25556. }
  25557. declare module BABYLON {
  25558. /**
  25559. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25560. */
  25561. export interface CubeMapInfo {
  25562. /**
  25563. * The pixel array for the front face.
  25564. * This is stored in format, left to right, up to down format.
  25565. */
  25566. front: Nullable<ArrayBufferView>;
  25567. /**
  25568. * The pixel array for the back face.
  25569. * This is stored in format, left to right, up to down format.
  25570. */
  25571. back: Nullable<ArrayBufferView>;
  25572. /**
  25573. * The pixel array for the left face.
  25574. * This is stored in format, left to right, up to down format.
  25575. */
  25576. left: Nullable<ArrayBufferView>;
  25577. /**
  25578. * The pixel array for the right face.
  25579. * This is stored in format, left to right, up to down format.
  25580. */
  25581. right: Nullable<ArrayBufferView>;
  25582. /**
  25583. * The pixel array for the up face.
  25584. * This is stored in format, left to right, up to down format.
  25585. */
  25586. up: Nullable<ArrayBufferView>;
  25587. /**
  25588. * The pixel array for the down face.
  25589. * This is stored in format, left to right, up to down format.
  25590. */
  25591. down: Nullable<ArrayBufferView>;
  25592. /**
  25593. * The size of the cubemap stored.
  25594. *
  25595. * Each faces will be size * size pixels.
  25596. */
  25597. size: number;
  25598. /**
  25599. * The format of the texture.
  25600. *
  25601. * RGBA, RGB.
  25602. */
  25603. format: number;
  25604. /**
  25605. * The type of the texture data.
  25606. *
  25607. * UNSIGNED_INT, FLOAT.
  25608. */
  25609. type: number;
  25610. /**
  25611. * Specifies whether the texture is in gamma space.
  25612. */
  25613. gammaSpace: boolean;
  25614. }
  25615. /**
  25616. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25617. */
  25618. export class PanoramaToCubeMapTools {
  25619. private static FACE_LEFT;
  25620. private static FACE_RIGHT;
  25621. private static FACE_FRONT;
  25622. private static FACE_BACK;
  25623. private static FACE_DOWN;
  25624. private static FACE_UP;
  25625. /**
  25626. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25627. *
  25628. * @param float32Array The source data.
  25629. * @param inputWidth The width of the input panorama.
  25630. * @param inputHeight The height of the input panorama.
  25631. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25632. * @return The cubemap data
  25633. */
  25634. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25635. private static CreateCubemapTexture;
  25636. private static CalcProjectionSpherical;
  25637. }
  25638. }
  25639. declare module BABYLON {
  25640. /**
  25641. * Helper class dealing with the extraction of spherical polynomial dataArray
  25642. * from a cube map.
  25643. */
  25644. export class CubeMapToSphericalPolynomialTools {
  25645. private static FileFaces;
  25646. /**
  25647. * Converts a texture to the according Spherical Polynomial data.
  25648. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25649. *
  25650. * @param texture The texture to extract the information from.
  25651. * @return The Spherical Polynomial data.
  25652. */
  25653. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25654. /**
  25655. * Converts a cubemap to the according Spherical Polynomial data.
  25656. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25657. *
  25658. * @param cubeInfo The Cube map to extract the information from.
  25659. * @return The Spherical Polynomial data.
  25660. */
  25661. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25662. }
  25663. }
  25664. declare module BABYLON {
  25665. interface BaseTexture {
  25666. /**
  25667. * Get the polynomial representation of the texture data.
  25668. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25669. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25670. */
  25671. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25672. }
  25673. }
  25674. declare module BABYLON {
  25675. /** @hidden */
  25676. export var pbrFragmentDeclaration: {
  25677. name: string;
  25678. shader: string;
  25679. };
  25680. }
  25681. declare module BABYLON {
  25682. /** @hidden */
  25683. export var pbrUboDeclaration: {
  25684. name: string;
  25685. shader: string;
  25686. };
  25687. }
  25688. declare module BABYLON {
  25689. /** @hidden */
  25690. export var pbrFragmentExtraDeclaration: {
  25691. name: string;
  25692. shader: string;
  25693. };
  25694. }
  25695. declare module BABYLON {
  25696. /** @hidden */
  25697. export var pbrFragmentSamplersDeclaration: {
  25698. name: string;
  25699. shader: string;
  25700. };
  25701. }
  25702. declare module BABYLON {
  25703. /** @hidden */
  25704. export var subSurfaceScatteringFunctions: {
  25705. name: string;
  25706. shader: string;
  25707. };
  25708. }
  25709. declare module BABYLON {
  25710. /** @hidden */
  25711. export var importanceSampling: {
  25712. name: string;
  25713. shader: string;
  25714. };
  25715. }
  25716. declare module BABYLON {
  25717. /** @hidden */
  25718. export var pbrHelperFunctions: {
  25719. name: string;
  25720. shader: string;
  25721. };
  25722. }
  25723. declare module BABYLON {
  25724. /** @hidden */
  25725. export var harmonicsFunctions: {
  25726. name: string;
  25727. shader: string;
  25728. };
  25729. }
  25730. declare module BABYLON {
  25731. /** @hidden */
  25732. export var pbrDirectLightingSetupFunctions: {
  25733. name: string;
  25734. shader: string;
  25735. };
  25736. }
  25737. declare module BABYLON {
  25738. /** @hidden */
  25739. export var pbrDirectLightingFalloffFunctions: {
  25740. name: string;
  25741. shader: string;
  25742. };
  25743. }
  25744. declare module BABYLON {
  25745. /** @hidden */
  25746. export var pbrBRDFFunctions: {
  25747. name: string;
  25748. shader: string;
  25749. };
  25750. }
  25751. declare module BABYLON {
  25752. /** @hidden */
  25753. export var hdrFilteringFunctions: {
  25754. name: string;
  25755. shader: string;
  25756. };
  25757. }
  25758. declare module BABYLON {
  25759. /** @hidden */
  25760. export var pbrDirectLightingFunctions: {
  25761. name: string;
  25762. shader: string;
  25763. };
  25764. }
  25765. declare module BABYLON {
  25766. /** @hidden */
  25767. export var pbrIBLFunctions: {
  25768. name: string;
  25769. shader: string;
  25770. };
  25771. }
  25772. declare module BABYLON {
  25773. /** @hidden */
  25774. export var pbrBlockAlbedoOpacity: {
  25775. name: string;
  25776. shader: string;
  25777. };
  25778. }
  25779. declare module BABYLON {
  25780. /** @hidden */
  25781. export var pbrBlockReflectivity: {
  25782. name: string;
  25783. shader: string;
  25784. };
  25785. }
  25786. declare module BABYLON {
  25787. /** @hidden */
  25788. export var pbrBlockAmbientOcclusion: {
  25789. name: string;
  25790. shader: string;
  25791. };
  25792. }
  25793. declare module BABYLON {
  25794. /** @hidden */
  25795. export var pbrBlockAlphaFresnel: {
  25796. name: string;
  25797. shader: string;
  25798. };
  25799. }
  25800. declare module BABYLON {
  25801. /** @hidden */
  25802. export var pbrBlockAnisotropic: {
  25803. name: string;
  25804. shader: string;
  25805. };
  25806. }
  25807. declare module BABYLON {
  25808. /** @hidden */
  25809. export var pbrBlockReflection: {
  25810. name: string;
  25811. shader: string;
  25812. };
  25813. }
  25814. declare module BABYLON {
  25815. /** @hidden */
  25816. export var pbrBlockSheen: {
  25817. name: string;
  25818. shader: string;
  25819. };
  25820. }
  25821. declare module BABYLON {
  25822. /** @hidden */
  25823. export var pbrBlockClearcoat: {
  25824. name: string;
  25825. shader: string;
  25826. };
  25827. }
  25828. declare module BABYLON {
  25829. /** @hidden */
  25830. export var pbrBlockSubSurface: {
  25831. name: string;
  25832. shader: string;
  25833. };
  25834. }
  25835. declare module BABYLON {
  25836. /** @hidden */
  25837. export var pbrBlockNormalGeometric: {
  25838. name: string;
  25839. shader: string;
  25840. };
  25841. }
  25842. declare module BABYLON {
  25843. /** @hidden */
  25844. export var pbrBlockNormalFinal: {
  25845. name: string;
  25846. shader: string;
  25847. };
  25848. }
  25849. declare module BABYLON {
  25850. /** @hidden */
  25851. export var pbrBlockLightmapInit: {
  25852. name: string;
  25853. shader: string;
  25854. };
  25855. }
  25856. declare module BABYLON {
  25857. /** @hidden */
  25858. export var pbrBlockGeometryInfo: {
  25859. name: string;
  25860. shader: string;
  25861. };
  25862. }
  25863. declare module BABYLON {
  25864. /** @hidden */
  25865. export var pbrBlockReflectance0: {
  25866. name: string;
  25867. shader: string;
  25868. };
  25869. }
  25870. declare module BABYLON {
  25871. /** @hidden */
  25872. export var pbrBlockReflectance: {
  25873. name: string;
  25874. shader: string;
  25875. };
  25876. }
  25877. declare module BABYLON {
  25878. /** @hidden */
  25879. export var pbrBlockDirectLighting: {
  25880. name: string;
  25881. shader: string;
  25882. };
  25883. }
  25884. declare module BABYLON {
  25885. /** @hidden */
  25886. export var pbrBlockFinalLitComponents: {
  25887. name: string;
  25888. shader: string;
  25889. };
  25890. }
  25891. declare module BABYLON {
  25892. /** @hidden */
  25893. export var pbrBlockFinalUnlitComponents: {
  25894. name: string;
  25895. shader: string;
  25896. };
  25897. }
  25898. declare module BABYLON {
  25899. /** @hidden */
  25900. export var pbrBlockFinalColorComposition: {
  25901. name: string;
  25902. shader: string;
  25903. };
  25904. }
  25905. declare module BABYLON {
  25906. /** @hidden */
  25907. export var pbrBlockImageProcessing: {
  25908. name: string;
  25909. shader: string;
  25910. };
  25911. }
  25912. declare module BABYLON {
  25913. /** @hidden */
  25914. export var pbrDebug: {
  25915. name: string;
  25916. shader: string;
  25917. };
  25918. }
  25919. declare module BABYLON {
  25920. /** @hidden */
  25921. export var pbrPixelShader: {
  25922. name: string;
  25923. shader: string;
  25924. };
  25925. }
  25926. declare module BABYLON {
  25927. /** @hidden */
  25928. export var pbrVertexDeclaration: {
  25929. name: string;
  25930. shader: string;
  25931. };
  25932. }
  25933. declare module BABYLON {
  25934. /** @hidden */
  25935. export var pbrVertexShader: {
  25936. name: string;
  25937. shader: string;
  25938. };
  25939. }
  25940. declare module BABYLON {
  25941. /**
  25942. * Manages the defines for the PBR Material.
  25943. * @hidden
  25944. */
  25945. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25946. PBR: boolean;
  25947. NUM_SAMPLES: string;
  25948. REALTIME_FILTERING: boolean;
  25949. MAINUV1: boolean;
  25950. MAINUV2: boolean;
  25951. UV1: boolean;
  25952. UV2: boolean;
  25953. ALBEDO: boolean;
  25954. GAMMAALBEDO: boolean;
  25955. ALBEDODIRECTUV: number;
  25956. VERTEXCOLOR: boolean;
  25957. DETAIL: boolean;
  25958. DETAILDIRECTUV: number;
  25959. DETAIL_NORMALBLENDMETHOD: number;
  25960. AMBIENT: boolean;
  25961. AMBIENTDIRECTUV: number;
  25962. AMBIENTINGRAYSCALE: boolean;
  25963. OPACITY: boolean;
  25964. VERTEXALPHA: boolean;
  25965. OPACITYDIRECTUV: number;
  25966. OPACITYRGB: boolean;
  25967. ALPHATEST: boolean;
  25968. DEPTHPREPASS: boolean;
  25969. ALPHABLEND: boolean;
  25970. ALPHAFROMALBEDO: boolean;
  25971. ALPHATESTVALUE: string;
  25972. SPECULAROVERALPHA: boolean;
  25973. RADIANCEOVERALPHA: boolean;
  25974. ALPHAFRESNEL: boolean;
  25975. LINEARALPHAFRESNEL: boolean;
  25976. PREMULTIPLYALPHA: boolean;
  25977. EMISSIVE: boolean;
  25978. EMISSIVEDIRECTUV: number;
  25979. REFLECTIVITY: boolean;
  25980. REFLECTIVITYDIRECTUV: number;
  25981. SPECULARTERM: boolean;
  25982. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25983. MICROSURFACEAUTOMATIC: boolean;
  25984. LODBASEDMICROSFURACE: boolean;
  25985. MICROSURFACEMAP: boolean;
  25986. MICROSURFACEMAPDIRECTUV: number;
  25987. METALLICWORKFLOW: boolean;
  25988. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25989. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25990. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25991. AOSTOREINMETALMAPRED: boolean;
  25992. METALLIC_REFLECTANCE: boolean;
  25993. METALLIC_REFLECTANCEDIRECTUV: number;
  25994. ENVIRONMENTBRDF: boolean;
  25995. ENVIRONMENTBRDF_RGBD: boolean;
  25996. NORMAL: boolean;
  25997. TANGENT: boolean;
  25998. BUMP: boolean;
  25999. BUMPDIRECTUV: number;
  26000. OBJECTSPACE_NORMALMAP: boolean;
  26001. PARALLAX: boolean;
  26002. PARALLAXOCCLUSION: boolean;
  26003. NORMALXYSCALE: boolean;
  26004. LIGHTMAP: boolean;
  26005. LIGHTMAPDIRECTUV: number;
  26006. USELIGHTMAPASSHADOWMAP: boolean;
  26007. GAMMALIGHTMAP: boolean;
  26008. RGBDLIGHTMAP: boolean;
  26009. REFLECTION: boolean;
  26010. REFLECTIONMAP_3D: boolean;
  26011. REFLECTIONMAP_SPHERICAL: boolean;
  26012. REFLECTIONMAP_PLANAR: boolean;
  26013. REFLECTIONMAP_CUBIC: boolean;
  26014. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26015. REFLECTIONMAP_PROJECTION: boolean;
  26016. REFLECTIONMAP_SKYBOX: boolean;
  26017. REFLECTIONMAP_EXPLICIT: boolean;
  26018. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26019. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26020. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26021. INVERTCUBICMAP: boolean;
  26022. USESPHERICALFROMREFLECTIONMAP: boolean;
  26023. USEIRRADIANCEMAP: boolean;
  26024. SPHERICAL_HARMONICS: boolean;
  26025. USESPHERICALINVERTEX: boolean;
  26026. REFLECTIONMAP_OPPOSITEZ: boolean;
  26027. LODINREFLECTIONALPHA: boolean;
  26028. GAMMAREFLECTION: boolean;
  26029. RGBDREFLECTION: boolean;
  26030. LINEARSPECULARREFLECTION: boolean;
  26031. RADIANCEOCCLUSION: boolean;
  26032. HORIZONOCCLUSION: boolean;
  26033. INSTANCES: boolean;
  26034. THIN_INSTANCES: boolean;
  26035. PREPASS: boolean;
  26036. PREPASS_IRRADIANCE: boolean;
  26037. PREPASS_IRRADIANCE_INDEX: number;
  26038. PREPASS_ALBEDO: boolean;
  26039. PREPASS_ALBEDO_INDEX: number;
  26040. PREPASS_DEPTHNORMAL: boolean;
  26041. PREPASS_DEPTHNORMAL_INDEX: number;
  26042. PREPASS_POSITION: boolean;
  26043. PREPASS_POSITION_INDEX: number;
  26044. PREPASS_VELOCITY: boolean;
  26045. PREPASS_VELOCITY_INDEX: number;
  26046. PREPASS_REFLECTIVITY: boolean;
  26047. PREPASS_REFLECTIVITY_INDEX: number;
  26048. SCENE_MRT_COUNT: number;
  26049. NUM_BONE_INFLUENCERS: number;
  26050. BonesPerMesh: number;
  26051. BONETEXTURE: boolean;
  26052. BONES_VELOCITY_ENABLED: boolean;
  26053. NONUNIFORMSCALING: boolean;
  26054. MORPHTARGETS: boolean;
  26055. MORPHTARGETS_NORMAL: boolean;
  26056. MORPHTARGETS_TANGENT: boolean;
  26057. MORPHTARGETS_UV: boolean;
  26058. NUM_MORPH_INFLUENCERS: number;
  26059. IMAGEPROCESSING: boolean;
  26060. VIGNETTE: boolean;
  26061. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26062. VIGNETTEBLENDMODEOPAQUE: boolean;
  26063. TONEMAPPING: boolean;
  26064. TONEMAPPING_ACES: boolean;
  26065. CONTRAST: boolean;
  26066. COLORCURVES: boolean;
  26067. COLORGRADING: boolean;
  26068. COLORGRADING3D: boolean;
  26069. SAMPLER3DGREENDEPTH: boolean;
  26070. SAMPLER3DBGRMAP: boolean;
  26071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26072. EXPOSURE: boolean;
  26073. MULTIVIEW: boolean;
  26074. USEPHYSICALLIGHTFALLOFF: boolean;
  26075. USEGLTFLIGHTFALLOFF: boolean;
  26076. TWOSIDEDLIGHTING: boolean;
  26077. SHADOWFLOAT: boolean;
  26078. CLIPPLANE: boolean;
  26079. CLIPPLANE2: boolean;
  26080. CLIPPLANE3: boolean;
  26081. CLIPPLANE4: boolean;
  26082. CLIPPLANE5: boolean;
  26083. CLIPPLANE6: boolean;
  26084. POINTSIZE: boolean;
  26085. FOG: boolean;
  26086. LOGARITHMICDEPTH: boolean;
  26087. FORCENORMALFORWARD: boolean;
  26088. SPECULARAA: boolean;
  26089. CLEARCOAT: boolean;
  26090. CLEARCOAT_DEFAULTIOR: boolean;
  26091. CLEARCOAT_TEXTURE: boolean;
  26092. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26093. CLEARCOAT_TEXTUREDIRECTUV: number;
  26094. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26095. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26096. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26097. CLEARCOAT_BUMP: boolean;
  26098. CLEARCOAT_BUMPDIRECTUV: number;
  26099. CLEARCOAT_REMAP_F0: boolean;
  26100. CLEARCOAT_TINT: boolean;
  26101. CLEARCOAT_TINT_TEXTURE: boolean;
  26102. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26103. ANISOTROPIC: boolean;
  26104. ANISOTROPIC_TEXTURE: boolean;
  26105. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26106. BRDF_V_HEIGHT_CORRELATED: boolean;
  26107. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26108. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26109. SHEEN: boolean;
  26110. SHEEN_TEXTURE: boolean;
  26111. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26112. SHEEN_TEXTUREDIRECTUV: number;
  26113. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26114. SHEEN_LINKWITHALBEDO: boolean;
  26115. SHEEN_ROUGHNESS: boolean;
  26116. SHEEN_ALBEDOSCALING: boolean;
  26117. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26118. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26119. SUBSURFACE: boolean;
  26120. SS_REFRACTION: boolean;
  26121. SS_TRANSLUCENCY: boolean;
  26122. SS_SCATTERING: boolean;
  26123. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26124. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26125. SS_REFRACTIONMAP_3D: boolean;
  26126. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26127. SS_LODINREFRACTIONALPHA: boolean;
  26128. SS_GAMMAREFRACTION: boolean;
  26129. SS_RGBDREFRACTION: boolean;
  26130. SS_LINEARSPECULARREFRACTION: boolean;
  26131. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26132. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26133. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26134. UNLIT: boolean;
  26135. DEBUGMODE: number;
  26136. /**
  26137. * Initializes the PBR Material defines.
  26138. */
  26139. constructor();
  26140. /**
  26141. * Resets the PBR Material defines.
  26142. */
  26143. reset(): void;
  26144. }
  26145. /**
  26146. * The Physically based material base class of BJS.
  26147. *
  26148. * This offers the main features of a standard PBR material.
  26149. * For more information, please refer to the documentation :
  26150. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26151. */
  26152. export abstract class PBRBaseMaterial extends PushMaterial {
  26153. /**
  26154. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26155. */
  26156. static readonly PBRMATERIAL_OPAQUE: number;
  26157. /**
  26158. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26159. */
  26160. static readonly PBRMATERIAL_ALPHATEST: number;
  26161. /**
  26162. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26163. */
  26164. static readonly PBRMATERIAL_ALPHABLEND: number;
  26165. /**
  26166. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26167. * They are also discarded below the alpha cutoff threshold to improve performances.
  26168. */
  26169. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26170. /**
  26171. * Defines the default value of how much AO map is occluding the analytical lights
  26172. * (point spot...).
  26173. */
  26174. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26175. /**
  26176. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26177. */
  26178. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26179. /**
  26180. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26181. * to enhance interoperability with other engines.
  26182. */
  26183. static readonly LIGHTFALLOFF_GLTF: number;
  26184. /**
  26185. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26186. * to enhance interoperability with other materials.
  26187. */
  26188. static readonly LIGHTFALLOFF_STANDARD: number;
  26189. /**
  26190. * Intensity of the direct lights e.g. the four lights available in your scene.
  26191. * This impacts both the direct diffuse and specular highlights.
  26192. */
  26193. protected _directIntensity: number;
  26194. /**
  26195. * Intensity of the emissive part of the material.
  26196. * This helps controlling the emissive effect without modifying the emissive color.
  26197. */
  26198. protected _emissiveIntensity: number;
  26199. /**
  26200. * Intensity of the environment e.g. how much the environment will light the object
  26201. * either through harmonics for rough material or through the refelction for shiny ones.
  26202. */
  26203. protected _environmentIntensity: number;
  26204. /**
  26205. * This is a special control allowing the reduction of the specular highlights coming from the
  26206. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26207. */
  26208. protected _specularIntensity: number;
  26209. /**
  26210. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26211. */
  26212. private _lightingInfos;
  26213. /**
  26214. * Debug Control allowing disabling the bump map on this material.
  26215. */
  26216. protected _disableBumpMap: boolean;
  26217. /**
  26218. * AKA Diffuse Texture in standard nomenclature.
  26219. */
  26220. protected _albedoTexture: Nullable<BaseTexture>;
  26221. /**
  26222. * AKA Occlusion Texture in other nomenclature.
  26223. */
  26224. protected _ambientTexture: Nullable<BaseTexture>;
  26225. /**
  26226. * AKA Occlusion Texture Intensity in other nomenclature.
  26227. */
  26228. protected _ambientTextureStrength: number;
  26229. /**
  26230. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26231. * 1 means it completely occludes it
  26232. * 0 mean it has no impact
  26233. */
  26234. protected _ambientTextureImpactOnAnalyticalLights: number;
  26235. /**
  26236. * Stores the alpha values in a texture.
  26237. */
  26238. protected _opacityTexture: Nullable<BaseTexture>;
  26239. /**
  26240. * Stores the reflection values in a texture.
  26241. */
  26242. protected _reflectionTexture: Nullable<BaseTexture>;
  26243. /**
  26244. * Stores the emissive values in a texture.
  26245. */
  26246. protected _emissiveTexture: Nullable<BaseTexture>;
  26247. /**
  26248. * AKA Specular texture in other nomenclature.
  26249. */
  26250. protected _reflectivityTexture: Nullable<BaseTexture>;
  26251. /**
  26252. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26253. */
  26254. protected _metallicTexture: Nullable<BaseTexture>;
  26255. /**
  26256. * Specifies the metallic scalar of the metallic/roughness workflow.
  26257. * Can also be used to scale the metalness values of the metallic texture.
  26258. */
  26259. protected _metallic: Nullable<number>;
  26260. /**
  26261. * Specifies the roughness scalar of the metallic/roughness workflow.
  26262. * Can also be used to scale the roughness values of the metallic texture.
  26263. */
  26264. protected _roughness: Nullable<number>;
  26265. /**
  26266. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26267. * By default the indexOfrefraction is used to compute F0;
  26268. *
  26269. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26270. *
  26271. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26272. * F90 = metallicReflectanceColor;
  26273. */
  26274. protected _metallicF0Factor: number;
  26275. /**
  26276. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26277. * By default the F90 is always 1;
  26278. *
  26279. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26280. *
  26281. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26282. * F90 = metallicReflectanceColor;
  26283. */
  26284. protected _metallicReflectanceColor: Color3;
  26285. /**
  26286. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26287. * This is multiply against the scalar values defined in the material.
  26288. */
  26289. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26290. /**
  26291. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26292. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26293. */
  26294. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26295. /**
  26296. * Stores surface normal data used to displace a mesh in a texture.
  26297. */
  26298. protected _bumpTexture: Nullable<BaseTexture>;
  26299. /**
  26300. * Stores the pre-calculated light information of a mesh in a texture.
  26301. */
  26302. protected _lightmapTexture: Nullable<BaseTexture>;
  26303. /**
  26304. * The color of a material in ambient lighting.
  26305. */
  26306. protected _ambientColor: Color3;
  26307. /**
  26308. * AKA Diffuse Color in other nomenclature.
  26309. */
  26310. protected _albedoColor: Color3;
  26311. /**
  26312. * AKA Specular Color in other nomenclature.
  26313. */
  26314. protected _reflectivityColor: Color3;
  26315. /**
  26316. * The color applied when light is reflected from a material.
  26317. */
  26318. protected _reflectionColor: Color3;
  26319. /**
  26320. * The color applied when light is emitted from a material.
  26321. */
  26322. protected _emissiveColor: Color3;
  26323. /**
  26324. * AKA Glossiness in other nomenclature.
  26325. */
  26326. protected _microSurface: number;
  26327. /**
  26328. * Specifies that the material will use the light map as a show map.
  26329. */
  26330. protected _useLightmapAsShadowmap: boolean;
  26331. /**
  26332. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26333. * makes the reflect vector face the model (under horizon).
  26334. */
  26335. protected _useHorizonOcclusion: boolean;
  26336. /**
  26337. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26338. * too much the area relying on ambient texture to define their ambient occlusion.
  26339. */
  26340. protected _useRadianceOcclusion: boolean;
  26341. /**
  26342. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26343. */
  26344. protected _useAlphaFromAlbedoTexture: boolean;
  26345. /**
  26346. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26347. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26348. */
  26349. protected _useSpecularOverAlpha: boolean;
  26350. /**
  26351. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26352. */
  26353. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26354. /**
  26355. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26356. */
  26357. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26358. /**
  26359. * Specifies if the metallic texture contains the roughness information in its green channel.
  26360. */
  26361. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26362. /**
  26363. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26364. */
  26365. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26366. /**
  26367. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26368. */
  26369. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26370. /**
  26371. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26372. */
  26373. protected _useAmbientInGrayScale: boolean;
  26374. /**
  26375. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26376. * The material will try to infer what glossiness each pixel should be.
  26377. */
  26378. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26379. /**
  26380. * Defines the falloff type used in this material.
  26381. * It by default is Physical.
  26382. */
  26383. protected _lightFalloff: number;
  26384. /**
  26385. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26386. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26387. */
  26388. protected _useRadianceOverAlpha: boolean;
  26389. /**
  26390. * Allows using an object space normal map (instead of tangent space).
  26391. */
  26392. protected _useObjectSpaceNormalMap: boolean;
  26393. /**
  26394. * Allows using the bump map in parallax mode.
  26395. */
  26396. protected _useParallax: boolean;
  26397. /**
  26398. * Allows using the bump map in parallax occlusion mode.
  26399. */
  26400. protected _useParallaxOcclusion: boolean;
  26401. /**
  26402. * Controls the scale bias of the parallax mode.
  26403. */
  26404. protected _parallaxScaleBias: number;
  26405. /**
  26406. * If sets to true, disables all the lights affecting the material.
  26407. */
  26408. protected _disableLighting: boolean;
  26409. /**
  26410. * Number of Simultaneous lights allowed on the material.
  26411. */
  26412. protected _maxSimultaneousLights: number;
  26413. /**
  26414. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26415. */
  26416. protected _invertNormalMapX: boolean;
  26417. /**
  26418. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26419. */
  26420. protected _invertNormalMapY: boolean;
  26421. /**
  26422. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26423. */
  26424. protected _twoSidedLighting: boolean;
  26425. /**
  26426. * Defines the alpha limits in alpha test mode.
  26427. */
  26428. protected _alphaCutOff: number;
  26429. /**
  26430. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26431. */
  26432. protected _forceAlphaTest: boolean;
  26433. /**
  26434. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26435. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26436. */
  26437. protected _useAlphaFresnel: boolean;
  26438. /**
  26439. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26440. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26441. */
  26442. protected _useLinearAlphaFresnel: boolean;
  26443. /**
  26444. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26445. * from cos thetav and roughness:
  26446. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26447. */
  26448. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26449. /**
  26450. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26451. */
  26452. protected _forceIrradianceInFragment: boolean;
  26453. private _realTimeFiltering;
  26454. /**
  26455. * Enables realtime filtering on the texture.
  26456. */
  26457. get realTimeFiltering(): boolean;
  26458. set realTimeFiltering(b: boolean);
  26459. private _realTimeFilteringQuality;
  26460. /**
  26461. * Quality switch for realtime filtering
  26462. */
  26463. get realTimeFilteringQuality(): number;
  26464. set realTimeFilteringQuality(n: number);
  26465. /**
  26466. * Can this material render to several textures at once
  26467. */
  26468. get canRenderToMRT(): boolean;
  26469. /**
  26470. * Force normal to face away from face.
  26471. */
  26472. protected _forceNormalForward: boolean;
  26473. /**
  26474. * Enables specular anti aliasing in the PBR shader.
  26475. * It will both interacts on the Geometry for analytical and IBL lighting.
  26476. * It also prefilter the roughness map based on the bump values.
  26477. */
  26478. protected _enableSpecularAntiAliasing: boolean;
  26479. /**
  26480. * Default configuration related to image processing available in the PBR Material.
  26481. */
  26482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26483. /**
  26484. * Keep track of the image processing observer to allow dispose and replace.
  26485. */
  26486. private _imageProcessingObserver;
  26487. /**
  26488. * Attaches a new image processing configuration to the PBR Material.
  26489. * @param configuration
  26490. */
  26491. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26492. /**
  26493. * Stores the available render targets.
  26494. */
  26495. private _renderTargets;
  26496. /**
  26497. * Sets the global ambient color for the material used in lighting calculations.
  26498. */
  26499. private _globalAmbientColor;
  26500. /**
  26501. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26502. */
  26503. private _useLogarithmicDepth;
  26504. /**
  26505. * If set to true, no lighting calculations will be applied.
  26506. */
  26507. private _unlit;
  26508. private _debugMode;
  26509. /**
  26510. * @hidden
  26511. * This is reserved for the inspector.
  26512. * Defines the material debug mode.
  26513. * It helps seeing only some components of the material while troubleshooting.
  26514. */
  26515. debugMode: number;
  26516. /**
  26517. * @hidden
  26518. * This is reserved for the inspector.
  26519. * Specify from where on screen the debug mode should start.
  26520. * The value goes from -1 (full screen) to 1 (not visible)
  26521. * It helps with side by side comparison against the final render
  26522. * This defaults to -1
  26523. */
  26524. private debugLimit;
  26525. /**
  26526. * @hidden
  26527. * This is reserved for the inspector.
  26528. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26529. * You can use the factor to better multiply the final value.
  26530. */
  26531. private debugFactor;
  26532. /**
  26533. * Defines the clear coat layer parameters for the material.
  26534. */
  26535. readonly clearCoat: PBRClearCoatConfiguration;
  26536. /**
  26537. * Defines the anisotropic parameters for the material.
  26538. */
  26539. readonly anisotropy: PBRAnisotropicConfiguration;
  26540. /**
  26541. * Defines the BRDF parameters for the material.
  26542. */
  26543. readonly brdf: PBRBRDFConfiguration;
  26544. /**
  26545. * Defines the Sheen parameters for the material.
  26546. */
  26547. readonly sheen: PBRSheenConfiguration;
  26548. /**
  26549. * Defines the SubSurface parameters for the material.
  26550. */
  26551. readonly subSurface: PBRSubSurfaceConfiguration;
  26552. /**
  26553. * Defines additionnal PrePass parameters for the material.
  26554. */
  26555. readonly prePassConfiguration: PrePassConfiguration;
  26556. /**
  26557. * Defines the detail map parameters for the material.
  26558. */
  26559. readonly detailMap: DetailMapConfiguration;
  26560. protected _rebuildInParallel: boolean;
  26561. /**
  26562. * Instantiates a new PBRMaterial instance.
  26563. *
  26564. * @param name The material name
  26565. * @param scene The scene the material will be use in.
  26566. */
  26567. constructor(name: string, scene: Scene);
  26568. /**
  26569. * Gets a boolean indicating that current material needs to register RTT
  26570. */
  26571. get hasRenderTargetTextures(): boolean;
  26572. /**
  26573. * Gets the name of the material class.
  26574. */
  26575. getClassName(): string;
  26576. /**
  26577. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26578. */
  26579. get useLogarithmicDepth(): boolean;
  26580. /**
  26581. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26582. */
  26583. set useLogarithmicDepth(value: boolean);
  26584. /**
  26585. * Returns true if alpha blending should be disabled.
  26586. */
  26587. protected get _disableAlphaBlending(): boolean;
  26588. /**
  26589. * Specifies whether or not this material should be rendered in alpha blend mode.
  26590. */
  26591. needAlphaBlending(): boolean;
  26592. /**
  26593. * Specifies whether or not this material should be rendered in alpha test mode.
  26594. */
  26595. needAlphaTesting(): boolean;
  26596. /**
  26597. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26598. */
  26599. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26600. /**
  26601. * Specifies whether or not there is a usable alpha channel for transparency.
  26602. */
  26603. protected _hasAlphaChannel(): boolean;
  26604. /**
  26605. * Gets the texture used for the alpha test.
  26606. */
  26607. getAlphaTestTexture(): Nullable<BaseTexture>;
  26608. /**
  26609. * Specifies that the submesh is ready to be used.
  26610. * @param mesh - BJS mesh.
  26611. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26612. * @param useInstances - Specifies that instances should be used.
  26613. * @returns - boolean indicating that the submesh is ready or not.
  26614. */
  26615. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26616. /**
  26617. * Specifies if the material uses metallic roughness workflow.
  26618. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26619. */
  26620. isMetallicWorkflow(): boolean;
  26621. private _prepareEffect;
  26622. private _prepareDefines;
  26623. /**
  26624. * Force shader compilation
  26625. */
  26626. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26627. /**
  26628. * Initializes the uniform buffer layout for the shader.
  26629. */
  26630. buildUniformLayout(): void;
  26631. /**
  26632. * Unbinds the material from the mesh
  26633. */
  26634. unbind(): void;
  26635. /**
  26636. * Binds the submesh data.
  26637. * @param world - The world matrix.
  26638. * @param mesh - The BJS mesh.
  26639. * @param subMesh - A submesh of the BJS mesh.
  26640. */
  26641. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26642. /**
  26643. * Returns the animatable textures.
  26644. * @returns - Array of animatable textures.
  26645. */
  26646. getAnimatables(): IAnimatable[];
  26647. /**
  26648. * Returns the texture used for reflections.
  26649. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26650. */
  26651. private _getReflectionTexture;
  26652. /**
  26653. * Returns an array of the actively used textures.
  26654. * @returns - Array of BaseTextures
  26655. */
  26656. getActiveTextures(): BaseTexture[];
  26657. /**
  26658. * Checks to see if a texture is used in the material.
  26659. * @param texture - Base texture to use.
  26660. * @returns - Boolean specifying if a texture is used in the material.
  26661. */
  26662. hasTexture(texture: BaseTexture): boolean;
  26663. /**
  26664. * Sets the required values to the prepass renderer.
  26665. * @param prePassRenderer defines the prepass renderer to setup
  26666. */
  26667. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26668. /**
  26669. * Disposes the resources of the material.
  26670. * @param forceDisposeEffect - Forces the disposal of effects.
  26671. * @param forceDisposeTextures - Forces the disposal of all textures.
  26672. */
  26673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26674. }
  26675. }
  26676. declare module BABYLON {
  26677. /**
  26678. * The Physically based material of BJS.
  26679. *
  26680. * This offers the main features of a standard PBR material.
  26681. * For more information, please refer to the documentation :
  26682. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26683. */
  26684. export class PBRMaterial extends PBRBaseMaterial {
  26685. /**
  26686. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26687. */
  26688. static readonly PBRMATERIAL_OPAQUE: number;
  26689. /**
  26690. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26691. */
  26692. static readonly PBRMATERIAL_ALPHATEST: number;
  26693. /**
  26694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26695. */
  26696. static readonly PBRMATERIAL_ALPHABLEND: number;
  26697. /**
  26698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26699. * They are also discarded below the alpha cutoff threshold to improve performances.
  26700. */
  26701. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26702. /**
  26703. * Defines the default value of how much AO map is occluding the analytical lights
  26704. * (point spot...).
  26705. */
  26706. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26707. /**
  26708. * Intensity of the direct lights e.g. the four lights available in your scene.
  26709. * This impacts both the direct diffuse and specular highlights.
  26710. */
  26711. directIntensity: number;
  26712. /**
  26713. * Intensity of the emissive part of the material.
  26714. * This helps controlling the emissive effect without modifying the emissive color.
  26715. */
  26716. emissiveIntensity: number;
  26717. /**
  26718. * Intensity of the environment e.g. how much the environment will light the object
  26719. * either through harmonics for rough material or through the refelction for shiny ones.
  26720. */
  26721. environmentIntensity: number;
  26722. /**
  26723. * This is a special control allowing the reduction of the specular highlights coming from the
  26724. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26725. */
  26726. specularIntensity: number;
  26727. /**
  26728. * Debug Control allowing disabling the bump map on this material.
  26729. */
  26730. disableBumpMap: boolean;
  26731. /**
  26732. * AKA Diffuse Texture in standard nomenclature.
  26733. */
  26734. albedoTexture: BaseTexture;
  26735. /**
  26736. * AKA Occlusion Texture in other nomenclature.
  26737. */
  26738. ambientTexture: BaseTexture;
  26739. /**
  26740. * AKA Occlusion Texture Intensity in other nomenclature.
  26741. */
  26742. ambientTextureStrength: number;
  26743. /**
  26744. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26745. * 1 means it completely occludes it
  26746. * 0 mean it has no impact
  26747. */
  26748. ambientTextureImpactOnAnalyticalLights: number;
  26749. /**
  26750. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26751. */
  26752. opacityTexture: BaseTexture;
  26753. /**
  26754. * Stores the reflection values in a texture.
  26755. */
  26756. reflectionTexture: Nullable<BaseTexture>;
  26757. /**
  26758. * Stores the emissive values in a texture.
  26759. */
  26760. emissiveTexture: BaseTexture;
  26761. /**
  26762. * AKA Specular texture in other nomenclature.
  26763. */
  26764. reflectivityTexture: BaseTexture;
  26765. /**
  26766. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26767. */
  26768. metallicTexture: BaseTexture;
  26769. /**
  26770. * Specifies the metallic scalar of the metallic/roughness workflow.
  26771. * Can also be used to scale the metalness values of the metallic texture.
  26772. */
  26773. metallic: Nullable<number>;
  26774. /**
  26775. * Specifies the roughness scalar of the metallic/roughness workflow.
  26776. * Can also be used to scale the roughness values of the metallic texture.
  26777. */
  26778. roughness: Nullable<number>;
  26779. /**
  26780. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26781. * By default the indexOfrefraction is used to compute F0;
  26782. *
  26783. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26784. *
  26785. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26786. * F90 = metallicReflectanceColor;
  26787. */
  26788. metallicF0Factor: number;
  26789. /**
  26790. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26791. * By default the F90 is always 1;
  26792. *
  26793. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26794. *
  26795. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26796. * F90 = metallicReflectanceColor;
  26797. */
  26798. metallicReflectanceColor: Color3;
  26799. /**
  26800. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26801. * This is multiply against the scalar values defined in the material.
  26802. */
  26803. metallicReflectanceTexture: Nullable<BaseTexture>;
  26804. /**
  26805. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26806. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26807. */
  26808. microSurfaceTexture: BaseTexture;
  26809. /**
  26810. * Stores surface normal data used to displace a mesh in a texture.
  26811. */
  26812. bumpTexture: BaseTexture;
  26813. /**
  26814. * Stores the pre-calculated light information of a mesh in a texture.
  26815. */
  26816. lightmapTexture: BaseTexture;
  26817. /**
  26818. * Stores the refracted light information in a texture.
  26819. */
  26820. get refractionTexture(): Nullable<BaseTexture>;
  26821. set refractionTexture(value: Nullable<BaseTexture>);
  26822. /**
  26823. * The color of a material in ambient lighting.
  26824. */
  26825. ambientColor: Color3;
  26826. /**
  26827. * AKA Diffuse Color in other nomenclature.
  26828. */
  26829. albedoColor: Color3;
  26830. /**
  26831. * AKA Specular Color in other nomenclature.
  26832. */
  26833. reflectivityColor: Color3;
  26834. /**
  26835. * The color reflected from the material.
  26836. */
  26837. reflectionColor: Color3;
  26838. /**
  26839. * The color emitted from the material.
  26840. */
  26841. emissiveColor: Color3;
  26842. /**
  26843. * AKA Glossiness in other nomenclature.
  26844. */
  26845. microSurface: number;
  26846. /**
  26847. * Index of refraction of the material base layer.
  26848. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26849. *
  26850. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26851. *
  26852. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26853. */
  26854. get indexOfRefraction(): number;
  26855. set indexOfRefraction(value: number);
  26856. /**
  26857. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26858. */
  26859. get invertRefractionY(): boolean;
  26860. set invertRefractionY(value: boolean);
  26861. /**
  26862. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26863. * Materials half opaque for instance using refraction could benefit from this control.
  26864. */
  26865. get linkRefractionWithTransparency(): boolean;
  26866. set linkRefractionWithTransparency(value: boolean);
  26867. /**
  26868. * If true, the light map contains occlusion information instead of lighting info.
  26869. */
  26870. useLightmapAsShadowmap: boolean;
  26871. /**
  26872. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26873. */
  26874. useAlphaFromAlbedoTexture: boolean;
  26875. /**
  26876. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26877. */
  26878. forceAlphaTest: boolean;
  26879. /**
  26880. * Defines the alpha limits in alpha test mode.
  26881. */
  26882. alphaCutOff: number;
  26883. /**
  26884. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26885. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26886. */
  26887. useSpecularOverAlpha: boolean;
  26888. /**
  26889. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26890. */
  26891. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26892. /**
  26893. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26894. */
  26895. useRoughnessFromMetallicTextureAlpha: boolean;
  26896. /**
  26897. * Specifies if the metallic texture contains the roughness information in its green channel.
  26898. */
  26899. useRoughnessFromMetallicTextureGreen: boolean;
  26900. /**
  26901. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26902. */
  26903. useMetallnessFromMetallicTextureBlue: boolean;
  26904. /**
  26905. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26906. */
  26907. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26908. /**
  26909. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26910. */
  26911. useAmbientInGrayScale: boolean;
  26912. /**
  26913. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26914. * The material will try to infer what glossiness each pixel should be.
  26915. */
  26916. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26917. /**
  26918. * BJS is using an harcoded light falloff based on a manually sets up range.
  26919. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26920. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26921. */
  26922. get usePhysicalLightFalloff(): boolean;
  26923. /**
  26924. * BJS is using an harcoded light falloff based on a manually sets up range.
  26925. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26926. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26927. */
  26928. set usePhysicalLightFalloff(value: boolean);
  26929. /**
  26930. * In order to support the falloff compatibility with gltf, a special mode has been added
  26931. * to reproduce the gltf light falloff.
  26932. */
  26933. get useGLTFLightFalloff(): boolean;
  26934. /**
  26935. * In order to support the falloff compatibility with gltf, a special mode has been added
  26936. * to reproduce the gltf light falloff.
  26937. */
  26938. set useGLTFLightFalloff(value: boolean);
  26939. /**
  26940. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26941. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26942. */
  26943. useRadianceOverAlpha: boolean;
  26944. /**
  26945. * Allows using an object space normal map (instead of tangent space).
  26946. */
  26947. useObjectSpaceNormalMap: boolean;
  26948. /**
  26949. * Allows using the bump map in parallax mode.
  26950. */
  26951. useParallax: boolean;
  26952. /**
  26953. * Allows using the bump map in parallax occlusion mode.
  26954. */
  26955. useParallaxOcclusion: boolean;
  26956. /**
  26957. * Controls the scale bias of the parallax mode.
  26958. */
  26959. parallaxScaleBias: number;
  26960. /**
  26961. * If sets to true, disables all the lights affecting the material.
  26962. */
  26963. disableLighting: boolean;
  26964. /**
  26965. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26966. */
  26967. forceIrradianceInFragment: boolean;
  26968. /**
  26969. * Number of Simultaneous lights allowed on the material.
  26970. */
  26971. maxSimultaneousLights: number;
  26972. /**
  26973. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26974. */
  26975. invertNormalMapX: boolean;
  26976. /**
  26977. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26978. */
  26979. invertNormalMapY: boolean;
  26980. /**
  26981. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26982. */
  26983. twoSidedLighting: boolean;
  26984. /**
  26985. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26986. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26987. */
  26988. useAlphaFresnel: boolean;
  26989. /**
  26990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26991. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26992. */
  26993. useLinearAlphaFresnel: boolean;
  26994. /**
  26995. * Let user defines the brdf lookup texture used for IBL.
  26996. * A default 8bit version is embedded but you could point at :
  26997. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  26998. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  26999. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27000. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27001. */
  27002. environmentBRDFTexture: Nullable<BaseTexture>;
  27003. /**
  27004. * Force normal to face away from face.
  27005. */
  27006. forceNormalForward: boolean;
  27007. /**
  27008. * Enables specular anti aliasing in the PBR shader.
  27009. * It will both interacts on the Geometry for analytical and IBL lighting.
  27010. * It also prefilter the roughness map based on the bump values.
  27011. */
  27012. enableSpecularAntiAliasing: boolean;
  27013. /**
  27014. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27015. * makes the reflect vector face the model (under horizon).
  27016. */
  27017. useHorizonOcclusion: boolean;
  27018. /**
  27019. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27020. * too much the area relying on ambient texture to define their ambient occlusion.
  27021. */
  27022. useRadianceOcclusion: boolean;
  27023. /**
  27024. * If set to true, no lighting calculations will be applied.
  27025. */
  27026. unlit: boolean;
  27027. /**
  27028. * Gets the image processing configuration used either in this material.
  27029. */
  27030. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27031. /**
  27032. * Sets the Default image processing configuration used either in the this material.
  27033. *
  27034. * If sets to null, the scene one is in use.
  27035. */
  27036. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27037. /**
  27038. * Gets wether the color curves effect is enabled.
  27039. */
  27040. get cameraColorCurvesEnabled(): boolean;
  27041. /**
  27042. * Sets wether the color curves effect is enabled.
  27043. */
  27044. set cameraColorCurvesEnabled(value: boolean);
  27045. /**
  27046. * Gets wether the color grading effect is enabled.
  27047. */
  27048. get cameraColorGradingEnabled(): boolean;
  27049. /**
  27050. * Gets wether the color grading effect is enabled.
  27051. */
  27052. set cameraColorGradingEnabled(value: boolean);
  27053. /**
  27054. * Gets wether tonemapping is enabled or not.
  27055. */
  27056. get cameraToneMappingEnabled(): boolean;
  27057. /**
  27058. * Sets wether tonemapping is enabled or not
  27059. */
  27060. set cameraToneMappingEnabled(value: boolean);
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. get cameraExposure(): number;
  27067. /**
  27068. * The camera exposure used on this material.
  27069. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27070. * This corresponds to a photographic exposure.
  27071. */
  27072. set cameraExposure(value: number);
  27073. /**
  27074. * Gets The camera contrast used on this material.
  27075. */
  27076. get cameraContrast(): number;
  27077. /**
  27078. * Sets The camera contrast used on this material.
  27079. */
  27080. set cameraContrast(value: number);
  27081. /**
  27082. * Gets the Color Grading 2D Lookup Texture.
  27083. */
  27084. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27085. /**
  27086. * Sets the Color Grading 2D Lookup Texture.
  27087. */
  27088. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27089. /**
  27090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27092. * 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;
  27093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27094. */
  27095. get cameraColorCurves(): Nullable<ColorCurves>;
  27096. /**
  27097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27099. * 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;
  27100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27101. */
  27102. set cameraColorCurves(value: Nullable<ColorCurves>);
  27103. /**
  27104. * Instantiates a new PBRMaterial instance.
  27105. *
  27106. * @param name The material name
  27107. * @param scene The scene the material will be use in.
  27108. */
  27109. constructor(name: string, scene: Scene);
  27110. /**
  27111. * Returns the name of this material class.
  27112. */
  27113. getClassName(): string;
  27114. /**
  27115. * Makes a duplicate of the current material.
  27116. * @param name - name to use for the new material.
  27117. */
  27118. clone(name: string): PBRMaterial;
  27119. /**
  27120. * Serializes this PBR Material.
  27121. * @returns - An object with the serialized material.
  27122. */
  27123. serialize(): any;
  27124. /**
  27125. * Parses a PBR Material from a serialized object.
  27126. * @param source - Serialized object.
  27127. * @param scene - BJS scene instance.
  27128. * @param rootUrl - url for the scene object
  27129. * @returns - PBRMaterial
  27130. */
  27131. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27132. }
  27133. }
  27134. declare module BABYLON {
  27135. /** @hidden */
  27136. export var mrtFragmentDeclaration: {
  27137. name: string;
  27138. shader: string;
  27139. };
  27140. }
  27141. declare module BABYLON {
  27142. /** @hidden */
  27143. export var geometryPixelShader: {
  27144. name: string;
  27145. shader: string;
  27146. };
  27147. }
  27148. declare module BABYLON {
  27149. /** @hidden */
  27150. export var geometryVertexShader: {
  27151. name: string;
  27152. shader: string;
  27153. };
  27154. }
  27155. declare module BABYLON {
  27156. /** @hidden */
  27157. interface ISavedTransformationMatrix {
  27158. world: Matrix;
  27159. viewProjection: Matrix;
  27160. }
  27161. /**
  27162. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27163. */
  27164. export class GeometryBufferRenderer {
  27165. /**
  27166. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27167. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27168. */
  27169. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27170. /**
  27171. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27172. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27173. */
  27174. static readonly POSITION_TEXTURE_TYPE: number;
  27175. /**
  27176. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27177. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27178. */
  27179. static readonly VELOCITY_TEXTURE_TYPE: number;
  27180. /**
  27181. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27182. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27183. */
  27184. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27185. /**
  27186. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27187. * in order to compute objects velocities when enableVelocity is set to "true"
  27188. * @hidden
  27189. */
  27190. _previousTransformationMatrices: {
  27191. [index: number]: ISavedTransformationMatrix;
  27192. };
  27193. /**
  27194. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27195. * in order to compute objects velocities when enableVelocity is set to "true"
  27196. * @hidden
  27197. */
  27198. _previousBonesTransformationMatrices: {
  27199. [index: number]: Float32Array;
  27200. };
  27201. /**
  27202. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27203. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27204. */
  27205. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27206. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27207. renderTransparentMeshes: boolean;
  27208. private _scene;
  27209. private _resizeObserver;
  27210. private _multiRenderTarget;
  27211. private _ratio;
  27212. private _enablePosition;
  27213. private _enableVelocity;
  27214. private _enableReflectivity;
  27215. private _positionIndex;
  27216. private _velocityIndex;
  27217. private _reflectivityIndex;
  27218. private _depthNormalIndex;
  27219. private _linkedWithPrePass;
  27220. private _prePassRenderer;
  27221. private _attachments;
  27222. protected _effect: Effect;
  27223. protected _cachedDefines: string;
  27224. /**
  27225. * @hidden
  27226. * Sets up internal structures to share outputs with PrePassRenderer
  27227. * This method should only be called by the PrePassRenderer itself
  27228. */
  27229. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27230. /**
  27231. * @hidden
  27232. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27233. * This method should only be called by the PrePassRenderer itself
  27234. */
  27235. _unlinkPrePassRenderer(): void;
  27236. /**
  27237. * @hidden
  27238. * Resets the geometry buffer layout
  27239. */
  27240. _resetLayout(): void;
  27241. /**
  27242. * @hidden
  27243. * Replaces a texture in the geometry buffer renderer
  27244. * Useful when linking textures of the prepass renderer
  27245. */
  27246. _forceTextureType(geometryBufferType: number, index: number): void;
  27247. /**
  27248. * @hidden
  27249. * Sets texture attachments
  27250. * Useful when linking textures of the prepass renderer
  27251. */
  27252. _setAttachments(attachments: number[]): void;
  27253. /**
  27254. * @hidden
  27255. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27256. * Useful when linking textures of the prepass renderer
  27257. */
  27258. _linkInternalTexture(internalTexture: InternalTexture): void;
  27259. /**
  27260. * Gets the render list (meshes to be rendered) used in the G buffer.
  27261. */
  27262. get renderList(): Nullable<AbstractMesh[]>;
  27263. /**
  27264. * Set the render list (meshes to be rendered) used in the G buffer.
  27265. */
  27266. set renderList(meshes: Nullable<AbstractMesh[]>);
  27267. /**
  27268. * Gets wether or not G buffer are supported by the running hardware.
  27269. * This requires draw buffer supports
  27270. */
  27271. get isSupported(): boolean;
  27272. /**
  27273. * Returns the index of the given texture type in the G-Buffer textures array
  27274. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27275. * @returns the index of the given texture type in the G-Buffer textures array
  27276. */
  27277. getTextureIndex(textureType: number): number;
  27278. /**
  27279. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27280. */
  27281. get enablePosition(): boolean;
  27282. /**
  27283. * Sets whether or not objects positions are enabled for the G buffer.
  27284. */
  27285. set enablePosition(enable: boolean);
  27286. /**
  27287. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27288. */
  27289. get enableVelocity(): boolean;
  27290. /**
  27291. * Sets wether or not objects velocities are enabled for the G buffer.
  27292. */
  27293. set enableVelocity(enable: boolean);
  27294. /**
  27295. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27296. */
  27297. get enableReflectivity(): boolean;
  27298. /**
  27299. * Sets wether or not objects roughness are enabled for the G buffer.
  27300. */
  27301. set enableReflectivity(enable: boolean);
  27302. /**
  27303. * Gets the scene associated with the buffer.
  27304. */
  27305. get scene(): Scene;
  27306. /**
  27307. * Gets the ratio used by the buffer during its creation.
  27308. * How big is the buffer related to the main canvas.
  27309. */
  27310. get ratio(): number;
  27311. /** @hidden */
  27312. static _SceneComponentInitialization: (scene: Scene) => void;
  27313. /**
  27314. * Creates a new G Buffer for the scene
  27315. * @param scene The scene the buffer belongs to
  27316. * @param ratio How big is the buffer related to the main canvas.
  27317. */
  27318. constructor(scene: Scene, ratio?: number);
  27319. /**
  27320. * Checks wether everything is ready to render a submesh to the G buffer.
  27321. * @param subMesh the submesh to check readiness for
  27322. * @param useInstances is the mesh drawn using instance or not
  27323. * @returns true if ready otherwise false
  27324. */
  27325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27326. /**
  27327. * Gets the current underlying G Buffer.
  27328. * @returns the buffer
  27329. */
  27330. getGBuffer(): MultiRenderTarget;
  27331. /**
  27332. * Gets the number of samples used to render the buffer (anti aliasing).
  27333. */
  27334. get samples(): number;
  27335. /**
  27336. * Sets the number of samples used to render the buffer (anti aliasing).
  27337. */
  27338. set samples(value: number);
  27339. /**
  27340. * Disposes the renderer and frees up associated resources.
  27341. */
  27342. dispose(): void;
  27343. private _assignRenderTargetIndices;
  27344. protected _createRenderTargets(): void;
  27345. private _copyBonesTransformationMatrices;
  27346. }
  27347. }
  27348. declare module BABYLON {
  27349. /**
  27350. * Renders a pre pass of the scene
  27351. * This means every mesh in the scene will be rendered to a render target texture
  27352. * And then this texture will be composited to the rendering canvas with post processes
  27353. * It is necessary for effects like subsurface scattering or deferred shading
  27354. */
  27355. export class PrePassRenderer {
  27356. /** @hidden */
  27357. static _SceneComponentInitialization: (scene: Scene) => void;
  27358. private _textureFormats;
  27359. /**
  27360. * To save performance, we can excluded skinned meshes from the prepass
  27361. */
  27362. excludedSkinnedMesh: AbstractMesh[];
  27363. /**
  27364. * Force material to be excluded from the prepass
  27365. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27366. * and you don't want a material to show in the effect.
  27367. */
  27368. excludedMaterials: Material[];
  27369. private _textureIndices;
  27370. private _scene;
  27371. private _engine;
  27372. private _isDirty;
  27373. /**
  27374. * Number of textures in the multi render target texture where the scene is directly rendered
  27375. */
  27376. mrtCount: number;
  27377. /**
  27378. * The render target where the scene is directly rendered
  27379. */
  27380. prePassRT: MultiRenderTarget;
  27381. private _multiRenderAttachments;
  27382. private _defaultAttachments;
  27383. private _clearAttachments;
  27384. private _postProcesses;
  27385. private readonly _clearColor;
  27386. /**
  27387. * Image processing post process for composition
  27388. */
  27389. imageProcessingPostProcess: ImageProcessingPostProcess;
  27390. /**
  27391. * Configuration for prepass effects
  27392. */
  27393. private _effectConfigurations;
  27394. private _mrtFormats;
  27395. private _mrtLayout;
  27396. private _enabled;
  27397. /**
  27398. * Indicates if the prepass is enabled
  27399. */
  27400. get enabled(): boolean;
  27401. /**
  27402. * How many samples are used for MSAA of the scene render target
  27403. */
  27404. get samples(): number;
  27405. set samples(n: number);
  27406. private _geometryBuffer;
  27407. private _useGeometryBufferFallback;
  27408. /**
  27409. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27410. */
  27411. get useGeometryBufferFallback(): boolean;
  27412. set useGeometryBufferFallback(value: boolean);
  27413. /**
  27414. * Instanciates a prepass renderer
  27415. * @param scene The scene
  27416. */
  27417. constructor(scene: Scene);
  27418. private _initializeAttachments;
  27419. private _createCompositionEffect;
  27420. /**
  27421. * Indicates if rendering a prepass is supported
  27422. */
  27423. get isSupported(): boolean;
  27424. /**
  27425. * Sets the proper output textures to draw in the engine.
  27426. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27427. * @param subMesh Submesh on which the effect is applied
  27428. */
  27429. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27430. /**
  27431. * @hidden
  27432. */
  27433. _beforeCameraDraw(): void;
  27434. /**
  27435. * @hidden
  27436. */
  27437. _afterCameraDraw(): void;
  27438. private _checkRTSize;
  27439. private _bindFrameBuffer;
  27440. /**
  27441. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27442. */
  27443. clear(): void;
  27444. private _setState;
  27445. private _updateGeometryBufferLayout;
  27446. /**
  27447. * Adds an effect configuration to the prepass.
  27448. * If an effect has already been added, it won't add it twice and will return the configuration
  27449. * already present.
  27450. * @param cfg the effect configuration
  27451. * @return the effect configuration now used by the prepass
  27452. */
  27453. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27454. /**
  27455. * Returns the index of a texture in the multi render target texture array.
  27456. * @param type Texture type
  27457. * @return The index
  27458. */
  27459. getIndex(type: number): number;
  27460. private _enable;
  27461. private _disable;
  27462. private _resetLayout;
  27463. private _resetPostProcessChain;
  27464. private _bindPostProcessChain;
  27465. /**
  27466. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27467. */
  27468. markAsDirty(): void;
  27469. /**
  27470. * Enables a texture on the MultiRenderTarget for prepass
  27471. */
  27472. private _enableTextures;
  27473. private _update;
  27474. private _markAllMaterialsAsPrePassDirty;
  27475. /**
  27476. * Disposes the prepass renderer.
  27477. */
  27478. dispose(): void;
  27479. }
  27480. }
  27481. declare module BABYLON {
  27482. /**
  27483. * Size options for a post process
  27484. */
  27485. export type PostProcessOptions = {
  27486. width: number;
  27487. height: number;
  27488. };
  27489. /**
  27490. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27491. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27492. */
  27493. export class PostProcess {
  27494. /**
  27495. * Gets or sets the unique id of the post process
  27496. */
  27497. uniqueId: number;
  27498. /** Name of the PostProcess. */
  27499. name: string;
  27500. /**
  27501. * Width of the texture to apply the post process on
  27502. */
  27503. width: number;
  27504. /**
  27505. * Height of the texture to apply the post process on
  27506. */
  27507. height: number;
  27508. /**
  27509. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27510. */
  27511. nodeMaterialSource: Nullable<NodeMaterial>;
  27512. /**
  27513. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27514. * @hidden
  27515. */
  27516. _outputTexture: Nullable<InternalTexture>;
  27517. /**
  27518. * Sampling mode used by the shader
  27519. * See https://doc.babylonjs.com/classes/3.1/texture
  27520. */
  27521. renderTargetSamplingMode: number;
  27522. /**
  27523. * Clear color to use when screen clearing
  27524. */
  27525. clearColor: Color4;
  27526. /**
  27527. * If the buffer needs to be cleared before applying the post process. (default: true)
  27528. * Should be set to false if shader will overwrite all previous pixels.
  27529. */
  27530. autoClear: boolean;
  27531. /**
  27532. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27533. */
  27534. alphaMode: number;
  27535. /**
  27536. * Sets the setAlphaBlendConstants of the babylon engine
  27537. */
  27538. alphaConstants: Color4;
  27539. /**
  27540. * Animations to be used for the post processing
  27541. */
  27542. animations: Animation[];
  27543. /**
  27544. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27545. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27546. */
  27547. enablePixelPerfectMode: boolean;
  27548. /**
  27549. * Force the postprocess to be applied without taking in account viewport
  27550. */
  27551. forceFullscreenViewport: boolean;
  27552. /**
  27553. * List of inspectable custom properties (used by the Inspector)
  27554. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27555. */
  27556. inspectableCustomProperties: IInspectable[];
  27557. /**
  27558. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27559. *
  27560. * | Value | Type | Description |
  27561. * | ----- | ----------------------------------- | ----------- |
  27562. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27563. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27564. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27565. *
  27566. */
  27567. scaleMode: number;
  27568. /**
  27569. * Force textures to be a power of two (default: false)
  27570. */
  27571. alwaysForcePOT: boolean;
  27572. private _samples;
  27573. /**
  27574. * Number of sample textures (default: 1)
  27575. */
  27576. get samples(): number;
  27577. set samples(n: number);
  27578. /**
  27579. * Modify the scale of the post process to be the same as the viewport (default: false)
  27580. */
  27581. adaptScaleToCurrentViewport: boolean;
  27582. private _camera;
  27583. protected _scene: Scene;
  27584. private _engine;
  27585. private _options;
  27586. private _reusable;
  27587. private _textureType;
  27588. private _textureFormat;
  27589. /**
  27590. * Smart array of input and output textures for the post process.
  27591. * @hidden
  27592. */
  27593. _textures: SmartArray<InternalTexture>;
  27594. /**
  27595. * The index in _textures that corresponds to the output texture.
  27596. * @hidden
  27597. */
  27598. _currentRenderTextureInd: number;
  27599. private _effect;
  27600. private _samplers;
  27601. private _fragmentUrl;
  27602. private _vertexUrl;
  27603. private _parameters;
  27604. private _scaleRatio;
  27605. protected _indexParameters: any;
  27606. private _shareOutputWithPostProcess;
  27607. private _texelSize;
  27608. private _forcedOutputTexture;
  27609. /**
  27610. * Prepass configuration in case this post process needs a texture from prepass
  27611. * @hidden
  27612. */
  27613. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27614. /**
  27615. * Returns the fragment url or shader name used in the post process.
  27616. * @returns the fragment url or name in the shader store.
  27617. */
  27618. getEffectName(): string;
  27619. /**
  27620. * An event triggered when the postprocess is activated.
  27621. */
  27622. onActivateObservable: Observable<Camera>;
  27623. private _onActivateObserver;
  27624. /**
  27625. * A function that is added to the onActivateObservable
  27626. */
  27627. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27628. /**
  27629. * An event triggered when the postprocess changes its size.
  27630. */
  27631. onSizeChangedObservable: Observable<PostProcess>;
  27632. private _onSizeChangedObserver;
  27633. /**
  27634. * A function that is added to the onSizeChangedObservable
  27635. */
  27636. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27637. /**
  27638. * An event triggered when the postprocess applies its effect.
  27639. */
  27640. onApplyObservable: Observable<Effect>;
  27641. private _onApplyObserver;
  27642. /**
  27643. * A function that is added to the onApplyObservable
  27644. */
  27645. set onApply(callback: (effect: Effect) => void);
  27646. /**
  27647. * An event triggered before rendering the postprocess
  27648. */
  27649. onBeforeRenderObservable: Observable<Effect>;
  27650. private _onBeforeRenderObserver;
  27651. /**
  27652. * A function that is added to the onBeforeRenderObservable
  27653. */
  27654. set onBeforeRender(callback: (effect: Effect) => void);
  27655. /**
  27656. * An event triggered after rendering the postprocess
  27657. */
  27658. onAfterRenderObservable: Observable<Effect>;
  27659. private _onAfterRenderObserver;
  27660. /**
  27661. * A function that is added to the onAfterRenderObservable
  27662. */
  27663. set onAfterRender(callback: (efect: Effect) => void);
  27664. /**
  27665. * 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
  27666. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27667. */
  27668. get inputTexture(): InternalTexture;
  27669. set inputTexture(value: InternalTexture);
  27670. /**
  27671. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27672. * the only way to unset it is to use this function to restore its internal state
  27673. */
  27674. restoreDefaultInputTexture(): void;
  27675. /**
  27676. * Gets the camera which post process is applied to.
  27677. * @returns The camera the post process is applied to.
  27678. */
  27679. getCamera(): Camera;
  27680. /**
  27681. * Gets the texel size of the postprocess.
  27682. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27683. */
  27684. get texelSize(): Vector2;
  27685. /**
  27686. * Creates a new instance PostProcess
  27687. * @param name The name of the PostProcess.
  27688. * @param fragmentUrl The url of the fragment shader to be used.
  27689. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27690. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27691. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27692. * @param camera The camera to apply the render pass to.
  27693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27694. * @param engine The engine which the post process will be applied. (default: current engine)
  27695. * @param reusable If the post process can be reused on the same frame. (default: false)
  27696. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27697. * @param textureType Type of textures used when performing the post process. (default: 0)
  27698. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27699. * @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
  27700. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27701. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27702. */
  27703. 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);
  27704. /**
  27705. * Gets a string identifying the name of the class
  27706. * @returns "PostProcess" string
  27707. */
  27708. getClassName(): string;
  27709. /**
  27710. * Gets the engine which this post process belongs to.
  27711. * @returns The engine the post process was enabled with.
  27712. */
  27713. getEngine(): Engine;
  27714. /**
  27715. * The effect that is created when initializing the post process.
  27716. * @returns The created effect corresponding the the postprocess.
  27717. */
  27718. getEffect(): Effect;
  27719. /**
  27720. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27721. * @param postProcess The post process to share the output with.
  27722. * @returns This post process.
  27723. */
  27724. shareOutputWith(postProcess: PostProcess): PostProcess;
  27725. /**
  27726. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27727. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27728. */
  27729. useOwnOutput(): void;
  27730. /**
  27731. * Updates the effect with the current post process compile time values and recompiles the shader.
  27732. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27733. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27734. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27735. * @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
  27736. * @param onCompiled Called when the shader has been compiled.
  27737. * @param onError Called if there is an error when compiling a shader.
  27738. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27739. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27740. */
  27741. 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;
  27742. /**
  27743. * The post process is reusable if it can be used multiple times within one frame.
  27744. * @returns If the post process is reusable
  27745. */
  27746. isReusable(): boolean;
  27747. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27748. markTextureDirty(): void;
  27749. /**
  27750. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27751. * 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.
  27752. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27753. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27754. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27755. * @returns The target texture that was bound to be written to.
  27756. */
  27757. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27758. /**
  27759. * If the post process is supported.
  27760. */
  27761. get isSupported(): boolean;
  27762. /**
  27763. * The aspect ratio of the output texture.
  27764. */
  27765. get aspectRatio(): number;
  27766. /**
  27767. * Get a value indicating if the post-process is ready to be used
  27768. * @returns true if the post-process is ready (shader is compiled)
  27769. */
  27770. isReady(): boolean;
  27771. /**
  27772. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27773. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27774. */
  27775. apply(): Nullable<Effect>;
  27776. private _disposeTextures;
  27777. /**
  27778. * Sets the required values to the prepass renderer.
  27779. * @param prePassRenderer defines the prepass renderer to setup.
  27780. * @returns true if the pre pass is needed.
  27781. */
  27782. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27783. /**
  27784. * Disposes the post process.
  27785. * @param camera The camera to dispose the post process on.
  27786. */
  27787. dispose(camera?: Camera): void;
  27788. /**
  27789. * Serializes the particle system to a JSON object
  27790. * @returns the JSON object
  27791. */
  27792. serialize(): any;
  27793. /**
  27794. * Creates a material from parsed material data
  27795. * @param parsedPostProcess defines parsed post process data
  27796. * @param scene defines the hosting scene
  27797. * @param rootUrl defines the root URL to use to load textures
  27798. * @returns a new post process
  27799. */
  27800. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27801. }
  27802. }
  27803. declare module BABYLON {
  27804. /** @hidden */
  27805. export var kernelBlurVaryingDeclaration: {
  27806. name: string;
  27807. shader: string;
  27808. };
  27809. }
  27810. declare module BABYLON {
  27811. /** @hidden */
  27812. export var kernelBlurFragment: {
  27813. name: string;
  27814. shader: string;
  27815. };
  27816. }
  27817. declare module BABYLON {
  27818. /** @hidden */
  27819. export var kernelBlurFragment2: {
  27820. name: string;
  27821. shader: string;
  27822. };
  27823. }
  27824. declare module BABYLON {
  27825. /** @hidden */
  27826. export var kernelBlurPixelShader: {
  27827. name: string;
  27828. shader: string;
  27829. };
  27830. }
  27831. declare module BABYLON {
  27832. /** @hidden */
  27833. export var kernelBlurVertex: {
  27834. name: string;
  27835. shader: string;
  27836. };
  27837. }
  27838. declare module BABYLON {
  27839. /** @hidden */
  27840. export var kernelBlurVertexShader: {
  27841. name: string;
  27842. shader: string;
  27843. };
  27844. }
  27845. declare module BABYLON {
  27846. /**
  27847. * The Blur Post Process which blurs an image based on a kernel and direction.
  27848. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27849. */
  27850. export class BlurPostProcess extends PostProcess {
  27851. private blockCompilation;
  27852. protected _kernel: number;
  27853. protected _idealKernel: number;
  27854. protected _packedFloat: boolean;
  27855. private _staticDefines;
  27856. /** The direction in which to blur the image. */
  27857. direction: Vector2;
  27858. /**
  27859. * Sets the length in pixels of the blur sample region
  27860. */
  27861. set kernel(v: number);
  27862. /**
  27863. * Gets the length in pixels of the blur sample region
  27864. */
  27865. get kernel(): number;
  27866. /**
  27867. * Sets wether or not the blur needs to unpack/repack floats
  27868. */
  27869. set packedFloat(v: boolean);
  27870. /**
  27871. * Gets wether or not the blur is unpacking/repacking floats
  27872. */
  27873. get packedFloat(): boolean;
  27874. /**
  27875. * Gets a string identifying the name of the class
  27876. * @returns "BlurPostProcess" string
  27877. */
  27878. getClassName(): string;
  27879. /**
  27880. * Creates a new instance BlurPostProcess
  27881. * @param name The name of the effect.
  27882. * @param direction The direction in which to blur the image.
  27883. * @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.
  27884. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27885. * @param camera The camera to apply the render pass to.
  27886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27887. * @param engine The engine which the post process will be applied. (default: current engine)
  27888. * @param reusable If the post process can be reused on the same frame. (default: false)
  27889. * @param textureType Type of textures used when performing the post process. (default: 0)
  27890. * @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)
  27891. */
  27892. 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);
  27893. /**
  27894. * Updates the effect with the current post process compile time values and recompiles the shader.
  27895. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27896. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27897. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27898. * @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
  27899. * @param onCompiled Called when the shader has been compiled.
  27900. * @param onError Called if there is an error when compiling a shader.
  27901. */
  27902. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27903. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27904. /**
  27905. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27906. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27907. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27908. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27909. * The gaps between physical kernels are compensated for in the weighting of the samples
  27910. * @param idealKernel Ideal blur kernel.
  27911. * @return Nearest best kernel.
  27912. */
  27913. protected _nearestBestKernel(idealKernel: number): number;
  27914. /**
  27915. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27916. * @param x The point on the Gaussian distribution to sample.
  27917. * @return the value of the Gaussian function at x.
  27918. */
  27919. protected _gaussianWeight(x: number): number;
  27920. /**
  27921. * Generates a string that can be used as a floating point number in GLSL.
  27922. * @param x Value to print.
  27923. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27924. * @return GLSL float string.
  27925. */
  27926. protected _glslFloat(x: number, decimalFigures?: number): string;
  27927. /** @hidden */
  27928. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27929. }
  27930. }
  27931. declare module BABYLON {
  27932. /**
  27933. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27934. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27935. * You can then easily use it as a reflectionTexture on a flat surface.
  27936. * In case the surface is not a plane, please consider relying on reflection probes.
  27937. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27938. */
  27939. export class MirrorTexture extends RenderTargetTexture {
  27940. private scene;
  27941. /**
  27942. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27943. * 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.
  27944. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27945. */
  27946. mirrorPlane: Plane;
  27947. /**
  27948. * Define the blur ratio used to blur the reflection if needed.
  27949. */
  27950. set blurRatio(value: number);
  27951. get blurRatio(): number;
  27952. /**
  27953. * Define the adaptive blur kernel used to blur the reflection if needed.
  27954. * This will autocompute the closest best match for the `blurKernel`
  27955. */
  27956. set adaptiveBlurKernel(value: number);
  27957. /**
  27958. * Define the blur kernel used to blur the reflection if needed.
  27959. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27960. */
  27961. set blurKernel(value: number);
  27962. /**
  27963. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27964. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27965. */
  27966. set blurKernelX(value: number);
  27967. get blurKernelX(): number;
  27968. /**
  27969. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27970. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27971. */
  27972. set blurKernelY(value: number);
  27973. get blurKernelY(): number;
  27974. private _autoComputeBlurKernel;
  27975. protected _onRatioRescale(): void;
  27976. private _updateGammaSpace;
  27977. private _imageProcessingConfigChangeObserver;
  27978. private _transformMatrix;
  27979. private _mirrorMatrix;
  27980. private _savedViewMatrix;
  27981. private _blurX;
  27982. private _blurY;
  27983. private _adaptiveBlurKernel;
  27984. private _blurKernelX;
  27985. private _blurKernelY;
  27986. private _blurRatio;
  27987. /**
  27988. * Instantiates a Mirror Texture.
  27989. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27990. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27991. * You can then easily use it as a reflectionTexture on a flat surface.
  27992. * In case the surface is not a plane, please consider relying on reflection probes.
  27993. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27994. * @param name
  27995. * @param size
  27996. * @param scene
  27997. * @param generateMipMaps
  27998. * @param type
  27999. * @param samplingMode
  28000. * @param generateDepthBuffer
  28001. */
  28002. constructor(name: string, size: number | {
  28003. width: number;
  28004. height: number;
  28005. } | {
  28006. ratio: number;
  28007. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28008. private _preparePostProcesses;
  28009. /**
  28010. * Clone the mirror texture.
  28011. * @returns the cloned texture
  28012. */
  28013. clone(): MirrorTexture;
  28014. /**
  28015. * Serialize the texture to a JSON representation you could use in Parse later on
  28016. * @returns the serialized JSON representation
  28017. */
  28018. serialize(): any;
  28019. /**
  28020. * Dispose the texture and release its associated resources.
  28021. */
  28022. dispose(): void;
  28023. }
  28024. }
  28025. declare module BABYLON {
  28026. /**
  28027. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28028. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28029. */
  28030. export class Texture extends BaseTexture {
  28031. /**
  28032. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28033. */
  28034. static SerializeBuffers: boolean;
  28035. /** @hidden */
  28036. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28037. /** @hidden */
  28038. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28039. /** @hidden */
  28040. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28041. /** nearest is mag = nearest and min = nearest and mip = linear */
  28042. static readonly NEAREST_SAMPLINGMODE: number;
  28043. /** nearest is mag = nearest and min = nearest and mip = linear */
  28044. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28045. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28046. static readonly BILINEAR_SAMPLINGMODE: number;
  28047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28048. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28049. /** Trilinear is mag = linear and min = linear and mip = linear */
  28050. static readonly TRILINEAR_SAMPLINGMODE: number;
  28051. /** Trilinear is mag = linear and min = linear and mip = linear */
  28052. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28053. /** mag = nearest and min = nearest and mip = nearest */
  28054. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28055. /** mag = nearest and min = linear and mip = nearest */
  28056. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28057. /** mag = nearest and min = linear and mip = linear */
  28058. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28059. /** mag = nearest and min = linear and mip = none */
  28060. static readonly NEAREST_LINEAR: number;
  28061. /** mag = nearest and min = nearest and mip = none */
  28062. static readonly NEAREST_NEAREST: number;
  28063. /** mag = linear and min = nearest and mip = nearest */
  28064. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28065. /** mag = linear and min = nearest and mip = linear */
  28066. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28067. /** mag = linear and min = linear and mip = none */
  28068. static readonly LINEAR_LINEAR: number;
  28069. /** mag = linear and min = nearest and mip = none */
  28070. static readonly LINEAR_NEAREST: number;
  28071. /** Explicit coordinates mode */
  28072. static readonly EXPLICIT_MODE: number;
  28073. /** Spherical coordinates mode */
  28074. static readonly SPHERICAL_MODE: number;
  28075. /** Planar coordinates mode */
  28076. static readonly PLANAR_MODE: number;
  28077. /** Cubic coordinates mode */
  28078. static readonly CUBIC_MODE: number;
  28079. /** Projection coordinates mode */
  28080. static readonly PROJECTION_MODE: number;
  28081. /** Inverse Cubic coordinates mode */
  28082. static readonly SKYBOX_MODE: number;
  28083. /** Inverse Cubic coordinates mode */
  28084. static readonly INVCUBIC_MODE: number;
  28085. /** Equirectangular coordinates mode */
  28086. static readonly EQUIRECTANGULAR_MODE: number;
  28087. /** Equirectangular Fixed coordinates mode */
  28088. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28089. /** Equirectangular Fixed Mirrored coordinates mode */
  28090. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28091. /** Texture is not repeating outside of 0..1 UVs */
  28092. static readonly CLAMP_ADDRESSMODE: number;
  28093. /** Texture is repeating outside of 0..1 UVs */
  28094. static readonly WRAP_ADDRESSMODE: number;
  28095. /** Texture is repeating and mirrored */
  28096. static readonly MIRROR_ADDRESSMODE: number;
  28097. /**
  28098. * 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
  28099. */
  28100. static UseSerializedUrlIfAny: boolean;
  28101. /**
  28102. * Define the url of the texture.
  28103. */
  28104. url: Nullable<string>;
  28105. /**
  28106. * Define an offset on the texture to offset the u coordinates of the UVs
  28107. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28108. */
  28109. uOffset: number;
  28110. /**
  28111. * Define an offset on the texture to offset the v coordinates of the UVs
  28112. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28113. */
  28114. vOffset: number;
  28115. /**
  28116. * Define an offset on the texture to scale the u coordinates of the UVs
  28117. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28118. */
  28119. uScale: number;
  28120. /**
  28121. * Define an offset on the texture to scale the v coordinates of the UVs
  28122. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28123. */
  28124. vScale: number;
  28125. /**
  28126. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28127. * @see https://doc.babylonjs.com/how_to/more_materials
  28128. */
  28129. uAng: number;
  28130. /**
  28131. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28132. * @see https://doc.babylonjs.com/how_to/more_materials
  28133. */
  28134. vAng: number;
  28135. /**
  28136. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28137. * @see https://doc.babylonjs.com/how_to/more_materials
  28138. */
  28139. wAng: number;
  28140. /**
  28141. * Defines the center of rotation (U)
  28142. */
  28143. uRotationCenter: number;
  28144. /**
  28145. * Defines the center of rotation (V)
  28146. */
  28147. vRotationCenter: number;
  28148. /**
  28149. * Defines the center of rotation (W)
  28150. */
  28151. wRotationCenter: number;
  28152. /**
  28153. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28154. */
  28155. homogeneousRotationInUVTransform: boolean;
  28156. /**
  28157. * Are mip maps generated for this texture or not.
  28158. */
  28159. get noMipmap(): boolean;
  28160. /**
  28161. * List of inspectable custom properties (used by the Inspector)
  28162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28163. */
  28164. inspectableCustomProperties: Nullable<IInspectable[]>;
  28165. private _noMipmap;
  28166. /** @hidden */
  28167. _invertY: boolean;
  28168. private _rowGenerationMatrix;
  28169. private _cachedTextureMatrix;
  28170. private _projectionModeMatrix;
  28171. private _t0;
  28172. private _t1;
  28173. private _t2;
  28174. private _cachedUOffset;
  28175. private _cachedVOffset;
  28176. private _cachedUScale;
  28177. private _cachedVScale;
  28178. private _cachedUAng;
  28179. private _cachedVAng;
  28180. private _cachedWAng;
  28181. private _cachedProjectionMatrixId;
  28182. private _cachedURotationCenter;
  28183. private _cachedVRotationCenter;
  28184. private _cachedWRotationCenter;
  28185. private _cachedHomogeneousRotationInUVTransform;
  28186. private _cachedCoordinatesMode;
  28187. /** @hidden */
  28188. protected _initialSamplingMode: number;
  28189. /** @hidden */
  28190. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28191. private _deleteBuffer;
  28192. protected _format: Nullable<number>;
  28193. private _delayedOnLoad;
  28194. private _delayedOnError;
  28195. private _mimeType?;
  28196. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28197. get mimeType(): string | undefined;
  28198. /**
  28199. * Observable triggered once the texture has been loaded.
  28200. */
  28201. onLoadObservable: Observable<Texture>;
  28202. protected _isBlocking: boolean;
  28203. /**
  28204. * Is the texture preventing material to render while loading.
  28205. * If false, a default texture will be used instead of the loading one during the preparation step.
  28206. */
  28207. set isBlocking(value: boolean);
  28208. get isBlocking(): boolean;
  28209. /**
  28210. * Get the current sampling mode associated with the texture.
  28211. */
  28212. get samplingMode(): number;
  28213. /**
  28214. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28215. */
  28216. get invertY(): boolean;
  28217. /**
  28218. * Instantiates a new texture.
  28219. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28220. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28221. * @param url defines the url of the picture to load as a texture
  28222. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28223. * @param noMipmap defines if the texture will require mip maps or not
  28224. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28225. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28226. * @param onLoad defines a callback triggered when the texture has been loaded
  28227. * @param onError defines a callback triggered when an error occurred during the loading session
  28228. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28229. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28230. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28231. * @param mimeType defines an optional mime type information
  28232. */
  28233. 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);
  28234. /**
  28235. * Update the url (and optional buffer) of this texture if url was null during construction.
  28236. * @param url the url of the texture
  28237. * @param buffer the buffer of the texture (defaults to null)
  28238. * @param onLoad callback called when the texture is loaded (defaults to null)
  28239. */
  28240. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28241. /**
  28242. * Finish the loading sequence of a texture flagged as delayed load.
  28243. * @hidden
  28244. */
  28245. delayLoad(): void;
  28246. private _prepareRowForTextureGeneration;
  28247. /**
  28248. * Checks if the texture has the same transform matrix than another texture
  28249. * @param texture texture to check against
  28250. * @returns true if the transforms are the same, else false
  28251. */
  28252. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28253. /**
  28254. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28255. * @returns the transform matrix of the texture.
  28256. */
  28257. getTextureMatrix(uBase?: number): Matrix;
  28258. /**
  28259. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28260. * @returns The reflection texture transform
  28261. */
  28262. getReflectionTextureMatrix(): Matrix;
  28263. /**
  28264. * Clones the texture.
  28265. * @returns the cloned texture
  28266. */
  28267. clone(): Texture;
  28268. /**
  28269. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28270. * @returns The JSON representation of the texture
  28271. */
  28272. serialize(): any;
  28273. /**
  28274. * Get the current class name of the texture useful for serialization or dynamic coding.
  28275. * @returns "Texture"
  28276. */
  28277. getClassName(): string;
  28278. /**
  28279. * Dispose the texture and release its associated resources.
  28280. */
  28281. dispose(): void;
  28282. /**
  28283. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28284. * @param parsedTexture Define the JSON representation of the texture
  28285. * @param scene Define the scene the parsed texture should be instantiated in
  28286. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28287. * @returns The parsed texture if successful
  28288. */
  28289. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28290. /**
  28291. * Creates a texture from its base 64 representation.
  28292. * @param data Define the base64 payload without the data: prefix
  28293. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28294. * @param scene Define the scene the texture should belong to
  28295. * @param noMipmap Forces the texture to not create mip map information if true
  28296. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28297. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28298. * @param onLoad define a callback triggered when the texture has been loaded
  28299. * @param onError define a callback triggered when an error occurred during the loading session
  28300. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28301. * @returns the created texture
  28302. */
  28303. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28304. /**
  28305. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28306. * @param data Define the base64 payload without the data: prefix
  28307. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28308. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28309. * @param scene Define the scene the texture should belong to
  28310. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28311. * @param noMipmap Forces the texture to not create mip map information if true
  28312. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28313. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28314. * @param onLoad define a callback triggered when the texture has been loaded
  28315. * @param onError define a callback triggered when an error occurred during the loading session
  28316. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28317. * @returns the created texture
  28318. */
  28319. 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;
  28320. }
  28321. }
  28322. declare module BABYLON {
  28323. /**
  28324. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28325. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28326. */
  28327. export class PostProcessManager {
  28328. private _scene;
  28329. private _indexBuffer;
  28330. private _vertexBuffers;
  28331. /**
  28332. * Creates a new instance PostProcess
  28333. * @param scene The scene that the post process is associated with.
  28334. */
  28335. constructor(scene: Scene);
  28336. private _prepareBuffers;
  28337. private _buildIndexBuffer;
  28338. /**
  28339. * Rebuilds the vertex buffers of the manager.
  28340. * @hidden
  28341. */
  28342. _rebuild(): void;
  28343. /**
  28344. * Prepares a frame to be run through a post process.
  28345. * @param sourceTexture The input texture to the post procesess. (default: null)
  28346. * @param postProcesses An array of post processes to be run. (default: null)
  28347. * @returns True if the post processes were able to be run.
  28348. * @hidden
  28349. */
  28350. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28351. /**
  28352. * Manually render a set of post processes to a texture.
  28353. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28354. * @param postProcesses An array of post processes to be run.
  28355. * @param targetTexture The target texture to render to.
  28356. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28357. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28358. * @param lodLevel defines which lod of the texture to render to
  28359. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28360. */
  28361. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28362. /**
  28363. * Finalize the result of the output of the postprocesses.
  28364. * @param doNotPresent If true the result will not be displayed to the screen.
  28365. * @param targetTexture The target texture to render to.
  28366. * @param faceIndex The index of the face to bind the target texture to.
  28367. * @param postProcesses The array of post processes to render.
  28368. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28369. * @hidden
  28370. */
  28371. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28372. /**
  28373. * Disposes of the post process manager.
  28374. */
  28375. dispose(): void;
  28376. }
  28377. }
  28378. declare module BABYLON {
  28379. /**
  28380. * This Helps creating a texture that will be created from a camera in your scene.
  28381. * It is basically a dynamic texture that could be used to create special effects for instance.
  28382. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28383. */
  28384. export class RenderTargetTexture extends Texture {
  28385. /**
  28386. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28387. */
  28388. static readonly REFRESHRATE_RENDER_ONCE: number;
  28389. /**
  28390. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28391. */
  28392. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28393. /**
  28394. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28395. * the central point of your effect and can save a lot of performances.
  28396. */
  28397. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28398. /**
  28399. * Use this predicate to dynamically define the list of mesh you want to render.
  28400. * If set, the renderList property will be overwritten.
  28401. */
  28402. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28403. private _renderList;
  28404. /**
  28405. * Use this list to define the list of mesh you want to render.
  28406. */
  28407. get renderList(): Nullable<Array<AbstractMesh>>;
  28408. set renderList(value: Nullable<Array<AbstractMesh>>);
  28409. /**
  28410. * Use this function to overload the renderList array at rendering time.
  28411. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28412. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28413. * the cube (if the RTT is a cube, else layerOrFace=0).
  28414. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28415. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28416. * hold dummy elements!
  28417. */
  28418. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28419. private _hookArray;
  28420. /**
  28421. * Define if particles should be rendered in your texture.
  28422. */
  28423. renderParticles: boolean;
  28424. /**
  28425. * Define if sprites should be rendered in your texture.
  28426. */
  28427. renderSprites: boolean;
  28428. /**
  28429. * Define the camera used to render the texture.
  28430. */
  28431. activeCamera: Nullable<Camera>;
  28432. /**
  28433. * Override the mesh isReady function with your own one.
  28434. */
  28435. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28436. /**
  28437. * Override the render function of the texture with your own one.
  28438. */
  28439. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28440. /**
  28441. * Define if camera post processes should be use while rendering the texture.
  28442. */
  28443. useCameraPostProcesses: boolean;
  28444. /**
  28445. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28446. */
  28447. ignoreCameraViewport: boolean;
  28448. private _postProcessManager;
  28449. private _postProcesses;
  28450. private _resizeObserver;
  28451. /**
  28452. * An event triggered when the texture is unbind.
  28453. */
  28454. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28455. /**
  28456. * An event triggered when the texture is unbind.
  28457. */
  28458. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28459. private _onAfterUnbindObserver;
  28460. /**
  28461. * Set a after unbind callback in the texture.
  28462. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28463. */
  28464. set onAfterUnbind(callback: () => void);
  28465. /**
  28466. * An event triggered before rendering the texture
  28467. */
  28468. onBeforeRenderObservable: Observable<number>;
  28469. private _onBeforeRenderObserver;
  28470. /**
  28471. * Set a before render callback in the texture.
  28472. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28473. */
  28474. set onBeforeRender(callback: (faceIndex: number) => void);
  28475. /**
  28476. * An event triggered after rendering the texture
  28477. */
  28478. onAfterRenderObservable: Observable<number>;
  28479. private _onAfterRenderObserver;
  28480. /**
  28481. * Set a after render callback in the texture.
  28482. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28483. */
  28484. set onAfterRender(callback: (faceIndex: number) => void);
  28485. /**
  28486. * An event triggered after the texture clear
  28487. */
  28488. onClearObservable: Observable<Engine>;
  28489. private _onClearObserver;
  28490. /**
  28491. * Set a clear callback in the texture.
  28492. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28493. */
  28494. set onClear(callback: (Engine: Engine) => void);
  28495. /**
  28496. * An event triggered when the texture is resized.
  28497. */
  28498. onResizeObservable: Observable<RenderTargetTexture>;
  28499. /**
  28500. * Define the clear color of the Render Target if it should be different from the scene.
  28501. */
  28502. clearColor: Color4;
  28503. protected _size: number | {
  28504. width: number;
  28505. height: number;
  28506. layers?: number;
  28507. };
  28508. protected _initialSizeParameter: number | {
  28509. width: number;
  28510. height: number;
  28511. } | {
  28512. ratio: number;
  28513. };
  28514. protected _sizeRatio: Nullable<number>;
  28515. /** @hidden */
  28516. _generateMipMaps: boolean;
  28517. protected _renderingManager: RenderingManager;
  28518. /** @hidden */
  28519. _waitingRenderList?: string[];
  28520. protected _doNotChangeAspectRatio: boolean;
  28521. protected _currentRefreshId: number;
  28522. protected _refreshRate: number;
  28523. protected _textureMatrix: Matrix;
  28524. protected _samples: number;
  28525. protected _renderTargetOptions: RenderTargetCreationOptions;
  28526. /**
  28527. * Gets render target creation options that were used.
  28528. */
  28529. get renderTargetOptions(): RenderTargetCreationOptions;
  28530. protected _onRatioRescale(): void;
  28531. /**
  28532. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28533. * It must define where the camera used to render the texture is set
  28534. */
  28535. boundingBoxPosition: Vector3;
  28536. private _boundingBoxSize;
  28537. /**
  28538. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28539. * When defined, the cubemap will switch to local mode
  28540. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28541. * @example https://www.babylonjs-playground.com/#RNASML
  28542. */
  28543. set boundingBoxSize(value: Vector3);
  28544. get boundingBoxSize(): Vector3;
  28545. /**
  28546. * In case the RTT has been created with a depth texture, get the associated
  28547. * depth texture.
  28548. * Otherwise, return null.
  28549. */
  28550. get depthStencilTexture(): Nullable<InternalTexture>;
  28551. /**
  28552. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28553. * or used a shadow, depth texture...
  28554. * @param name The friendly name of the texture
  28555. * @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)
  28556. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28557. * @param generateMipMaps True if mip maps need to be generated after render.
  28558. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28559. * @param type The type of the buffer in the RTT (int, half float, float...)
  28560. * @param isCube True if a cube texture needs to be created
  28561. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28562. * @param generateDepthBuffer True to generate a depth buffer
  28563. * @param generateStencilBuffer True to generate a stencil buffer
  28564. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28565. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28566. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28567. */
  28568. constructor(name: string, size: number | {
  28569. width: number;
  28570. height: number;
  28571. layers?: number;
  28572. } | {
  28573. ratio: number;
  28574. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28575. /**
  28576. * Creates a depth stencil texture.
  28577. * This is only available in WebGL 2 or with the depth texture extension available.
  28578. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28579. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28580. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28581. */
  28582. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28583. private _processSizeParameter;
  28584. /**
  28585. * Define the number of samples to use in case of MSAA.
  28586. * It defaults to one meaning no MSAA has been enabled.
  28587. */
  28588. get samples(): number;
  28589. set samples(value: number);
  28590. /**
  28591. * Resets the refresh counter of the texture and start bak from scratch.
  28592. * Could be useful to regenerate the texture if it is setup to render only once.
  28593. */
  28594. resetRefreshCounter(): void;
  28595. /**
  28596. * Define the refresh rate of the texture or the rendering frequency.
  28597. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28598. */
  28599. get refreshRate(): number;
  28600. set refreshRate(value: number);
  28601. /**
  28602. * Adds a post process to the render target rendering passes.
  28603. * @param postProcess define the post process to add
  28604. */
  28605. addPostProcess(postProcess: PostProcess): void;
  28606. /**
  28607. * Clear all the post processes attached to the render target
  28608. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28609. */
  28610. clearPostProcesses(dispose?: boolean): void;
  28611. /**
  28612. * Remove one of the post process from the list of attached post processes to the texture
  28613. * @param postProcess define the post process to remove from the list
  28614. */
  28615. removePostProcess(postProcess: PostProcess): void;
  28616. /** @hidden */
  28617. _shouldRender(): boolean;
  28618. /**
  28619. * Gets the actual render size of the texture.
  28620. * @returns the width of the render size
  28621. */
  28622. getRenderSize(): number;
  28623. /**
  28624. * Gets the actual render width of the texture.
  28625. * @returns the width of the render size
  28626. */
  28627. getRenderWidth(): number;
  28628. /**
  28629. * Gets the actual render height of the texture.
  28630. * @returns the height of the render size
  28631. */
  28632. getRenderHeight(): number;
  28633. /**
  28634. * Gets the actual number of layers of the texture.
  28635. * @returns the number of layers
  28636. */
  28637. getRenderLayers(): number;
  28638. /**
  28639. * Get if the texture can be rescaled or not.
  28640. */
  28641. get canRescale(): boolean;
  28642. /**
  28643. * Resize the texture using a ratio.
  28644. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28645. */
  28646. scale(ratio: number): void;
  28647. /**
  28648. * Get the texture reflection matrix used to rotate/transform the reflection.
  28649. * @returns the reflection matrix
  28650. */
  28651. getReflectionTextureMatrix(): Matrix;
  28652. /**
  28653. * Resize the texture to a new desired size.
  28654. * Be carrefull as it will recreate all the data in the new texture.
  28655. * @param size Define the new size. It can be:
  28656. * - a number for squared texture,
  28657. * - an object containing { width: number, height: number }
  28658. * - or an object containing a ratio { ratio: number }
  28659. */
  28660. resize(size: number | {
  28661. width: number;
  28662. height: number;
  28663. } | {
  28664. ratio: number;
  28665. }): void;
  28666. private _defaultRenderListPrepared;
  28667. /**
  28668. * Renders all the objects from the render list into the texture.
  28669. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28670. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28671. */
  28672. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28673. private _bestReflectionRenderTargetDimension;
  28674. private _prepareRenderingManager;
  28675. /**
  28676. * @hidden
  28677. * @param faceIndex face index to bind to if this is a cubetexture
  28678. * @param layer defines the index of the texture to bind in the array
  28679. */
  28680. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28681. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28682. private renderToTarget;
  28683. /**
  28684. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28685. * This allowed control for front to back rendering or reversly depending of the special needs.
  28686. *
  28687. * @param renderingGroupId The rendering group id corresponding to its index
  28688. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28689. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28690. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28691. */
  28692. 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;
  28693. /**
  28694. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28695. *
  28696. * @param renderingGroupId The rendering group id corresponding to its index
  28697. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28698. */
  28699. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28700. /**
  28701. * Clones the texture.
  28702. * @returns the cloned texture
  28703. */
  28704. clone(): RenderTargetTexture;
  28705. /**
  28706. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28707. * @returns The JSON representation of the texture
  28708. */
  28709. serialize(): any;
  28710. /**
  28711. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28712. */
  28713. disposeFramebufferObjects(): void;
  28714. /**
  28715. * Dispose the texture and release its associated resources.
  28716. */
  28717. dispose(): void;
  28718. /** @hidden */
  28719. _rebuild(): void;
  28720. /**
  28721. * Clear the info related to rendering groups preventing retention point in material dispose.
  28722. */
  28723. freeRenderingGroups(): void;
  28724. /**
  28725. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28726. * @returns the view count
  28727. */
  28728. getViewCount(): number;
  28729. }
  28730. }
  28731. declare module BABYLON {
  28732. /**
  28733. * Class used to manipulate GUIDs
  28734. */
  28735. export class GUID {
  28736. /**
  28737. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28738. * Be aware Math.random() could cause collisions, but:
  28739. * "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"
  28740. * @returns a pseudo random id
  28741. */
  28742. static RandomId(): string;
  28743. }
  28744. }
  28745. declare module BABYLON {
  28746. /**
  28747. * Options to be used when creating a shadow depth material
  28748. */
  28749. export interface IIOptionShadowDepthMaterial {
  28750. /** Variables in the vertex shader code that need to have their names remapped.
  28751. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28752. * "var_name" should be either: worldPos or vNormalW
  28753. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28754. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28755. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28756. */
  28757. remappedVariables?: string[];
  28758. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28759. standalone?: boolean;
  28760. }
  28761. /**
  28762. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28763. */
  28764. export class ShadowDepthWrapper {
  28765. private _scene;
  28766. private _options?;
  28767. private _baseMaterial;
  28768. private _onEffectCreatedObserver;
  28769. private _subMeshToEffect;
  28770. private _subMeshToDepthEffect;
  28771. private _meshes;
  28772. /** @hidden */
  28773. _matriceNames: any;
  28774. /** Gets the standalone status of the wrapper */
  28775. get standalone(): boolean;
  28776. /** Gets the base material the wrapper is built upon */
  28777. get baseMaterial(): Material;
  28778. /**
  28779. * Instantiate a new shadow depth wrapper.
  28780. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28781. * generate the shadow depth map. For more information, please refer to the documentation:
  28782. * https://doc.babylonjs.com/babylon101/shadows
  28783. * @param baseMaterial Material to wrap
  28784. * @param scene Define the scene the material belongs to
  28785. * @param options Options used to create the wrapper
  28786. */
  28787. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28788. /**
  28789. * Gets the effect to use to generate the depth map
  28790. * @param subMesh subMesh to get the effect for
  28791. * @param shadowGenerator shadow generator to get the effect for
  28792. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28793. */
  28794. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28795. /**
  28796. * Specifies that the submesh is ready to be used for depth rendering
  28797. * @param subMesh submesh to check
  28798. * @param defines the list of defines to take into account when checking the effect
  28799. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28800. * @param useInstances specifies that instances should be used
  28801. * @returns a boolean indicating that the submesh is ready or not
  28802. */
  28803. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28804. /**
  28805. * Disposes the resources
  28806. */
  28807. dispose(): void;
  28808. private _makeEffect;
  28809. }
  28810. }
  28811. declare module BABYLON {
  28812. /**
  28813. * Options for compiling materials.
  28814. */
  28815. export interface IMaterialCompilationOptions {
  28816. /**
  28817. * Defines whether clip planes are enabled.
  28818. */
  28819. clipPlane: boolean;
  28820. /**
  28821. * Defines whether instances are enabled.
  28822. */
  28823. useInstances: boolean;
  28824. }
  28825. /**
  28826. * Options passed when calling customShaderNameResolve
  28827. */
  28828. export interface ICustomShaderNameResolveOptions {
  28829. /**
  28830. * 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
  28831. */
  28832. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28833. }
  28834. /**
  28835. * Base class for the main features of a material in Babylon.js
  28836. */
  28837. export class Material implements IAnimatable {
  28838. /**
  28839. * Returns the triangle fill mode
  28840. */
  28841. static readonly TriangleFillMode: number;
  28842. /**
  28843. * Returns the wireframe mode
  28844. */
  28845. static readonly WireFrameFillMode: number;
  28846. /**
  28847. * Returns the point fill mode
  28848. */
  28849. static readonly PointFillMode: number;
  28850. /**
  28851. * Returns the point list draw mode
  28852. */
  28853. static readonly PointListDrawMode: number;
  28854. /**
  28855. * Returns the line list draw mode
  28856. */
  28857. static readonly LineListDrawMode: number;
  28858. /**
  28859. * Returns the line loop draw mode
  28860. */
  28861. static readonly LineLoopDrawMode: number;
  28862. /**
  28863. * Returns the line strip draw mode
  28864. */
  28865. static readonly LineStripDrawMode: number;
  28866. /**
  28867. * Returns the triangle strip draw mode
  28868. */
  28869. static readonly TriangleStripDrawMode: number;
  28870. /**
  28871. * Returns the triangle fan draw mode
  28872. */
  28873. static readonly TriangleFanDrawMode: number;
  28874. /**
  28875. * Stores the clock-wise side orientation
  28876. */
  28877. static readonly ClockWiseSideOrientation: number;
  28878. /**
  28879. * Stores the counter clock-wise side orientation
  28880. */
  28881. static readonly CounterClockWiseSideOrientation: number;
  28882. /**
  28883. * The dirty texture flag value
  28884. */
  28885. static readonly TextureDirtyFlag: number;
  28886. /**
  28887. * The dirty light flag value
  28888. */
  28889. static readonly LightDirtyFlag: number;
  28890. /**
  28891. * The dirty fresnel flag value
  28892. */
  28893. static readonly FresnelDirtyFlag: number;
  28894. /**
  28895. * The dirty attribute flag value
  28896. */
  28897. static readonly AttributesDirtyFlag: number;
  28898. /**
  28899. * The dirty misc flag value
  28900. */
  28901. static readonly MiscDirtyFlag: number;
  28902. /**
  28903. * The dirty prepass flag value
  28904. */
  28905. static readonly PrePassDirtyFlag: number;
  28906. /**
  28907. * The all dirty flag value
  28908. */
  28909. static readonly AllDirtyFlag: number;
  28910. /**
  28911. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28912. */
  28913. static readonly MATERIAL_OPAQUE: number;
  28914. /**
  28915. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28916. */
  28917. static readonly MATERIAL_ALPHATEST: number;
  28918. /**
  28919. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28920. */
  28921. static readonly MATERIAL_ALPHABLEND: number;
  28922. /**
  28923. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28924. * They are also discarded below the alpha cutoff threshold to improve performances.
  28925. */
  28926. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28927. /**
  28928. * The Whiteout method is used to blend normals.
  28929. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28930. */
  28931. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28932. /**
  28933. * The Reoriented Normal Mapping method is used to blend normals.
  28934. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28935. */
  28936. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28937. /**
  28938. * Custom callback helping to override the default shader used in the material.
  28939. */
  28940. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28941. /**
  28942. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28943. */
  28944. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28945. /**
  28946. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28947. * This means that the material can keep using a previous shader while a new one is being compiled.
  28948. * This is mostly used when shader parallel compilation is supported (true by default)
  28949. */
  28950. allowShaderHotSwapping: boolean;
  28951. /**
  28952. * The ID of the material
  28953. */
  28954. id: string;
  28955. /**
  28956. * Gets or sets the unique id of the material
  28957. */
  28958. uniqueId: number;
  28959. /**
  28960. * The name of the material
  28961. */
  28962. name: string;
  28963. /**
  28964. * Gets or sets user defined metadata
  28965. */
  28966. metadata: any;
  28967. /**
  28968. * For internal use only. Please do not use.
  28969. */
  28970. reservedDataStore: any;
  28971. /**
  28972. * Specifies if the ready state should be checked on each call
  28973. */
  28974. checkReadyOnEveryCall: boolean;
  28975. /**
  28976. * Specifies if the ready state should be checked once
  28977. */
  28978. checkReadyOnlyOnce: boolean;
  28979. /**
  28980. * The state of the material
  28981. */
  28982. state: string;
  28983. /**
  28984. * If the material can be rendered to several textures with MRT extension
  28985. */
  28986. get canRenderToMRT(): boolean;
  28987. /**
  28988. * The alpha value of the material
  28989. */
  28990. protected _alpha: number;
  28991. /**
  28992. * List of inspectable custom properties (used by the Inspector)
  28993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28994. */
  28995. inspectableCustomProperties: IInspectable[];
  28996. /**
  28997. * Sets the alpha value of the material
  28998. */
  28999. set alpha(value: number);
  29000. /**
  29001. * Gets the alpha value of the material
  29002. */
  29003. get alpha(): number;
  29004. /**
  29005. * Specifies if back face culling is enabled
  29006. */
  29007. protected _backFaceCulling: boolean;
  29008. /**
  29009. * Sets the back-face culling state
  29010. */
  29011. set backFaceCulling(value: boolean);
  29012. /**
  29013. * Gets the back-face culling state
  29014. */
  29015. get backFaceCulling(): boolean;
  29016. /**
  29017. * Stores the value for side orientation
  29018. */
  29019. sideOrientation: number;
  29020. /**
  29021. * Callback triggered when the material is compiled
  29022. */
  29023. onCompiled: Nullable<(effect: Effect) => void>;
  29024. /**
  29025. * Callback triggered when an error occurs
  29026. */
  29027. onError: Nullable<(effect: Effect, errors: string) => void>;
  29028. /**
  29029. * Callback triggered to get the render target textures
  29030. */
  29031. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29032. /**
  29033. * Gets a boolean indicating that current material needs to register RTT
  29034. */
  29035. get hasRenderTargetTextures(): boolean;
  29036. /**
  29037. * Specifies if the material should be serialized
  29038. */
  29039. doNotSerialize: boolean;
  29040. /**
  29041. * @hidden
  29042. */
  29043. _storeEffectOnSubMeshes: boolean;
  29044. /**
  29045. * Stores the animations for the material
  29046. */
  29047. animations: Nullable<Array<Animation>>;
  29048. /**
  29049. * An event triggered when the material is disposed
  29050. */
  29051. onDisposeObservable: Observable<Material>;
  29052. /**
  29053. * An observer which watches for dispose events
  29054. */
  29055. private _onDisposeObserver;
  29056. private _onUnBindObservable;
  29057. /**
  29058. * Called during a dispose event
  29059. */
  29060. set onDispose(callback: () => void);
  29061. private _onBindObservable;
  29062. /**
  29063. * An event triggered when the material is bound
  29064. */
  29065. get onBindObservable(): Observable<AbstractMesh>;
  29066. /**
  29067. * An observer which watches for bind events
  29068. */
  29069. private _onBindObserver;
  29070. /**
  29071. * Called during a bind event
  29072. */
  29073. set onBind(callback: (Mesh: AbstractMesh) => void);
  29074. /**
  29075. * An event triggered when the material is unbound
  29076. */
  29077. get onUnBindObservable(): Observable<Material>;
  29078. protected _onEffectCreatedObservable: Nullable<Observable<{
  29079. effect: Effect;
  29080. subMesh: Nullable<SubMesh>;
  29081. }>>;
  29082. /**
  29083. * An event triggered when the effect is (re)created
  29084. */
  29085. get onEffectCreatedObservable(): Observable<{
  29086. effect: Effect;
  29087. subMesh: Nullable<SubMesh>;
  29088. }>;
  29089. /**
  29090. * Stores the value of the alpha mode
  29091. */
  29092. private _alphaMode;
  29093. /**
  29094. * Sets the value of the alpha mode.
  29095. *
  29096. * | Value | Type | Description |
  29097. * | --- | --- | --- |
  29098. * | 0 | ALPHA_DISABLE | |
  29099. * | 1 | ALPHA_ADD | |
  29100. * | 2 | ALPHA_COMBINE | |
  29101. * | 3 | ALPHA_SUBTRACT | |
  29102. * | 4 | ALPHA_MULTIPLY | |
  29103. * | 5 | ALPHA_MAXIMIZED | |
  29104. * | 6 | ALPHA_ONEONE | |
  29105. * | 7 | ALPHA_PREMULTIPLIED | |
  29106. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29107. * | 9 | ALPHA_INTERPOLATE | |
  29108. * | 10 | ALPHA_SCREENMODE | |
  29109. *
  29110. */
  29111. set alphaMode(value: number);
  29112. /**
  29113. * Gets the value of the alpha mode
  29114. */
  29115. get alphaMode(): number;
  29116. /**
  29117. * Stores the state of the need depth pre-pass value
  29118. */
  29119. private _needDepthPrePass;
  29120. /**
  29121. * Sets the need depth pre-pass value
  29122. */
  29123. set needDepthPrePass(value: boolean);
  29124. /**
  29125. * Gets the depth pre-pass value
  29126. */
  29127. get needDepthPrePass(): boolean;
  29128. /**
  29129. * Specifies if depth writing should be disabled
  29130. */
  29131. disableDepthWrite: boolean;
  29132. /**
  29133. * Specifies if color writing should be disabled
  29134. */
  29135. disableColorWrite: boolean;
  29136. /**
  29137. * Specifies if depth writing should be forced
  29138. */
  29139. forceDepthWrite: boolean;
  29140. /**
  29141. * Specifies the depth function that should be used. 0 means the default engine function
  29142. */
  29143. depthFunction: number;
  29144. /**
  29145. * Specifies if there should be a separate pass for culling
  29146. */
  29147. separateCullingPass: boolean;
  29148. /**
  29149. * Stores the state specifing if fog should be enabled
  29150. */
  29151. private _fogEnabled;
  29152. /**
  29153. * Sets the state for enabling fog
  29154. */
  29155. set fogEnabled(value: boolean);
  29156. /**
  29157. * Gets the value of the fog enabled state
  29158. */
  29159. get fogEnabled(): boolean;
  29160. /**
  29161. * Stores the size of points
  29162. */
  29163. pointSize: number;
  29164. /**
  29165. * Stores the z offset value
  29166. */
  29167. zOffset: number;
  29168. get wireframe(): boolean;
  29169. /**
  29170. * Sets the state of wireframe mode
  29171. */
  29172. set wireframe(value: boolean);
  29173. /**
  29174. * Gets the value specifying if point clouds are enabled
  29175. */
  29176. get pointsCloud(): boolean;
  29177. /**
  29178. * Sets the state of point cloud mode
  29179. */
  29180. set pointsCloud(value: boolean);
  29181. /**
  29182. * Gets the material fill mode
  29183. */
  29184. get fillMode(): number;
  29185. /**
  29186. * Sets the material fill mode
  29187. */
  29188. set fillMode(value: number);
  29189. /**
  29190. * @hidden
  29191. * Stores the effects for the material
  29192. */
  29193. _effect: Nullable<Effect>;
  29194. /**
  29195. * Specifies if uniform buffers should be used
  29196. */
  29197. private _useUBO;
  29198. /**
  29199. * Stores a reference to the scene
  29200. */
  29201. private _scene;
  29202. /**
  29203. * Stores the fill mode state
  29204. */
  29205. private _fillMode;
  29206. /**
  29207. * Specifies if the depth write state should be cached
  29208. */
  29209. private _cachedDepthWriteState;
  29210. /**
  29211. * Specifies if the color write state should be cached
  29212. */
  29213. private _cachedColorWriteState;
  29214. /**
  29215. * Specifies if the depth function state should be cached
  29216. */
  29217. private _cachedDepthFunctionState;
  29218. /**
  29219. * Stores the uniform buffer
  29220. */
  29221. protected _uniformBuffer: UniformBuffer;
  29222. /** @hidden */
  29223. _indexInSceneMaterialArray: number;
  29224. /** @hidden */
  29225. meshMap: Nullable<{
  29226. [id: string]: AbstractMesh | undefined;
  29227. }>;
  29228. /**
  29229. * Creates a material instance
  29230. * @param name defines the name of the material
  29231. * @param scene defines the scene to reference
  29232. * @param doNotAdd specifies if the material should be added to the scene
  29233. */
  29234. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29235. /**
  29236. * Returns a string representation of the current material
  29237. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29238. * @returns a string with material information
  29239. */
  29240. toString(fullDetails?: boolean): string;
  29241. /**
  29242. * Gets the class name of the material
  29243. * @returns a string with the class name of the material
  29244. */
  29245. getClassName(): string;
  29246. /**
  29247. * Specifies if updates for the material been locked
  29248. */
  29249. get isFrozen(): boolean;
  29250. /**
  29251. * Locks updates for the material
  29252. */
  29253. freeze(): void;
  29254. /**
  29255. * Unlocks updates for the material
  29256. */
  29257. unfreeze(): void;
  29258. /**
  29259. * Specifies if the material is ready to be used
  29260. * @param mesh defines the mesh to check
  29261. * @param useInstances specifies if instances should be used
  29262. * @returns a boolean indicating if the material is ready to be used
  29263. */
  29264. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29265. /**
  29266. * Specifies that the submesh is ready to be used
  29267. * @param mesh defines the mesh to check
  29268. * @param subMesh defines which submesh to check
  29269. * @param useInstances specifies that instances should be used
  29270. * @returns a boolean indicating that the submesh is ready or not
  29271. */
  29272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29273. /**
  29274. * Returns the material effect
  29275. * @returns the effect associated with the material
  29276. */
  29277. getEffect(): Nullable<Effect>;
  29278. /**
  29279. * Returns the current scene
  29280. * @returns a Scene
  29281. */
  29282. getScene(): Scene;
  29283. /**
  29284. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29285. */
  29286. protected _forceAlphaTest: boolean;
  29287. /**
  29288. * The transparency mode of the material.
  29289. */
  29290. protected _transparencyMode: Nullable<number>;
  29291. /**
  29292. * Gets the current transparency mode.
  29293. */
  29294. get transparencyMode(): Nullable<number>;
  29295. /**
  29296. * Sets the transparency mode of the material.
  29297. *
  29298. * | Value | Type | Description |
  29299. * | ----- | ----------------------------------- | ----------- |
  29300. * | 0 | OPAQUE | |
  29301. * | 1 | ALPHATEST | |
  29302. * | 2 | ALPHABLEND | |
  29303. * | 3 | ALPHATESTANDBLEND | |
  29304. *
  29305. */
  29306. set transparencyMode(value: Nullable<number>);
  29307. /**
  29308. * Returns true if alpha blending should be disabled.
  29309. */
  29310. protected get _disableAlphaBlending(): boolean;
  29311. /**
  29312. * Specifies whether or not this material should be rendered in alpha blend mode.
  29313. * @returns a boolean specifying if alpha blending is needed
  29314. */
  29315. needAlphaBlending(): boolean;
  29316. /**
  29317. * Specifies if the mesh will require alpha blending
  29318. * @param mesh defines the mesh to check
  29319. * @returns a boolean specifying if alpha blending is needed for the mesh
  29320. */
  29321. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29322. /**
  29323. * Specifies whether or not this material should be rendered in alpha test mode.
  29324. * @returns a boolean specifying if an alpha test is needed.
  29325. */
  29326. needAlphaTesting(): boolean;
  29327. /**
  29328. * Specifies if material alpha testing should be turned on for the mesh
  29329. * @param mesh defines the mesh to check
  29330. */
  29331. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29332. /**
  29333. * Gets the texture used for the alpha test
  29334. * @returns the texture to use for alpha testing
  29335. */
  29336. getAlphaTestTexture(): Nullable<BaseTexture>;
  29337. /**
  29338. * Marks the material to indicate that it needs to be re-calculated
  29339. */
  29340. markDirty(): void;
  29341. /** @hidden */
  29342. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29343. /**
  29344. * Binds the material to the mesh
  29345. * @param world defines the world transformation matrix
  29346. * @param mesh defines the mesh to bind the material to
  29347. */
  29348. bind(world: Matrix, mesh?: Mesh): void;
  29349. /**
  29350. * Binds the submesh to the material
  29351. * @param world defines the world transformation matrix
  29352. * @param mesh defines the mesh containing the submesh
  29353. * @param subMesh defines the submesh to bind the material to
  29354. */
  29355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29356. /**
  29357. * Binds the world matrix to the material
  29358. * @param world defines the world transformation matrix
  29359. */
  29360. bindOnlyWorldMatrix(world: Matrix): void;
  29361. /**
  29362. * Binds the scene's uniform buffer to the effect.
  29363. * @param effect defines the effect to bind to the scene uniform buffer
  29364. * @param sceneUbo defines the uniform buffer storing scene data
  29365. */
  29366. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29367. /**
  29368. * Binds the view matrix to the effect
  29369. * @param effect defines the effect to bind the view matrix to
  29370. */
  29371. bindView(effect: Effect): void;
  29372. /**
  29373. * Binds the view projection matrix to the effect
  29374. * @param effect defines the effect to bind the view projection matrix to
  29375. */
  29376. bindViewProjection(effect: Effect): void;
  29377. /**
  29378. * Processes to execute after binding the material to a mesh
  29379. * @param mesh defines the rendered mesh
  29380. */
  29381. protected _afterBind(mesh?: Mesh): void;
  29382. /**
  29383. * Unbinds the material from the mesh
  29384. */
  29385. unbind(): void;
  29386. /**
  29387. * Gets the active textures from the material
  29388. * @returns an array of textures
  29389. */
  29390. getActiveTextures(): BaseTexture[];
  29391. /**
  29392. * Specifies if the material uses a texture
  29393. * @param texture defines the texture to check against the material
  29394. * @returns a boolean specifying if the material uses the texture
  29395. */
  29396. hasTexture(texture: BaseTexture): boolean;
  29397. /**
  29398. * Makes a duplicate of the material, and gives it a new name
  29399. * @param name defines the new name for the duplicated material
  29400. * @returns the cloned material
  29401. */
  29402. clone(name: string): Nullable<Material>;
  29403. /**
  29404. * Gets the meshes bound to the material
  29405. * @returns an array of meshes bound to the material
  29406. */
  29407. getBindedMeshes(): AbstractMesh[];
  29408. /**
  29409. * Force shader compilation
  29410. * @param mesh defines the mesh associated with this material
  29411. * @param onCompiled defines a function to execute once the material is compiled
  29412. * @param options defines the options to configure the compilation
  29413. * @param onError defines a function to execute if the material fails compiling
  29414. */
  29415. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29416. /**
  29417. * Force shader compilation
  29418. * @param mesh defines the mesh that will use this material
  29419. * @param options defines additional options for compiling the shaders
  29420. * @returns a promise that resolves when the compilation completes
  29421. */
  29422. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29423. private static readonly _AllDirtyCallBack;
  29424. private static readonly _ImageProcessingDirtyCallBack;
  29425. private static readonly _TextureDirtyCallBack;
  29426. private static readonly _FresnelDirtyCallBack;
  29427. private static readonly _MiscDirtyCallBack;
  29428. private static readonly _PrePassDirtyCallBack;
  29429. private static readonly _LightsDirtyCallBack;
  29430. private static readonly _AttributeDirtyCallBack;
  29431. private static _FresnelAndMiscDirtyCallBack;
  29432. private static _TextureAndMiscDirtyCallBack;
  29433. private static readonly _DirtyCallbackArray;
  29434. private static readonly _RunDirtyCallBacks;
  29435. /**
  29436. * Marks a define in the material to indicate that it needs to be re-computed
  29437. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29438. */
  29439. markAsDirty(flag: number): void;
  29440. /**
  29441. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29442. * @param func defines a function which checks material defines against the submeshes
  29443. */
  29444. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29445. /**
  29446. * Indicates that the scene should check if the rendering now needs a prepass
  29447. */
  29448. protected _markScenePrePassDirty(): void;
  29449. /**
  29450. * Indicates that we need to re-calculated for all submeshes
  29451. */
  29452. protected _markAllSubMeshesAsAllDirty(): void;
  29453. /**
  29454. * Indicates that image processing needs to be re-calculated for all submeshes
  29455. */
  29456. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29457. /**
  29458. * Indicates that textures need to be re-calculated for all submeshes
  29459. */
  29460. protected _markAllSubMeshesAsTexturesDirty(): void;
  29461. /**
  29462. * Indicates that fresnel needs to be re-calculated for all submeshes
  29463. */
  29464. protected _markAllSubMeshesAsFresnelDirty(): void;
  29465. /**
  29466. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29467. */
  29468. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29469. /**
  29470. * Indicates that lights need to be re-calculated for all submeshes
  29471. */
  29472. protected _markAllSubMeshesAsLightsDirty(): void;
  29473. /**
  29474. * Indicates that attributes need to be re-calculated for all submeshes
  29475. */
  29476. protected _markAllSubMeshesAsAttributesDirty(): void;
  29477. /**
  29478. * Indicates that misc needs to be re-calculated for all submeshes
  29479. */
  29480. protected _markAllSubMeshesAsMiscDirty(): void;
  29481. /**
  29482. * Indicates that prepass needs to be re-calculated for all submeshes
  29483. */
  29484. protected _markAllSubMeshesAsPrePassDirty(): void;
  29485. /**
  29486. * Indicates that textures and misc need to be re-calculated for all submeshes
  29487. */
  29488. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29489. /**
  29490. * Sets the required values to the prepass renderer.
  29491. * @param prePassRenderer defines the prepass renderer to setup.
  29492. * @returns true if the pre pass is needed.
  29493. */
  29494. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29495. /**
  29496. * Disposes the material
  29497. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29498. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29499. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29500. */
  29501. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29502. /** @hidden */
  29503. private releaseVertexArrayObject;
  29504. /**
  29505. * Serializes this material
  29506. * @returns the serialized material object
  29507. */
  29508. serialize(): any;
  29509. /**
  29510. * Creates a material from parsed material data
  29511. * @param parsedMaterial defines parsed material data
  29512. * @param scene defines the hosting scene
  29513. * @param rootUrl defines the root URL to use to load textures
  29514. * @returns a new material
  29515. */
  29516. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29517. }
  29518. }
  29519. declare module BABYLON {
  29520. /**
  29521. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29522. * separate meshes. This can be use to improve performances.
  29523. * @see https://doc.babylonjs.com/how_to/multi_materials
  29524. */
  29525. export class MultiMaterial extends Material {
  29526. private _subMaterials;
  29527. /**
  29528. * Gets or Sets the list of Materials used within the multi material.
  29529. * They need to be ordered according to the submeshes order in the associated mesh
  29530. */
  29531. get subMaterials(): Nullable<Material>[];
  29532. set subMaterials(value: Nullable<Material>[]);
  29533. /**
  29534. * Function used to align with Node.getChildren()
  29535. * @returns the list of Materials used within the multi material
  29536. */
  29537. getChildren(): Nullable<Material>[];
  29538. /**
  29539. * Instantiates a new Multi Material
  29540. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29541. * separate meshes. This can be use to improve performances.
  29542. * @see https://doc.babylonjs.com/how_to/multi_materials
  29543. * @param name Define the name in the scene
  29544. * @param scene Define the scene the material belongs to
  29545. */
  29546. constructor(name: string, scene: Scene);
  29547. private _hookArray;
  29548. /**
  29549. * Get one of the submaterial by its index in the submaterials array
  29550. * @param index The index to look the sub material at
  29551. * @returns The Material if the index has been defined
  29552. */
  29553. getSubMaterial(index: number): Nullable<Material>;
  29554. /**
  29555. * Get the list of active textures for the whole sub materials list.
  29556. * @returns All the textures that will be used during the rendering
  29557. */
  29558. getActiveTextures(): BaseTexture[];
  29559. /**
  29560. * Gets the current class name of the material e.g. "MultiMaterial"
  29561. * Mainly use in serialization.
  29562. * @returns the class name
  29563. */
  29564. getClassName(): string;
  29565. /**
  29566. * Checks if the material is ready to render the requested sub mesh
  29567. * @param mesh Define the mesh the submesh belongs to
  29568. * @param subMesh Define the sub mesh to look readyness for
  29569. * @param useInstances Define whether or not the material is used with instances
  29570. * @returns true if ready, otherwise false
  29571. */
  29572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29573. /**
  29574. * Clones the current material and its related sub materials
  29575. * @param name Define the name of the newly cloned material
  29576. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29577. * @returns the cloned material
  29578. */
  29579. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29580. /**
  29581. * Serializes the materials into a JSON representation.
  29582. * @returns the JSON representation
  29583. */
  29584. serialize(): any;
  29585. /**
  29586. * Dispose the material and release its associated resources
  29587. * @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)
  29588. * @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)
  29589. * @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)
  29590. */
  29591. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29592. /**
  29593. * Creates a MultiMaterial from parsed MultiMaterial data.
  29594. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29595. * @param scene defines the hosting scene
  29596. * @returns a new MultiMaterial
  29597. */
  29598. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29599. }
  29600. }
  29601. declare module BABYLON {
  29602. /**
  29603. * Defines a subdivision inside a mesh
  29604. */
  29605. export class SubMesh implements ICullable {
  29606. /** the material index to use */
  29607. materialIndex: number;
  29608. /** vertex index start */
  29609. verticesStart: number;
  29610. /** vertices count */
  29611. verticesCount: number;
  29612. /** index start */
  29613. indexStart: number;
  29614. /** indices count */
  29615. indexCount: number;
  29616. /** @hidden */
  29617. _materialDefines: Nullable<MaterialDefines>;
  29618. /** @hidden */
  29619. _materialEffect: Nullable<Effect>;
  29620. /** @hidden */
  29621. _effectOverride: Nullable<Effect>;
  29622. /**
  29623. * Gets material defines used by the effect associated to the sub mesh
  29624. */
  29625. get materialDefines(): Nullable<MaterialDefines>;
  29626. /**
  29627. * Sets material defines used by the effect associated to the sub mesh
  29628. */
  29629. set materialDefines(defines: Nullable<MaterialDefines>);
  29630. /**
  29631. * Gets associated effect
  29632. */
  29633. get effect(): Nullable<Effect>;
  29634. /**
  29635. * Sets associated effect (effect used to render this submesh)
  29636. * @param effect defines the effect to associate with
  29637. * @param defines defines the set of defines used to compile this effect
  29638. */
  29639. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29640. /** @hidden */
  29641. _linesIndexCount: number;
  29642. private _mesh;
  29643. private _renderingMesh;
  29644. private _boundingInfo;
  29645. private _linesIndexBuffer;
  29646. /** @hidden */
  29647. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29648. /** @hidden */
  29649. _trianglePlanes: Plane[];
  29650. /** @hidden */
  29651. _lastColliderTransformMatrix: Nullable<Matrix>;
  29652. /** @hidden */
  29653. _renderId: number;
  29654. /** @hidden */
  29655. _alphaIndex: number;
  29656. /** @hidden */
  29657. _distanceToCamera: number;
  29658. /** @hidden */
  29659. _id: number;
  29660. private _currentMaterial;
  29661. /**
  29662. * Add a new submesh to a mesh
  29663. * @param materialIndex defines the material index to use
  29664. * @param verticesStart defines vertex index start
  29665. * @param verticesCount defines vertices count
  29666. * @param indexStart defines index start
  29667. * @param indexCount defines indices count
  29668. * @param mesh defines the parent mesh
  29669. * @param renderingMesh defines an optional rendering mesh
  29670. * @param createBoundingBox defines if bounding box should be created for this submesh
  29671. * @returns the new submesh
  29672. */
  29673. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29674. /**
  29675. * Creates a new submesh
  29676. * @param materialIndex defines the material index to use
  29677. * @param verticesStart defines vertex index start
  29678. * @param verticesCount defines vertices count
  29679. * @param indexStart defines index start
  29680. * @param indexCount defines indices count
  29681. * @param mesh defines the parent mesh
  29682. * @param renderingMesh defines an optional rendering mesh
  29683. * @param createBoundingBox defines if bounding box should be created for this submesh
  29684. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29685. */
  29686. constructor(
  29687. /** the material index to use */
  29688. materialIndex: number,
  29689. /** vertex index start */
  29690. verticesStart: number,
  29691. /** vertices count */
  29692. verticesCount: number,
  29693. /** index start */
  29694. indexStart: number,
  29695. /** indices count */
  29696. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29697. /**
  29698. * Returns true if this submesh covers the entire parent mesh
  29699. * @ignorenaming
  29700. */
  29701. get IsGlobal(): boolean;
  29702. /**
  29703. * Returns the submesh BoudingInfo object
  29704. * @returns current bounding info (or mesh's one if the submesh is global)
  29705. */
  29706. getBoundingInfo(): BoundingInfo;
  29707. /**
  29708. * Sets the submesh BoundingInfo
  29709. * @param boundingInfo defines the new bounding info to use
  29710. * @returns the SubMesh
  29711. */
  29712. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29713. /**
  29714. * Returns the mesh of the current submesh
  29715. * @return the parent mesh
  29716. */
  29717. getMesh(): AbstractMesh;
  29718. /**
  29719. * Returns the rendering mesh of the submesh
  29720. * @returns the rendering mesh (could be different from parent mesh)
  29721. */
  29722. getRenderingMesh(): Mesh;
  29723. /**
  29724. * Returns the replacement mesh of the submesh
  29725. * @returns the replacement mesh (could be different from parent mesh)
  29726. */
  29727. getReplacementMesh(): Nullable<AbstractMesh>;
  29728. /**
  29729. * Returns the effective mesh of the submesh
  29730. * @returns the effective mesh (could be different from parent mesh)
  29731. */
  29732. getEffectiveMesh(): AbstractMesh;
  29733. /**
  29734. * Returns the submesh material
  29735. * @returns null or the current material
  29736. */
  29737. getMaterial(): Nullable<Material>;
  29738. private _IsMultiMaterial;
  29739. /**
  29740. * Sets a new updated BoundingInfo object to the submesh
  29741. * @param data defines an optional position array to use to determine the bounding info
  29742. * @returns the SubMesh
  29743. */
  29744. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29745. /** @hidden */
  29746. _checkCollision(collider: Collider): boolean;
  29747. /**
  29748. * Updates the submesh BoundingInfo
  29749. * @param world defines the world matrix to use to update the bounding info
  29750. * @returns the submesh
  29751. */
  29752. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29753. /**
  29754. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29755. * @param frustumPlanes defines the frustum planes
  29756. * @returns true if the submesh is intersecting with the frustum
  29757. */
  29758. isInFrustum(frustumPlanes: Plane[]): boolean;
  29759. /**
  29760. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29761. * @param frustumPlanes defines the frustum planes
  29762. * @returns true if the submesh is inside the frustum
  29763. */
  29764. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29765. /**
  29766. * Renders the submesh
  29767. * @param enableAlphaMode defines if alpha needs to be used
  29768. * @returns the submesh
  29769. */
  29770. render(enableAlphaMode: boolean): SubMesh;
  29771. /**
  29772. * @hidden
  29773. */
  29774. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29775. /**
  29776. * Checks if the submesh intersects with a ray
  29777. * @param ray defines the ray to test
  29778. * @returns true is the passed ray intersects the submesh bounding box
  29779. */
  29780. canIntersects(ray: Ray): boolean;
  29781. /**
  29782. * Intersects current submesh with a ray
  29783. * @param ray defines the ray to test
  29784. * @param positions defines mesh's positions array
  29785. * @param indices defines mesh's indices array
  29786. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29787. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29788. * @returns intersection info or null if no intersection
  29789. */
  29790. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29791. /** @hidden */
  29792. private _intersectLines;
  29793. /** @hidden */
  29794. private _intersectUnIndexedLines;
  29795. /** @hidden */
  29796. private _intersectTriangles;
  29797. /** @hidden */
  29798. private _intersectUnIndexedTriangles;
  29799. /** @hidden */
  29800. _rebuild(): void;
  29801. /**
  29802. * Creates a new submesh from the passed mesh
  29803. * @param newMesh defines the new hosting mesh
  29804. * @param newRenderingMesh defines an optional rendering mesh
  29805. * @returns the new submesh
  29806. */
  29807. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29808. /**
  29809. * Release associated resources
  29810. */
  29811. dispose(): void;
  29812. /**
  29813. * Gets the class name
  29814. * @returns the string "SubMesh".
  29815. */
  29816. getClassName(): string;
  29817. /**
  29818. * Creates a new submesh from indices data
  29819. * @param materialIndex the index of the main mesh material
  29820. * @param startIndex the index where to start the copy in the mesh indices array
  29821. * @param indexCount the number of indices to copy then from the startIndex
  29822. * @param mesh the main mesh to create the submesh from
  29823. * @param renderingMesh the optional rendering mesh
  29824. * @returns a new submesh
  29825. */
  29826. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29827. }
  29828. }
  29829. declare module BABYLON {
  29830. /**
  29831. * Class used to represent data loading progression
  29832. */
  29833. export class SceneLoaderFlags {
  29834. private static _ForceFullSceneLoadingForIncremental;
  29835. private static _ShowLoadingScreen;
  29836. private static _CleanBoneMatrixWeights;
  29837. private static _loggingLevel;
  29838. /**
  29839. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29840. */
  29841. static get ForceFullSceneLoadingForIncremental(): boolean;
  29842. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29843. /**
  29844. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29845. */
  29846. static get ShowLoadingScreen(): boolean;
  29847. static set ShowLoadingScreen(value: boolean);
  29848. /**
  29849. * Defines the current logging level (while loading the scene)
  29850. * @ignorenaming
  29851. */
  29852. static get loggingLevel(): number;
  29853. static set loggingLevel(value: number);
  29854. /**
  29855. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29856. */
  29857. static get CleanBoneMatrixWeights(): boolean;
  29858. static set CleanBoneMatrixWeights(value: boolean);
  29859. }
  29860. }
  29861. declare module BABYLON {
  29862. /**
  29863. * Class used to store geometry data (vertex buffers + index buffer)
  29864. */
  29865. export class Geometry implements IGetSetVerticesData {
  29866. /**
  29867. * Gets or sets the ID of the geometry
  29868. */
  29869. id: string;
  29870. /**
  29871. * Gets or sets the unique ID of the geometry
  29872. */
  29873. uniqueId: number;
  29874. /**
  29875. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29876. */
  29877. delayLoadState: number;
  29878. /**
  29879. * Gets the file containing the data to load when running in delay load state
  29880. */
  29881. delayLoadingFile: Nullable<string>;
  29882. /**
  29883. * Callback called when the geometry is updated
  29884. */
  29885. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29886. private _scene;
  29887. private _engine;
  29888. private _meshes;
  29889. private _totalVertices;
  29890. /** @hidden */
  29891. _indices: IndicesArray;
  29892. /** @hidden */
  29893. _vertexBuffers: {
  29894. [key: string]: VertexBuffer;
  29895. };
  29896. private _isDisposed;
  29897. private _extend;
  29898. private _boundingBias;
  29899. /** @hidden */
  29900. _delayInfo: Array<string>;
  29901. private _indexBuffer;
  29902. private _indexBufferIsUpdatable;
  29903. /** @hidden */
  29904. _boundingInfo: Nullable<BoundingInfo>;
  29905. /** @hidden */
  29906. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29907. /** @hidden */
  29908. _softwareSkinningFrameId: number;
  29909. private _vertexArrayObjects;
  29910. private _updatable;
  29911. /** @hidden */
  29912. _positions: Nullable<Vector3[]>;
  29913. /**
  29914. * 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
  29915. */
  29916. get boundingBias(): Vector2;
  29917. /**
  29918. * 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
  29919. */
  29920. set boundingBias(value: Vector2);
  29921. /**
  29922. * Static function used to attach a new empty geometry to a mesh
  29923. * @param mesh defines the mesh to attach the geometry to
  29924. * @returns the new Geometry
  29925. */
  29926. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29927. /** Get the list of meshes using this geometry */
  29928. get meshes(): Mesh[];
  29929. /**
  29930. * 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
  29931. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29932. */
  29933. useBoundingInfoFromGeometry: boolean;
  29934. /**
  29935. * Creates a new geometry
  29936. * @param id defines the unique ID
  29937. * @param scene defines the hosting scene
  29938. * @param vertexData defines the VertexData used to get geometry data
  29939. * @param updatable defines if geometry must be updatable (false by default)
  29940. * @param mesh defines the mesh that will be associated with the geometry
  29941. */
  29942. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29943. /**
  29944. * Gets the current extend of the geometry
  29945. */
  29946. get extend(): {
  29947. minimum: Vector3;
  29948. maximum: Vector3;
  29949. };
  29950. /**
  29951. * Gets the hosting scene
  29952. * @returns the hosting Scene
  29953. */
  29954. getScene(): Scene;
  29955. /**
  29956. * Gets the hosting engine
  29957. * @returns the hosting Engine
  29958. */
  29959. getEngine(): Engine;
  29960. /**
  29961. * Defines if the geometry is ready to use
  29962. * @returns true if the geometry is ready to be used
  29963. */
  29964. isReady(): boolean;
  29965. /**
  29966. * Gets a value indicating that the geometry should not be serialized
  29967. */
  29968. get doNotSerialize(): boolean;
  29969. /** @hidden */
  29970. _rebuild(): void;
  29971. /**
  29972. * Affects all geometry data in one call
  29973. * @param vertexData defines the geometry data
  29974. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29975. */
  29976. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29977. /**
  29978. * Set specific vertex data
  29979. * @param kind defines the data kind (Position, normal, etc...)
  29980. * @param data defines the vertex data to use
  29981. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29982. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29983. */
  29984. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29985. /**
  29986. * Removes a specific vertex data
  29987. * @param kind defines the data kind (Position, normal, etc...)
  29988. */
  29989. removeVerticesData(kind: string): void;
  29990. /**
  29991. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29992. * @param buffer defines the vertex buffer to use
  29993. * @param totalVertices defines the total number of vertices for position kind (could be null)
  29994. */
  29995. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  29996. /**
  29997. * Update a specific vertex buffer
  29998. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  29999. * It will do nothing if the buffer is not updatable
  30000. * @param kind defines the data kind (Position, normal, etc...)
  30001. * @param data defines the data to use
  30002. * @param offset defines the offset in the target buffer where to store the data
  30003. * @param useBytes set to true if the offset is in bytes
  30004. */
  30005. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30006. /**
  30007. * Update a specific vertex buffer
  30008. * This function will create a new buffer if the current one is not updatable
  30009. * @param kind defines the data kind (Position, normal, etc...)
  30010. * @param data defines the data to use
  30011. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30012. */
  30013. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30014. private _updateBoundingInfo;
  30015. /** @hidden */
  30016. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30017. /**
  30018. * Gets total number of vertices
  30019. * @returns the total number of vertices
  30020. */
  30021. getTotalVertices(): number;
  30022. /**
  30023. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30024. * @param kind defines the data kind (Position, normal, etc...)
  30025. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30026. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30027. * @returns a float array containing vertex data
  30028. */
  30029. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30030. /**
  30031. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30032. * @param kind defines the data kind (Position, normal, etc...)
  30033. * @returns true if the vertex buffer with the specified kind is updatable
  30034. */
  30035. isVertexBufferUpdatable(kind: string): boolean;
  30036. /**
  30037. * Gets a specific vertex buffer
  30038. * @param kind defines the data kind (Position, normal, etc...)
  30039. * @returns a VertexBuffer
  30040. */
  30041. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30042. /**
  30043. * Returns all vertex buffers
  30044. * @return an object holding all vertex buffers indexed by kind
  30045. */
  30046. getVertexBuffers(): Nullable<{
  30047. [key: string]: VertexBuffer;
  30048. }>;
  30049. /**
  30050. * Gets a boolean indicating if specific vertex buffer is present
  30051. * @param kind defines the data kind (Position, normal, etc...)
  30052. * @returns true if data is present
  30053. */
  30054. isVerticesDataPresent(kind: string): boolean;
  30055. /**
  30056. * Gets a list of all attached data kinds (Position, normal, etc...)
  30057. * @returns a list of string containing all kinds
  30058. */
  30059. getVerticesDataKinds(): string[];
  30060. /**
  30061. * Update index buffer
  30062. * @param indices defines the indices to store in the index buffer
  30063. * @param offset defines the offset in the target buffer where to store the data
  30064. * @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)
  30065. */
  30066. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30067. /**
  30068. * Creates a new index buffer
  30069. * @param indices defines the indices to store in the index buffer
  30070. * @param totalVertices defines the total number of vertices (could be null)
  30071. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30072. */
  30073. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30074. /**
  30075. * Return the total number of indices
  30076. * @returns the total number of indices
  30077. */
  30078. getTotalIndices(): number;
  30079. /**
  30080. * Gets the index buffer array
  30081. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30082. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30083. * @returns the index buffer array
  30084. */
  30085. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30086. /**
  30087. * Gets the index buffer
  30088. * @return the index buffer
  30089. */
  30090. getIndexBuffer(): Nullable<DataBuffer>;
  30091. /** @hidden */
  30092. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30093. /**
  30094. * Release the associated resources for a specific mesh
  30095. * @param mesh defines the source mesh
  30096. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30097. */
  30098. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30099. /**
  30100. * Apply current geometry to a given mesh
  30101. * @param mesh defines the mesh to apply geometry to
  30102. */
  30103. applyToMesh(mesh: Mesh): void;
  30104. private _updateExtend;
  30105. private _applyToMesh;
  30106. private notifyUpdate;
  30107. /**
  30108. * Load the geometry if it was flagged as delay loaded
  30109. * @param scene defines the hosting scene
  30110. * @param onLoaded defines a callback called when the geometry is loaded
  30111. */
  30112. load(scene: Scene, onLoaded?: () => void): void;
  30113. private _queueLoad;
  30114. /**
  30115. * Invert the geometry to move from a right handed system to a left handed one.
  30116. */
  30117. toLeftHanded(): void;
  30118. /** @hidden */
  30119. _resetPointsArrayCache(): void;
  30120. /** @hidden */
  30121. _generatePointsArray(): boolean;
  30122. /**
  30123. * Gets a value indicating if the geometry is disposed
  30124. * @returns true if the geometry was disposed
  30125. */
  30126. isDisposed(): boolean;
  30127. private _disposeVertexArrayObjects;
  30128. /**
  30129. * Free all associated resources
  30130. */
  30131. dispose(): void;
  30132. /**
  30133. * Clone the current geometry into a new geometry
  30134. * @param id defines the unique ID of the new geometry
  30135. * @returns a new geometry object
  30136. */
  30137. copy(id: string): Geometry;
  30138. /**
  30139. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30140. * @return a JSON representation of the current geometry data (without the vertices data)
  30141. */
  30142. serialize(): any;
  30143. private toNumberArray;
  30144. /**
  30145. * Serialize all vertices data into a JSON oject
  30146. * @returns a JSON representation of the current geometry data
  30147. */
  30148. serializeVerticeData(): any;
  30149. /**
  30150. * Extracts a clone of a mesh geometry
  30151. * @param mesh defines the source mesh
  30152. * @param id defines the unique ID of the new geometry object
  30153. * @returns the new geometry object
  30154. */
  30155. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30156. /**
  30157. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30158. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30159. * Be aware Math.random() could cause collisions, but:
  30160. * "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"
  30161. * @returns a string containing a new GUID
  30162. */
  30163. static RandomId(): string;
  30164. /** @hidden */
  30165. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30166. private static _CleanMatricesWeights;
  30167. /**
  30168. * Create a new geometry from persisted data (Using .babylon file format)
  30169. * @param parsedVertexData defines the persisted data
  30170. * @param scene defines the hosting scene
  30171. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30172. * @returns the new geometry object
  30173. */
  30174. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30175. }
  30176. }
  30177. declare module BABYLON {
  30178. /**
  30179. * Define an interface for all classes that will get and set the data on vertices
  30180. */
  30181. export interface IGetSetVerticesData {
  30182. /**
  30183. * Gets a boolean indicating if specific vertex data is present
  30184. * @param kind defines the vertex data kind to use
  30185. * @returns true is data kind is present
  30186. */
  30187. isVerticesDataPresent(kind: string): boolean;
  30188. /**
  30189. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30190. * @param kind defines the data kind (Position, normal, etc...)
  30191. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30192. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30193. * @returns a float array containing vertex data
  30194. */
  30195. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30196. /**
  30197. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30198. * @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.
  30199. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30200. * @returns the indices array or an empty array if the mesh has no geometry
  30201. */
  30202. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30203. /**
  30204. * Set specific vertex data
  30205. * @param kind defines the data kind (Position, normal, etc...)
  30206. * @param data defines the vertex data to use
  30207. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30208. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30209. */
  30210. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30211. /**
  30212. * Update a specific associated vertex buffer
  30213. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30214. * - VertexBuffer.PositionKind
  30215. * - VertexBuffer.UVKind
  30216. * - VertexBuffer.UV2Kind
  30217. * - VertexBuffer.UV3Kind
  30218. * - VertexBuffer.UV4Kind
  30219. * - VertexBuffer.UV5Kind
  30220. * - VertexBuffer.UV6Kind
  30221. * - VertexBuffer.ColorKind
  30222. * - VertexBuffer.MatricesIndicesKind
  30223. * - VertexBuffer.MatricesIndicesExtraKind
  30224. * - VertexBuffer.MatricesWeightsKind
  30225. * - VertexBuffer.MatricesWeightsExtraKind
  30226. * @param data defines the data source
  30227. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30228. * @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)
  30229. */
  30230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30231. /**
  30232. * Creates a new index buffer
  30233. * @param indices defines the indices to store in the index buffer
  30234. * @param totalVertices defines the total number of vertices (could be null)
  30235. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30236. */
  30237. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30238. }
  30239. /**
  30240. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30241. */
  30242. export class VertexData {
  30243. /**
  30244. * Mesh side orientation : usually the external or front surface
  30245. */
  30246. static readonly FRONTSIDE: number;
  30247. /**
  30248. * Mesh side orientation : usually the internal or back surface
  30249. */
  30250. static readonly BACKSIDE: number;
  30251. /**
  30252. * Mesh side orientation : both internal and external or front and back surfaces
  30253. */
  30254. static readonly DOUBLESIDE: number;
  30255. /**
  30256. * Mesh side orientation : by default, `FRONTSIDE`
  30257. */
  30258. static readonly DEFAULTSIDE: number;
  30259. /**
  30260. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30261. */
  30262. positions: Nullable<FloatArray>;
  30263. /**
  30264. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30265. */
  30266. normals: Nullable<FloatArray>;
  30267. /**
  30268. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30269. */
  30270. tangents: Nullable<FloatArray>;
  30271. /**
  30272. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30273. */
  30274. uvs: Nullable<FloatArray>;
  30275. /**
  30276. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30277. */
  30278. uvs2: Nullable<FloatArray>;
  30279. /**
  30280. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30281. */
  30282. uvs3: Nullable<FloatArray>;
  30283. /**
  30284. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30285. */
  30286. uvs4: Nullable<FloatArray>;
  30287. /**
  30288. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30289. */
  30290. uvs5: Nullable<FloatArray>;
  30291. /**
  30292. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30293. */
  30294. uvs6: Nullable<FloatArray>;
  30295. /**
  30296. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30297. */
  30298. colors: Nullable<FloatArray>;
  30299. /**
  30300. * 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).
  30301. */
  30302. matricesIndices: Nullable<FloatArray>;
  30303. /**
  30304. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30305. */
  30306. matricesWeights: Nullable<FloatArray>;
  30307. /**
  30308. * An array extending the number of possible indices
  30309. */
  30310. matricesIndicesExtra: Nullable<FloatArray>;
  30311. /**
  30312. * An array extending the number of possible weights when the number of indices is extended
  30313. */
  30314. matricesWeightsExtra: Nullable<FloatArray>;
  30315. /**
  30316. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30317. */
  30318. indices: Nullable<IndicesArray>;
  30319. /**
  30320. * Uses the passed data array to set the set the values for the specified kind of data
  30321. * @param data a linear array of floating numbers
  30322. * @param kind the type of data that is being set, eg positions, colors etc
  30323. */
  30324. set(data: FloatArray, kind: string): void;
  30325. /**
  30326. * Associates the vertexData to the passed Mesh.
  30327. * Sets it as updatable or not (default `false`)
  30328. * @param mesh the mesh the vertexData is applied to
  30329. * @param updatable when used and having the value true allows new data to update the vertexData
  30330. * @returns the VertexData
  30331. */
  30332. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30333. /**
  30334. * Associates the vertexData to the passed Geometry.
  30335. * Sets it as updatable or not (default `false`)
  30336. * @param geometry the geometry the vertexData is applied to
  30337. * @param updatable when used and having the value true allows new data to update the vertexData
  30338. * @returns VertexData
  30339. */
  30340. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30341. /**
  30342. * Updates the associated mesh
  30343. * @param mesh the mesh to be updated
  30344. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30345. * @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
  30346. * @returns VertexData
  30347. */
  30348. updateMesh(mesh: Mesh): VertexData;
  30349. /**
  30350. * Updates the associated geometry
  30351. * @param geometry the geometry to be updated
  30352. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30353. * @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
  30354. * @returns VertexData.
  30355. */
  30356. updateGeometry(geometry: Geometry): VertexData;
  30357. private _applyTo;
  30358. private _update;
  30359. /**
  30360. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30361. * @param matrix the transforming matrix
  30362. * @returns the VertexData
  30363. */
  30364. transform(matrix: Matrix): VertexData;
  30365. /**
  30366. * Merges the passed VertexData into the current one
  30367. * @param other the VertexData to be merged into the current one
  30368. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30369. * @returns the modified VertexData
  30370. */
  30371. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30372. private _mergeElement;
  30373. private _validate;
  30374. /**
  30375. * Serializes the VertexData
  30376. * @returns a serialized object
  30377. */
  30378. serialize(): any;
  30379. /**
  30380. * Extracts the vertexData from a mesh
  30381. * @param mesh the mesh from which to extract the VertexData
  30382. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30383. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30384. * @returns the object VertexData associated to the passed mesh
  30385. */
  30386. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30387. /**
  30388. * Extracts the vertexData from the geometry
  30389. * @param geometry the geometry from which to extract the VertexData
  30390. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30391. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30392. * @returns the object VertexData associated to the passed mesh
  30393. */
  30394. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30395. private static _ExtractFrom;
  30396. /**
  30397. * Creates the VertexData for a Ribbon
  30398. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30399. * * pathArray array of paths, each of which an array of successive Vector3
  30400. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30401. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30402. * * 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
  30403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30404. * * 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)
  30405. * * 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)
  30406. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30407. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30408. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30409. * @returns the VertexData of the ribbon
  30410. */
  30411. static CreateRibbon(options: {
  30412. pathArray: Vector3[][];
  30413. closeArray?: boolean;
  30414. closePath?: boolean;
  30415. offset?: number;
  30416. sideOrientation?: number;
  30417. frontUVs?: Vector4;
  30418. backUVs?: Vector4;
  30419. invertUV?: boolean;
  30420. uvs?: Vector2[];
  30421. colors?: Color4[];
  30422. }): VertexData;
  30423. /**
  30424. * Creates the VertexData for a box
  30425. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30426. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30427. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30428. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30429. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30430. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30431. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30433. * * 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)
  30434. * * 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)
  30435. * @returns the VertexData of the box
  30436. */
  30437. static CreateBox(options: {
  30438. size?: number;
  30439. width?: number;
  30440. height?: number;
  30441. depth?: number;
  30442. faceUV?: Vector4[];
  30443. faceColors?: Color4[];
  30444. sideOrientation?: number;
  30445. frontUVs?: Vector4;
  30446. backUVs?: Vector4;
  30447. }): VertexData;
  30448. /**
  30449. * Creates the VertexData for a tiled box
  30450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30451. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30452. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30453. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30455. * @returns the VertexData of the box
  30456. */
  30457. static CreateTiledBox(options: {
  30458. pattern?: number;
  30459. width?: number;
  30460. height?: number;
  30461. depth?: number;
  30462. tileSize?: number;
  30463. tileWidth?: number;
  30464. tileHeight?: number;
  30465. alignHorizontal?: number;
  30466. alignVertical?: number;
  30467. faceUV?: Vector4[];
  30468. faceColors?: Color4[];
  30469. sideOrientation?: number;
  30470. }): VertexData;
  30471. /**
  30472. * Creates the VertexData for a tiled plane
  30473. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30474. * * pattern a limited pattern arrangement depending on the number
  30475. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30476. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30477. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30479. * * 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)
  30480. * * 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)
  30481. * @returns the VertexData of the tiled plane
  30482. */
  30483. static CreateTiledPlane(options: {
  30484. pattern?: number;
  30485. tileSize?: number;
  30486. tileWidth?: number;
  30487. tileHeight?: number;
  30488. size?: number;
  30489. width?: number;
  30490. height?: number;
  30491. alignHorizontal?: number;
  30492. alignVertical?: number;
  30493. sideOrientation?: number;
  30494. frontUVs?: Vector4;
  30495. backUVs?: Vector4;
  30496. }): VertexData;
  30497. /**
  30498. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30499. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30500. * * segments sets the number of horizontal strips optional, default 32
  30501. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30502. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30503. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30504. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30505. * * 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
  30506. * * 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
  30507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30508. * * 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)
  30509. * * 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)
  30510. * @returns the VertexData of the ellipsoid
  30511. */
  30512. static CreateSphere(options: {
  30513. segments?: number;
  30514. diameter?: number;
  30515. diameterX?: number;
  30516. diameterY?: number;
  30517. diameterZ?: number;
  30518. arc?: number;
  30519. slice?: number;
  30520. sideOrientation?: number;
  30521. frontUVs?: Vector4;
  30522. backUVs?: Vector4;
  30523. }): VertexData;
  30524. /**
  30525. * Creates the VertexData for a cylinder, cone or prism
  30526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30527. * * height sets the height (y direction) of the cylinder, optional, default 2
  30528. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30529. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30530. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30531. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30532. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30533. * * 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
  30534. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30535. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30536. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30537. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30539. * * 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)
  30540. * * 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)
  30541. * @returns the VertexData of the cylinder, cone or prism
  30542. */
  30543. static CreateCylinder(options: {
  30544. height?: number;
  30545. diameterTop?: number;
  30546. diameterBottom?: number;
  30547. diameter?: number;
  30548. tessellation?: number;
  30549. subdivisions?: number;
  30550. arc?: number;
  30551. faceColors?: Color4[];
  30552. faceUV?: Vector4[];
  30553. hasRings?: boolean;
  30554. enclose?: boolean;
  30555. sideOrientation?: number;
  30556. frontUVs?: Vector4;
  30557. backUVs?: Vector4;
  30558. }): VertexData;
  30559. /**
  30560. * Creates the VertexData for a torus
  30561. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30562. * * diameter the diameter of the torus, optional default 1
  30563. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30564. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30566. * * 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)
  30567. * * 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)
  30568. * @returns the VertexData of the torus
  30569. */
  30570. static CreateTorus(options: {
  30571. diameter?: number;
  30572. thickness?: number;
  30573. tessellation?: number;
  30574. sideOrientation?: number;
  30575. frontUVs?: Vector4;
  30576. backUVs?: Vector4;
  30577. }): VertexData;
  30578. /**
  30579. * Creates the VertexData of the LineSystem
  30580. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30581. * - lines an array of lines, each line being an array of successive Vector3
  30582. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30583. * @returns the VertexData of the LineSystem
  30584. */
  30585. static CreateLineSystem(options: {
  30586. lines: Vector3[][];
  30587. colors?: Nullable<Color4[][]>;
  30588. }): VertexData;
  30589. /**
  30590. * Create the VertexData for a DashedLines
  30591. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30592. * - points an array successive Vector3
  30593. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30594. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30595. * - dashNb the intended total number of dashes, optional, default 200
  30596. * @returns the VertexData for the DashedLines
  30597. */
  30598. static CreateDashedLines(options: {
  30599. points: Vector3[];
  30600. dashSize?: number;
  30601. gapSize?: number;
  30602. dashNb?: number;
  30603. }): VertexData;
  30604. /**
  30605. * Creates the VertexData for a Ground
  30606. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30607. * - width the width (x direction) of the ground, optional, default 1
  30608. * - height the height (z direction) of the ground, optional, default 1
  30609. * - subdivisions the number of subdivisions per side, optional, default 1
  30610. * @returns the VertexData of the Ground
  30611. */
  30612. static CreateGround(options: {
  30613. width?: number;
  30614. height?: number;
  30615. subdivisions?: number;
  30616. subdivisionsX?: number;
  30617. subdivisionsY?: number;
  30618. }): VertexData;
  30619. /**
  30620. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30621. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30622. * * xmin the ground minimum X coordinate, optional, default -1
  30623. * * zmin the ground minimum Z coordinate, optional, default -1
  30624. * * xmax the ground maximum X coordinate, optional, default 1
  30625. * * zmax the ground maximum Z coordinate, optional, default 1
  30626. * * 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}
  30627. * * 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}
  30628. * @returns the VertexData of the TiledGround
  30629. */
  30630. static CreateTiledGround(options: {
  30631. xmin: number;
  30632. zmin: number;
  30633. xmax: number;
  30634. zmax: number;
  30635. subdivisions?: {
  30636. w: number;
  30637. h: number;
  30638. };
  30639. precision?: {
  30640. w: number;
  30641. h: number;
  30642. };
  30643. }): VertexData;
  30644. /**
  30645. * Creates the VertexData of the Ground designed from a heightmap
  30646. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30647. * * width the width (x direction) of the ground
  30648. * * height the height (z direction) of the ground
  30649. * * subdivisions the number of subdivisions per side
  30650. * * minHeight the minimum altitude on the ground, optional, default 0
  30651. * * maxHeight the maximum altitude on the ground, optional default 1
  30652. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30653. * * buffer the array holding the image color data
  30654. * * bufferWidth the width of image
  30655. * * bufferHeight the height of image
  30656. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30657. * @returns the VertexData of the Ground designed from a heightmap
  30658. */
  30659. static CreateGroundFromHeightMap(options: {
  30660. width: number;
  30661. height: number;
  30662. subdivisions: number;
  30663. minHeight: number;
  30664. maxHeight: number;
  30665. colorFilter: Color3;
  30666. buffer: Uint8Array;
  30667. bufferWidth: number;
  30668. bufferHeight: number;
  30669. alphaFilter: number;
  30670. }): VertexData;
  30671. /**
  30672. * Creates the VertexData for a Plane
  30673. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30674. * * size sets the width and height of the plane to the value of size, optional default 1
  30675. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30676. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30678. * * 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)
  30679. * * 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)
  30680. * @returns the VertexData of the box
  30681. */
  30682. static CreatePlane(options: {
  30683. size?: number;
  30684. width?: number;
  30685. height?: number;
  30686. sideOrientation?: number;
  30687. frontUVs?: Vector4;
  30688. backUVs?: Vector4;
  30689. }): VertexData;
  30690. /**
  30691. * Creates the VertexData of the Disc or regular Polygon
  30692. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30693. * * radius the radius of the disc, optional default 0.5
  30694. * * tessellation the number of polygon sides, optional, default 64
  30695. * * 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
  30696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30697. * * 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)
  30698. * * 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)
  30699. * @returns the VertexData of the box
  30700. */
  30701. static CreateDisc(options: {
  30702. radius?: number;
  30703. tessellation?: number;
  30704. arc?: number;
  30705. sideOrientation?: number;
  30706. frontUVs?: Vector4;
  30707. backUVs?: Vector4;
  30708. }): VertexData;
  30709. /**
  30710. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30711. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30712. * @param polygon a mesh built from polygonTriangulation.build()
  30713. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30714. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30715. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30716. * @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)
  30717. * @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)
  30718. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30719. * @returns the VertexData of the Polygon
  30720. */
  30721. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30722. /**
  30723. * Creates the VertexData of the IcoSphere
  30724. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30725. * * radius the radius of the IcoSphere, optional default 1
  30726. * * radiusX allows stretching in the x direction, optional, default radius
  30727. * * radiusY allows stretching in the y direction, optional, default radius
  30728. * * radiusZ allows stretching in the z direction, optional, default radius
  30729. * * flat when true creates a flat shaded mesh, optional, default true
  30730. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30732. * * 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)
  30733. * * 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)
  30734. * @returns the VertexData of the IcoSphere
  30735. */
  30736. static CreateIcoSphere(options: {
  30737. radius?: number;
  30738. radiusX?: number;
  30739. radiusY?: number;
  30740. radiusZ?: number;
  30741. flat?: boolean;
  30742. subdivisions?: number;
  30743. sideOrientation?: number;
  30744. frontUVs?: Vector4;
  30745. backUVs?: Vector4;
  30746. }): VertexData;
  30747. /**
  30748. * Creates the VertexData for a Polyhedron
  30749. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30750. * * type provided types are:
  30751. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30752. * * 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)
  30753. * * size the size of the IcoSphere, optional default 1
  30754. * * sizeX allows stretching in the x direction, optional, default size
  30755. * * sizeY allows stretching in the y direction, optional, default size
  30756. * * sizeZ allows stretching in the z direction, optional, default size
  30757. * * 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
  30758. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30759. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30760. * * flat when true creates a flat shaded mesh, optional, default true
  30761. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30763. * * 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)
  30764. * * 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)
  30765. * @returns the VertexData of the Polyhedron
  30766. */
  30767. static CreatePolyhedron(options: {
  30768. type?: number;
  30769. size?: number;
  30770. sizeX?: number;
  30771. sizeY?: number;
  30772. sizeZ?: number;
  30773. custom?: any;
  30774. faceUV?: Vector4[];
  30775. faceColors?: Color4[];
  30776. flat?: boolean;
  30777. sideOrientation?: number;
  30778. frontUVs?: Vector4;
  30779. backUVs?: Vector4;
  30780. }): VertexData;
  30781. /**
  30782. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30783. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30784. * @returns the VertexData of the Capsule
  30785. */
  30786. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30787. /**
  30788. * Creates the VertexData for a TorusKnot
  30789. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30790. * * radius the radius of the torus knot, optional, default 2
  30791. * * tube the thickness of the tube, optional, default 0.5
  30792. * * radialSegments the number of sides on each tube segments, optional, default 32
  30793. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30794. * * p the number of windings around the z axis, optional, default 2
  30795. * * q the number of windings around the x axis, optional, default 3
  30796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30797. * * 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)
  30798. * * 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)
  30799. * @returns the VertexData of the Torus Knot
  30800. */
  30801. static CreateTorusKnot(options: {
  30802. radius?: number;
  30803. tube?: number;
  30804. radialSegments?: number;
  30805. tubularSegments?: number;
  30806. p?: number;
  30807. q?: number;
  30808. sideOrientation?: number;
  30809. frontUVs?: Vector4;
  30810. backUVs?: Vector4;
  30811. }): VertexData;
  30812. /**
  30813. * Compute normals for given positions and indices
  30814. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30815. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30816. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30817. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30818. * * facetNormals : optional array of facet normals (vector3)
  30819. * * facetPositions : optional array of facet positions (vector3)
  30820. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30821. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30822. * * bInfo : optional bounding info, required for facetPartitioning computation
  30823. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30824. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30825. * * useRightHandedSystem: optional boolean to for right handed system computation
  30826. * * depthSort : optional boolean to enable the facet depth sort computation
  30827. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30828. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30829. */
  30830. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30831. facetNormals?: any;
  30832. facetPositions?: any;
  30833. facetPartitioning?: any;
  30834. ratio?: number;
  30835. bInfo?: any;
  30836. bbSize?: Vector3;
  30837. subDiv?: any;
  30838. useRightHandedSystem?: boolean;
  30839. depthSort?: boolean;
  30840. distanceTo?: Vector3;
  30841. depthSortedFacets?: any;
  30842. }): void;
  30843. /** @hidden */
  30844. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30845. /**
  30846. * Applies VertexData created from the imported parameters to the geometry
  30847. * @param parsedVertexData the parsed data from an imported file
  30848. * @param geometry the geometry to apply the VertexData to
  30849. */
  30850. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30851. }
  30852. }
  30853. declare module BABYLON {
  30854. /**
  30855. * Defines a target to use with MorphTargetManager
  30856. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30857. */
  30858. export class MorphTarget implements IAnimatable {
  30859. /** defines the name of the target */
  30860. name: string;
  30861. /**
  30862. * Gets or sets the list of animations
  30863. */
  30864. animations: Animation[];
  30865. private _scene;
  30866. private _positions;
  30867. private _normals;
  30868. private _tangents;
  30869. private _uvs;
  30870. private _influence;
  30871. private _uniqueId;
  30872. /**
  30873. * Observable raised when the influence changes
  30874. */
  30875. onInfluenceChanged: Observable<boolean>;
  30876. /** @hidden */
  30877. _onDataLayoutChanged: Observable<void>;
  30878. /**
  30879. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30880. */
  30881. get influence(): number;
  30882. set influence(influence: number);
  30883. /**
  30884. * Gets or sets the id of the morph Target
  30885. */
  30886. id: string;
  30887. private _animationPropertiesOverride;
  30888. /**
  30889. * Gets or sets the animation properties override
  30890. */
  30891. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30892. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30893. /**
  30894. * Creates a new MorphTarget
  30895. * @param name defines the name of the target
  30896. * @param influence defines the influence to use
  30897. * @param scene defines the scene the morphtarget belongs to
  30898. */
  30899. constructor(
  30900. /** defines the name of the target */
  30901. name: string, influence?: number, scene?: Nullable<Scene>);
  30902. /**
  30903. * Gets the unique ID of this manager
  30904. */
  30905. get uniqueId(): number;
  30906. /**
  30907. * Gets a boolean defining if the target contains position data
  30908. */
  30909. get hasPositions(): boolean;
  30910. /**
  30911. * Gets a boolean defining if the target contains normal data
  30912. */
  30913. get hasNormals(): boolean;
  30914. /**
  30915. * Gets a boolean defining if the target contains tangent data
  30916. */
  30917. get hasTangents(): boolean;
  30918. /**
  30919. * Gets a boolean defining if the target contains texture coordinates data
  30920. */
  30921. get hasUVs(): boolean;
  30922. /**
  30923. * Affects position data to this target
  30924. * @param data defines the position data to use
  30925. */
  30926. setPositions(data: Nullable<FloatArray>): void;
  30927. /**
  30928. * Gets the position data stored in this target
  30929. * @returns a FloatArray containing the position data (or null if not present)
  30930. */
  30931. getPositions(): Nullable<FloatArray>;
  30932. /**
  30933. * Affects normal data to this target
  30934. * @param data defines the normal data to use
  30935. */
  30936. setNormals(data: Nullable<FloatArray>): void;
  30937. /**
  30938. * Gets the normal data stored in this target
  30939. * @returns a FloatArray containing the normal data (or null if not present)
  30940. */
  30941. getNormals(): Nullable<FloatArray>;
  30942. /**
  30943. * Affects tangent data to this target
  30944. * @param data defines the tangent data to use
  30945. */
  30946. setTangents(data: Nullable<FloatArray>): void;
  30947. /**
  30948. * Gets the tangent data stored in this target
  30949. * @returns a FloatArray containing the tangent data (or null if not present)
  30950. */
  30951. getTangents(): Nullable<FloatArray>;
  30952. /**
  30953. * Affects texture coordinates data to this target
  30954. * @param data defines the texture coordinates data to use
  30955. */
  30956. setUVs(data: Nullable<FloatArray>): void;
  30957. /**
  30958. * Gets the texture coordinates data stored in this target
  30959. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30960. */
  30961. getUVs(): Nullable<FloatArray>;
  30962. /**
  30963. * Clone the current target
  30964. * @returns a new MorphTarget
  30965. */
  30966. clone(): MorphTarget;
  30967. /**
  30968. * Serializes the current target into a Serialization object
  30969. * @returns the serialized object
  30970. */
  30971. serialize(): any;
  30972. /**
  30973. * Returns the string "MorphTarget"
  30974. * @returns "MorphTarget"
  30975. */
  30976. getClassName(): string;
  30977. /**
  30978. * Creates a new target from serialized data
  30979. * @param serializationObject defines the serialized data to use
  30980. * @returns a new MorphTarget
  30981. */
  30982. static Parse(serializationObject: any): MorphTarget;
  30983. /**
  30984. * Creates a MorphTarget from mesh data
  30985. * @param mesh defines the source mesh
  30986. * @param name defines the name to use for the new target
  30987. * @param influence defines the influence to attach to the target
  30988. * @returns a new MorphTarget
  30989. */
  30990. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30991. }
  30992. }
  30993. declare module BABYLON {
  30994. /**
  30995. * This class is used to deform meshes using morphing between different targets
  30996. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30997. */
  30998. export class MorphTargetManager {
  30999. private _targets;
  31000. private _targetInfluenceChangedObservers;
  31001. private _targetDataLayoutChangedObservers;
  31002. private _activeTargets;
  31003. private _scene;
  31004. private _influences;
  31005. private _supportsNormals;
  31006. private _supportsTangents;
  31007. private _supportsUVs;
  31008. private _vertexCount;
  31009. private _uniqueId;
  31010. private _tempInfluences;
  31011. /**
  31012. * Gets or sets a boolean indicating if normals must be morphed
  31013. */
  31014. enableNormalMorphing: boolean;
  31015. /**
  31016. * Gets or sets a boolean indicating if tangents must be morphed
  31017. */
  31018. enableTangentMorphing: boolean;
  31019. /**
  31020. * Gets or sets a boolean indicating if UV must be morphed
  31021. */
  31022. enableUVMorphing: boolean;
  31023. /**
  31024. * Creates a new MorphTargetManager
  31025. * @param scene defines the current scene
  31026. */
  31027. constructor(scene?: Nullable<Scene>);
  31028. /**
  31029. * Gets the unique ID of this manager
  31030. */
  31031. get uniqueId(): number;
  31032. /**
  31033. * Gets the number of vertices handled by this manager
  31034. */
  31035. get vertexCount(): number;
  31036. /**
  31037. * Gets a boolean indicating if this manager supports morphing of normals
  31038. */
  31039. get supportsNormals(): boolean;
  31040. /**
  31041. * Gets a boolean indicating if this manager supports morphing of tangents
  31042. */
  31043. get supportsTangents(): boolean;
  31044. /**
  31045. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31046. */
  31047. get supportsUVs(): boolean;
  31048. /**
  31049. * Gets the number of targets stored in this manager
  31050. */
  31051. get numTargets(): number;
  31052. /**
  31053. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31054. */
  31055. get numInfluencers(): number;
  31056. /**
  31057. * Gets the list of influences (one per target)
  31058. */
  31059. get influences(): Float32Array;
  31060. /**
  31061. * Gets the active target at specified index. An active target is a target with an influence > 0
  31062. * @param index defines the index to check
  31063. * @returns the requested target
  31064. */
  31065. getActiveTarget(index: number): MorphTarget;
  31066. /**
  31067. * Gets the target at specified index
  31068. * @param index defines the index to check
  31069. * @returns the requested target
  31070. */
  31071. getTarget(index: number): MorphTarget;
  31072. /**
  31073. * Add a new target to this manager
  31074. * @param target defines the target to add
  31075. */
  31076. addTarget(target: MorphTarget): void;
  31077. /**
  31078. * Removes a target from the manager
  31079. * @param target defines the target to remove
  31080. */
  31081. removeTarget(target: MorphTarget): void;
  31082. /**
  31083. * Clone the current manager
  31084. * @returns a new MorphTargetManager
  31085. */
  31086. clone(): MorphTargetManager;
  31087. /**
  31088. * Serializes the current manager into a Serialization object
  31089. * @returns the serialized object
  31090. */
  31091. serialize(): any;
  31092. private _syncActiveTargets;
  31093. /**
  31094. * Syncrhonize the targets with all the meshes using this morph target manager
  31095. */
  31096. synchronize(): void;
  31097. /**
  31098. * Creates a new MorphTargetManager from serialized data
  31099. * @param serializationObject defines the serialized data
  31100. * @param scene defines the hosting scene
  31101. * @returns the new MorphTargetManager
  31102. */
  31103. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31104. }
  31105. }
  31106. declare module BABYLON {
  31107. /**
  31108. * Class used to represent a specific level of detail of a mesh
  31109. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31110. */
  31111. export class MeshLODLevel {
  31112. /** Defines the distance where this level should start being displayed */
  31113. distance: number;
  31114. /** Defines the mesh to use to render this level */
  31115. mesh: Nullable<Mesh>;
  31116. /**
  31117. * Creates a new LOD level
  31118. * @param distance defines the distance where this level should star being displayed
  31119. * @param mesh defines the mesh to use to render this level
  31120. */
  31121. constructor(
  31122. /** Defines the distance where this level should start being displayed */
  31123. distance: number,
  31124. /** Defines the mesh to use to render this level */
  31125. mesh: Nullable<Mesh>);
  31126. }
  31127. }
  31128. declare module BABYLON {
  31129. /**
  31130. * Helper class used to generate a canvas to manipulate images
  31131. */
  31132. export class CanvasGenerator {
  31133. /**
  31134. * Create a new canvas (or offscreen canvas depending on the context)
  31135. * @param width defines the expected width
  31136. * @param height defines the expected height
  31137. * @return a new canvas or offscreen canvas
  31138. */
  31139. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31140. }
  31141. }
  31142. declare module BABYLON {
  31143. /**
  31144. * Mesh representing the gorund
  31145. */
  31146. export class GroundMesh extends Mesh {
  31147. /** If octree should be generated */
  31148. generateOctree: boolean;
  31149. private _heightQuads;
  31150. /** @hidden */
  31151. _subdivisionsX: number;
  31152. /** @hidden */
  31153. _subdivisionsY: number;
  31154. /** @hidden */
  31155. _width: number;
  31156. /** @hidden */
  31157. _height: number;
  31158. /** @hidden */
  31159. _minX: number;
  31160. /** @hidden */
  31161. _maxX: number;
  31162. /** @hidden */
  31163. _minZ: number;
  31164. /** @hidden */
  31165. _maxZ: number;
  31166. constructor(name: string, scene: Scene);
  31167. /**
  31168. * "GroundMesh"
  31169. * @returns "GroundMesh"
  31170. */
  31171. getClassName(): string;
  31172. /**
  31173. * The minimum of x and y subdivisions
  31174. */
  31175. get subdivisions(): number;
  31176. /**
  31177. * X subdivisions
  31178. */
  31179. get subdivisionsX(): number;
  31180. /**
  31181. * Y subdivisions
  31182. */
  31183. get subdivisionsY(): number;
  31184. /**
  31185. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31186. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31187. * @param chunksCount the number of subdivisions for x and y
  31188. * @param octreeBlocksSize (Default: 32)
  31189. */
  31190. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31191. /**
  31192. * Returns a height (y) value in the Worl system :
  31193. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31194. * @param x x coordinate
  31195. * @param z z coordinate
  31196. * @returns the ground y position if (x, z) are outside the ground surface.
  31197. */
  31198. getHeightAtCoordinates(x: number, z: number): number;
  31199. /**
  31200. * Returns a normalized vector (Vector3) orthogonal to the ground
  31201. * at the ground coordinates (x, z) expressed in the World system.
  31202. * @param x x coordinate
  31203. * @param z z coordinate
  31204. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31205. */
  31206. getNormalAtCoordinates(x: number, z: number): Vector3;
  31207. /**
  31208. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31209. * at the ground coordinates (x, z) expressed in the World system.
  31210. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31211. * @param x x coordinate
  31212. * @param z z coordinate
  31213. * @param ref vector to store the result
  31214. * @returns the GroundMesh.
  31215. */
  31216. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31217. /**
  31218. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31219. * if the ground has been updated.
  31220. * This can be used in the render loop.
  31221. * @returns the GroundMesh.
  31222. */
  31223. updateCoordinateHeights(): GroundMesh;
  31224. private _getFacetAt;
  31225. private _initHeightQuads;
  31226. private _computeHeightQuads;
  31227. /**
  31228. * Serializes this ground mesh
  31229. * @param serializationObject object to write serialization to
  31230. */
  31231. serialize(serializationObject: any): void;
  31232. /**
  31233. * Parses a serialized ground mesh
  31234. * @param parsedMesh the serialized mesh
  31235. * @param scene the scene to create the ground mesh in
  31236. * @returns the created ground mesh
  31237. */
  31238. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31239. }
  31240. }
  31241. declare module BABYLON {
  31242. /**
  31243. * Interface for Physics-Joint data
  31244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31245. */
  31246. export interface PhysicsJointData {
  31247. /**
  31248. * The main pivot of the joint
  31249. */
  31250. mainPivot?: Vector3;
  31251. /**
  31252. * The connected pivot of the joint
  31253. */
  31254. connectedPivot?: Vector3;
  31255. /**
  31256. * The main axis of the joint
  31257. */
  31258. mainAxis?: Vector3;
  31259. /**
  31260. * The connected axis of the joint
  31261. */
  31262. connectedAxis?: Vector3;
  31263. /**
  31264. * The collision of the joint
  31265. */
  31266. collision?: boolean;
  31267. /**
  31268. * Native Oimo/Cannon/Energy data
  31269. */
  31270. nativeParams?: any;
  31271. }
  31272. /**
  31273. * This is a holder class for the physics joint created by the physics plugin
  31274. * It holds a set of functions to control the underlying joint
  31275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31276. */
  31277. export class PhysicsJoint {
  31278. /**
  31279. * The type of the physics joint
  31280. */
  31281. type: number;
  31282. /**
  31283. * The data for the physics joint
  31284. */
  31285. jointData: PhysicsJointData;
  31286. private _physicsJoint;
  31287. protected _physicsPlugin: IPhysicsEnginePlugin;
  31288. /**
  31289. * Initializes the physics joint
  31290. * @param type The type of the physics joint
  31291. * @param jointData The data for the physics joint
  31292. */
  31293. constructor(
  31294. /**
  31295. * The type of the physics joint
  31296. */
  31297. type: number,
  31298. /**
  31299. * The data for the physics joint
  31300. */
  31301. jointData: PhysicsJointData);
  31302. /**
  31303. * Gets the physics joint
  31304. */
  31305. get physicsJoint(): any;
  31306. /**
  31307. * Sets the physics joint
  31308. */
  31309. set physicsJoint(newJoint: any);
  31310. /**
  31311. * Sets the physics plugin
  31312. */
  31313. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31314. /**
  31315. * Execute a function that is physics-plugin specific.
  31316. * @param {Function} func the function that will be executed.
  31317. * It accepts two parameters: the physics world and the physics joint
  31318. */
  31319. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31320. /**
  31321. * Distance-Joint type
  31322. */
  31323. static DistanceJoint: number;
  31324. /**
  31325. * Hinge-Joint type
  31326. */
  31327. static HingeJoint: number;
  31328. /**
  31329. * Ball-and-Socket joint type
  31330. */
  31331. static BallAndSocketJoint: number;
  31332. /**
  31333. * Wheel-Joint type
  31334. */
  31335. static WheelJoint: number;
  31336. /**
  31337. * Slider-Joint type
  31338. */
  31339. static SliderJoint: number;
  31340. /**
  31341. * Prismatic-Joint type
  31342. */
  31343. static PrismaticJoint: number;
  31344. /**
  31345. * Universal-Joint type
  31346. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31347. */
  31348. static UniversalJoint: number;
  31349. /**
  31350. * Hinge-Joint 2 type
  31351. */
  31352. static Hinge2Joint: number;
  31353. /**
  31354. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31355. */
  31356. static PointToPointJoint: number;
  31357. /**
  31358. * Spring-Joint type
  31359. */
  31360. static SpringJoint: number;
  31361. /**
  31362. * Lock-Joint type
  31363. */
  31364. static LockJoint: number;
  31365. }
  31366. /**
  31367. * A class representing a physics distance joint
  31368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31369. */
  31370. export class DistanceJoint extends PhysicsJoint {
  31371. /**
  31372. *
  31373. * @param jointData The data for the Distance-Joint
  31374. */
  31375. constructor(jointData: DistanceJointData);
  31376. /**
  31377. * Update the predefined distance.
  31378. * @param maxDistance The maximum preferred distance
  31379. * @param minDistance The minimum preferred distance
  31380. */
  31381. updateDistance(maxDistance: number, minDistance?: number): void;
  31382. }
  31383. /**
  31384. * Represents a Motor-Enabled Joint
  31385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31386. */
  31387. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31388. /**
  31389. * Initializes the Motor-Enabled Joint
  31390. * @param type The type of the joint
  31391. * @param jointData The physica joint data for the joint
  31392. */
  31393. constructor(type: number, jointData: PhysicsJointData);
  31394. /**
  31395. * Set the motor values.
  31396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31397. * @param force the force to apply
  31398. * @param maxForce max force for this motor.
  31399. */
  31400. setMotor(force?: number, maxForce?: number): void;
  31401. /**
  31402. * Set the motor's limits.
  31403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31404. * @param upperLimit The upper limit of the motor
  31405. * @param lowerLimit The lower limit of the motor
  31406. */
  31407. setLimit(upperLimit: number, lowerLimit?: number): void;
  31408. }
  31409. /**
  31410. * This class represents a single physics Hinge-Joint
  31411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31412. */
  31413. export class HingeJoint extends MotorEnabledJoint {
  31414. /**
  31415. * Initializes the Hinge-Joint
  31416. * @param jointData The joint data for the Hinge-Joint
  31417. */
  31418. constructor(jointData: PhysicsJointData);
  31419. /**
  31420. * Set the motor values.
  31421. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31422. * @param {number} force the force to apply
  31423. * @param {number} maxForce max force for this motor.
  31424. */
  31425. setMotor(force?: number, maxForce?: number): void;
  31426. /**
  31427. * Set the motor's limits.
  31428. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31429. * @param upperLimit The upper limit of the motor
  31430. * @param lowerLimit The lower limit of the motor
  31431. */
  31432. setLimit(upperLimit: number, lowerLimit?: number): void;
  31433. }
  31434. /**
  31435. * This class represents a dual hinge physics joint (same as wheel joint)
  31436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31437. */
  31438. export class Hinge2Joint extends MotorEnabledJoint {
  31439. /**
  31440. * Initializes the Hinge2-Joint
  31441. * @param jointData The joint data for the Hinge2-Joint
  31442. */
  31443. constructor(jointData: PhysicsJointData);
  31444. /**
  31445. * Set the motor values.
  31446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31447. * @param {number} targetSpeed the speed the motor is to reach
  31448. * @param {number} maxForce max force for this motor.
  31449. * @param {motorIndex} the motor's index, 0 or 1.
  31450. */
  31451. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31452. /**
  31453. * Set the motor limits.
  31454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31455. * @param {number} upperLimit the upper limit
  31456. * @param {number} lowerLimit lower limit
  31457. * @param {motorIndex} the motor's index, 0 or 1.
  31458. */
  31459. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31460. }
  31461. /**
  31462. * Interface for a motor enabled joint
  31463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31464. */
  31465. export interface IMotorEnabledJoint {
  31466. /**
  31467. * Physics joint
  31468. */
  31469. physicsJoint: any;
  31470. /**
  31471. * Sets the motor of the motor-enabled joint
  31472. * @param force The force of the motor
  31473. * @param maxForce The maximum force of the motor
  31474. * @param motorIndex The index of the motor
  31475. */
  31476. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31477. /**
  31478. * Sets the limit of the motor
  31479. * @param upperLimit The upper limit of the motor
  31480. * @param lowerLimit The lower limit of the motor
  31481. * @param motorIndex The index of the motor
  31482. */
  31483. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31484. }
  31485. /**
  31486. * Joint data for a Distance-Joint
  31487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31488. */
  31489. export interface DistanceJointData extends PhysicsJointData {
  31490. /**
  31491. * Max distance the 2 joint objects can be apart
  31492. */
  31493. maxDistance: number;
  31494. }
  31495. /**
  31496. * Joint data from a spring joint
  31497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31498. */
  31499. export interface SpringJointData extends PhysicsJointData {
  31500. /**
  31501. * Length of the spring
  31502. */
  31503. length: number;
  31504. /**
  31505. * Stiffness of the spring
  31506. */
  31507. stiffness: number;
  31508. /**
  31509. * Damping of the spring
  31510. */
  31511. damping: number;
  31512. /** this callback will be called when applying the force to the impostors. */
  31513. forceApplicationCallback: () => void;
  31514. }
  31515. }
  31516. declare module BABYLON {
  31517. /**
  31518. * Holds the data for the raycast result
  31519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31520. */
  31521. export class PhysicsRaycastResult {
  31522. private _hasHit;
  31523. private _hitDistance;
  31524. private _hitNormalWorld;
  31525. private _hitPointWorld;
  31526. private _rayFromWorld;
  31527. private _rayToWorld;
  31528. /**
  31529. * Gets if there was a hit
  31530. */
  31531. get hasHit(): boolean;
  31532. /**
  31533. * Gets the distance from the hit
  31534. */
  31535. get hitDistance(): number;
  31536. /**
  31537. * Gets the hit normal/direction in the world
  31538. */
  31539. get hitNormalWorld(): Vector3;
  31540. /**
  31541. * Gets the hit point in the world
  31542. */
  31543. get hitPointWorld(): Vector3;
  31544. /**
  31545. * Gets the ray "start point" of the ray in the world
  31546. */
  31547. get rayFromWorld(): Vector3;
  31548. /**
  31549. * Gets the ray "end point" of the ray in the world
  31550. */
  31551. get rayToWorld(): Vector3;
  31552. /**
  31553. * Sets the hit data (normal & point in world space)
  31554. * @param hitNormalWorld defines the normal in world space
  31555. * @param hitPointWorld defines the point in world space
  31556. */
  31557. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31558. /**
  31559. * Sets the distance from the start point to the hit point
  31560. * @param distance
  31561. */
  31562. setHitDistance(distance: number): void;
  31563. /**
  31564. * Calculates the distance manually
  31565. */
  31566. calculateHitDistance(): void;
  31567. /**
  31568. * Resets all the values to default
  31569. * @param from The from point on world space
  31570. * @param to The to point on world space
  31571. */
  31572. reset(from?: Vector3, to?: Vector3): void;
  31573. }
  31574. /**
  31575. * Interface for the size containing width and height
  31576. */
  31577. interface IXYZ {
  31578. /**
  31579. * X
  31580. */
  31581. x: number;
  31582. /**
  31583. * Y
  31584. */
  31585. y: number;
  31586. /**
  31587. * Z
  31588. */
  31589. z: number;
  31590. }
  31591. }
  31592. declare module BABYLON {
  31593. /**
  31594. * Interface used to describe a physics joint
  31595. */
  31596. export interface PhysicsImpostorJoint {
  31597. /** Defines the main impostor to which the joint is linked */
  31598. mainImpostor: PhysicsImpostor;
  31599. /** Defines the impostor that is connected to the main impostor using this joint */
  31600. connectedImpostor: PhysicsImpostor;
  31601. /** Defines the joint itself */
  31602. joint: PhysicsJoint;
  31603. }
  31604. /** @hidden */
  31605. export interface IPhysicsEnginePlugin {
  31606. world: any;
  31607. name: string;
  31608. setGravity(gravity: Vector3): void;
  31609. setTimeStep(timeStep: number): void;
  31610. getTimeStep(): number;
  31611. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31612. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31613. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31614. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31615. removePhysicsBody(impostor: PhysicsImpostor): void;
  31616. generateJoint(joint: PhysicsImpostorJoint): void;
  31617. removeJoint(joint: PhysicsImpostorJoint): void;
  31618. isSupported(): boolean;
  31619. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31620. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31621. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31622. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31623. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31624. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31625. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31626. getBodyMass(impostor: PhysicsImpostor): number;
  31627. getBodyFriction(impostor: PhysicsImpostor): number;
  31628. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31629. getBodyRestitution(impostor: PhysicsImpostor): number;
  31630. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31631. getBodyPressure?(impostor: PhysicsImpostor): number;
  31632. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31633. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31634. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31635. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31636. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31637. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31638. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31639. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31640. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31641. sleepBody(impostor: PhysicsImpostor): void;
  31642. wakeUpBody(impostor: PhysicsImpostor): void;
  31643. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31644. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31645. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31647. getRadius(impostor: PhysicsImpostor): number;
  31648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31650. dispose(): void;
  31651. }
  31652. /**
  31653. * Interface used to define a physics engine
  31654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31655. */
  31656. export interface IPhysicsEngine {
  31657. /**
  31658. * Gets the gravity vector used by the simulation
  31659. */
  31660. gravity: Vector3;
  31661. /**
  31662. * Sets the gravity vector used by the simulation
  31663. * @param gravity defines the gravity vector to use
  31664. */
  31665. setGravity(gravity: Vector3): void;
  31666. /**
  31667. * Set the time step of the physics engine.
  31668. * Default is 1/60.
  31669. * To slow it down, enter 1/600 for example.
  31670. * To speed it up, 1/30
  31671. * @param newTimeStep the new timestep to apply to this world.
  31672. */
  31673. setTimeStep(newTimeStep: number): void;
  31674. /**
  31675. * Get the time step of the physics engine.
  31676. * @returns the current time step
  31677. */
  31678. getTimeStep(): number;
  31679. /**
  31680. * Set the sub time step of the physics engine.
  31681. * Default is 0 meaning there is no sub steps
  31682. * To increase physics resolution precision, set a small value (like 1 ms)
  31683. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31684. */
  31685. setSubTimeStep(subTimeStep: number): void;
  31686. /**
  31687. * Get the sub time step of the physics engine.
  31688. * @returns the current sub time step
  31689. */
  31690. getSubTimeStep(): number;
  31691. /**
  31692. * Release all resources
  31693. */
  31694. dispose(): void;
  31695. /**
  31696. * Gets the name of the current physics plugin
  31697. * @returns the name of the plugin
  31698. */
  31699. getPhysicsPluginName(): string;
  31700. /**
  31701. * Adding a new impostor for the impostor tracking.
  31702. * This will be done by the impostor itself.
  31703. * @param impostor the impostor to add
  31704. */
  31705. addImpostor(impostor: PhysicsImpostor): void;
  31706. /**
  31707. * Remove an impostor from the engine.
  31708. * This impostor and its mesh will not longer be updated by the physics engine.
  31709. * @param impostor the impostor to remove
  31710. */
  31711. removeImpostor(impostor: PhysicsImpostor): void;
  31712. /**
  31713. * Add a joint to the physics engine
  31714. * @param mainImpostor defines the main impostor to which the joint is added.
  31715. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31716. * @param joint defines the joint that will connect both impostors.
  31717. */
  31718. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31719. /**
  31720. * Removes a joint from the simulation
  31721. * @param mainImpostor defines the impostor used with the joint
  31722. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31723. * @param joint defines the joint to remove
  31724. */
  31725. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31726. /**
  31727. * Gets the current plugin used to run the simulation
  31728. * @returns current plugin
  31729. */
  31730. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31731. /**
  31732. * Gets the list of physic impostors
  31733. * @returns an array of PhysicsImpostor
  31734. */
  31735. getImpostors(): Array<PhysicsImpostor>;
  31736. /**
  31737. * Gets the impostor for a physics enabled object
  31738. * @param object defines the object impersonated by the impostor
  31739. * @returns the PhysicsImpostor or null if not found
  31740. */
  31741. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31742. /**
  31743. * Gets the impostor for a physics body object
  31744. * @param body defines physics body used by the impostor
  31745. * @returns the PhysicsImpostor or null if not found
  31746. */
  31747. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31748. /**
  31749. * Does a raycast in the physics world
  31750. * @param from when should the ray start?
  31751. * @param to when should the ray end?
  31752. * @returns PhysicsRaycastResult
  31753. */
  31754. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31755. /**
  31756. * Called by the scene. No need to call it.
  31757. * @param delta defines the timespam between frames
  31758. */
  31759. _step(delta: number): void;
  31760. }
  31761. }
  31762. declare module BABYLON {
  31763. /**
  31764. * The interface for the physics imposter parameters
  31765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31766. */
  31767. export interface PhysicsImpostorParameters {
  31768. /**
  31769. * The mass of the physics imposter
  31770. */
  31771. mass: number;
  31772. /**
  31773. * The friction of the physics imposter
  31774. */
  31775. friction?: number;
  31776. /**
  31777. * The coefficient of restitution of the physics imposter
  31778. */
  31779. restitution?: number;
  31780. /**
  31781. * The native options of the physics imposter
  31782. */
  31783. nativeOptions?: any;
  31784. /**
  31785. * Specifies if the parent should be ignored
  31786. */
  31787. ignoreParent?: boolean;
  31788. /**
  31789. * Specifies if bi-directional transformations should be disabled
  31790. */
  31791. disableBidirectionalTransformation?: boolean;
  31792. /**
  31793. * The pressure inside the physics imposter, soft object only
  31794. */
  31795. pressure?: number;
  31796. /**
  31797. * The stiffness the physics imposter, soft object only
  31798. */
  31799. stiffness?: number;
  31800. /**
  31801. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31802. */
  31803. velocityIterations?: number;
  31804. /**
  31805. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31806. */
  31807. positionIterations?: number;
  31808. /**
  31809. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31810. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31811. * Add to fix multiple points
  31812. */
  31813. fixedPoints?: number;
  31814. /**
  31815. * The collision margin around a soft object
  31816. */
  31817. margin?: number;
  31818. /**
  31819. * The collision margin around a soft object
  31820. */
  31821. damping?: number;
  31822. /**
  31823. * The path for a rope based on an extrusion
  31824. */
  31825. path?: any;
  31826. /**
  31827. * The shape of an extrusion used for a rope based on an extrusion
  31828. */
  31829. shape?: any;
  31830. }
  31831. /**
  31832. * Interface for a physics-enabled object
  31833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31834. */
  31835. export interface IPhysicsEnabledObject {
  31836. /**
  31837. * The position of the physics-enabled object
  31838. */
  31839. position: Vector3;
  31840. /**
  31841. * The rotation of the physics-enabled object
  31842. */
  31843. rotationQuaternion: Nullable<Quaternion>;
  31844. /**
  31845. * The scale of the physics-enabled object
  31846. */
  31847. scaling: Vector3;
  31848. /**
  31849. * The rotation of the physics-enabled object
  31850. */
  31851. rotation?: Vector3;
  31852. /**
  31853. * The parent of the physics-enabled object
  31854. */
  31855. parent?: any;
  31856. /**
  31857. * The bounding info of the physics-enabled object
  31858. * @returns The bounding info of the physics-enabled object
  31859. */
  31860. getBoundingInfo(): BoundingInfo;
  31861. /**
  31862. * Computes the world matrix
  31863. * @param force Specifies if the world matrix should be computed by force
  31864. * @returns A world matrix
  31865. */
  31866. computeWorldMatrix(force: boolean): Matrix;
  31867. /**
  31868. * Gets the world matrix
  31869. * @returns A world matrix
  31870. */
  31871. getWorldMatrix?(): Matrix;
  31872. /**
  31873. * Gets the child meshes
  31874. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31875. * @returns An array of abstract meshes
  31876. */
  31877. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31878. /**
  31879. * Gets the vertex data
  31880. * @param kind The type of vertex data
  31881. * @returns A nullable array of numbers, or a float32 array
  31882. */
  31883. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31884. /**
  31885. * Gets the indices from the mesh
  31886. * @returns A nullable array of index arrays
  31887. */
  31888. getIndices?(): Nullable<IndicesArray>;
  31889. /**
  31890. * Gets the scene from the mesh
  31891. * @returns the indices array or null
  31892. */
  31893. getScene?(): Scene;
  31894. /**
  31895. * Gets the absolute position from the mesh
  31896. * @returns the absolute position
  31897. */
  31898. getAbsolutePosition(): Vector3;
  31899. /**
  31900. * Gets the absolute pivot point from the mesh
  31901. * @returns the absolute pivot point
  31902. */
  31903. getAbsolutePivotPoint(): Vector3;
  31904. /**
  31905. * Rotates the mesh
  31906. * @param axis The axis of rotation
  31907. * @param amount The amount of rotation
  31908. * @param space The space of the rotation
  31909. * @returns The rotation transform node
  31910. */
  31911. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31912. /**
  31913. * Translates the mesh
  31914. * @param axis The axis of translation
  31915. * @param distance The distance of translation
  31916. * @param space The space of the translation
  31917. * @returns The transform node
  31918. */
  31919. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31920. /**
  31921. * Sets the absolute position of the mesh
  31922. * @param absolutePosition The absolute position of the mesh
  31923. * @returns The transform node
  31924. */
  31925. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31926. /**
  31927. * Gets the class name of the mesh
  31928. * @returns The class name
  31929. */
  31930. getClassName(): string;
  31931. }
  31932. /**
  31933. * Represents a physics imposter
  31934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31935. */
  31936. export class PhysicsImpostor {
  31937. /**
  31938. * The physics-enabled object used as the physics imposter
  31939. */
  31940. object: IPhysicsEnabledObject;
  31941. /**
  31942. * The type of the physics imposter
  31943. */
  31944. type: number;
  31945. private _options;
  31946. private _scene?;
  31947. /**
  31948. * The default object size of the imposter
  31949. */
  31950. static DEFAULT_OBJECT_SIZE: Vector3;
  31951. /**
  31952. * The identity quaternion of the imposter
  31953. */
  31954. static IDENTITY_QUATERNION: Quaternion;
  31955. /** @hidden */
  31956. _pluginData: any;
  31957. private _physicsEngine;
  31958. private _physicsBody;
  31959. private _bodyUpdateRequired;
  31960. private _onBeforePhysicsStepCallbacks;
  31961. private _onAfterPhysicsStepCallbacks;
  31962. /** @hidden */
  31963. _onPhysicsCollideCallbacks: Array<{
  31964. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31965. otherImpostors: Array<PhysicsImpostor>;
  31966. }>;
  31967. private _deltaPosition;
  31968. private _deltaRotation;
  31969. private _deltaRotationConjugated;
  31970. /** @hidden */
  31971. _isFromLine: boolean;
  31972. private _parent;
  31973. private _isDisposed;
  31974. private static _tmpVecs;
  31975. private static _tmpQuat;
  31976. /**
  31977. * Specifies if the physics imposter is disposed
  31978. */
  31979. get isDisposed(): boolean;
  31980. /**
  31981. * Gets the mass of the physics imposter
  31982. */
  31983. get mass(): number;
  31984. set mass(value: number);
  31985. /**
  31986. * Gets the coefficient of friction
  31987. */
  31988. get friction(): number;
  31989. /**
  31990. * Sets the coefficient of friction
  31991. */
  31992. set friction(value: number);
  31993. /**
  31994. * Gets the coefficient of restitution
  31995. */
  31996. get restitution(): number;
  31997. /**
  31998. * Sets the coefficient of restitution
  31999. */
  32000. set restitution(value: number);
  32001. /**
  32002. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32003. */
  32004. get pressure(): number;
  32005. /**
  32006. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32007. */
  32008. set pressure(value: number);
  32009. /**
  32010. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32011. */
  32012. get stiffness(): number;
  32013. /**
  32014. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32015. */
  32016. set stiffness(value: number);
  32017. /**
  32018. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32019. */
  32020. get velocityIterations(): number;
  32021. /**
  32022. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32023. */
  32024. set velocityIterations(value: number);
  32025. /**
  32026. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32027. */
  32028. get positionIterations(): number;
  32029. /**
  32030. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32031. */
  32032. set positionIterations(value: number);
  32033. /**
  32034. * The unique id of the physics imposter
  32035. * set by the physics engine when adding this impostor to the array
  32036. */
  32037. uniqueId: number;
  32038. /**
  32039. * @hidden
  32040. */
  32041. soft: boolean;
  32042. /**
  32043. * @hidden
  32044. */
  32045. segments: number;
  32046. private _joints;
  32047. /**
  32048. * Initializes the physics imposter
  32049. * @param object The physics-enabled object used as the physics imposter
  32050. * @param type The type of the physics imposter
  32051. * @param _options The options for the physics imposter
  32052. * @param _scene The Babylon scene
  32053. */
  32054. constructor(
  32055. /**
  32056. * The physics-enabled object used as the physics imposter
  32057. */
  32058. object: IPhysicsEnabledObject,
  32059. /**
  32060. * The type of the physics imposter
  32061. */
  32062. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32063. /**
  32064. * This function will completly initialize this impostor.
  32065. * It will create a new body - but only if this mesh has no parent.
  32066. * If it has, this impostor will not be used other than to define the impostor
  32067. * of the child mesh.
  32068. * @hidden
  32069. */
  32070. _init(): void;
  32071. private _getPhysicsParent;
  32072. /**
  32073. * Should a new body be generated.
  32074. * @returns boolean specifying if body initialization is required
  32075. */
  32076. isBodyInitRequired(): boolean;
  32077. /**
  32078. * Sets the updated scaling
  32079. * @param updated Specifies if the scaling is updated
  32080. */
  32081. setScalingUpdated(): void;
  32082. /**
  32083. * Force a regeneration of this or the parent's impostor's body.
  32084. * Use under cautious - This will remove all joints already implemented.
  32085. */
  32086. forceUpdate(): void;
  32087. /**
  32088. * Gets the body that holds this impostor. Either its own, or its parent.
  32089. */
  32090. get physicsBody(): any;
  32091. /**
  32092. * Get the parent of the physics imposter
  32093. * @returns Physics imposter or null
  32094. */
  32095. get parent(): Nullable<PhysicsImpostor>;
  32096. /**
  32097. * Sets the parent of the physics imposter
  32098. */
  32099. set parent(value: Nullable<PhysicsImpostor>);
  32100. /**
  32101. * Set the physics body. Used mainly by the physics engine/plugin
  32102. */
  32103. set physicsBody(physicsBody: any);
  32104. /**
  32105. * Resets the update flags
  32106. */
  32107. resetUpdateFlags(): void;
  32108. /**
  32109. * Gets the object extend size
  32110. * @returns the object extend size
  32111. */
  32112. getObjectExtendSize(): Vector3;
  32113. /**
  32114. * Gets the object center
  32115. * @returns The object center
  32116. */
  32117. getObjectCenter(): Vector3;
  32118. /**
  32119. * Get a specific parameter from the options parameters
  32120. * @param paramName The object parameter name
  32121. * @returns The object parameter
  32122. */
  32123. getParam(paramName: string): any;
  32124. /**
  32125. * Sets a specific parameter in the options given to the physics plugin
  32126. * @param paramName The parameter name
  32127. * @param value The value of the parameter
  32128. */
  32129. setParam(paramName: string, value: number): void;
  32130. /**
  32131. * Specifically change the body's mass option. Won't recreate the physics body object
  32132. * @param mass The mass of the physics imposter
  32133. */
  32134. setMass(mass: number): void;
  32135. /**
  32136. * Gets the linear velocity
  32137. * @returns linear velocity or null
  32138. */
  32139. getLinearVelocity(): Nullable<Vector3>;
  32140. /**
  32141. * Sets the linear velocity
  32142. * @param velocity linear velocity or null
  32143. */
  32144. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32145. /**
  32146. * Gets the angular velocity
  32147. * @returns angular velocity or null
  32148. */
  32149. getAngularVelocity(): Nullable<Vector3>;
  32150. /**
  32151. * Sets the angular velocity
  32152. * @param velocity The velocity or null
  32153. */
  32154. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32155. /**
  32156. * Execute a function with the physics plugin native code
  32157. * Provide a function the will have two variables - the world object and the physics body object
  32158. * @param func The function to execute with the physics plugin native code
  32159. */
  32160. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32161. /**
  32162. * Register a function that will be executed before the physics world is stepping forward
  32163. * @param func The function to execute before the physics world is stepped forward
  32164. */
  32165. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32166. /**
  32167. * Unregister a function that will be executed before the physics world is stepping forward
  32168. * @param func The function to execute before the physics world is stepped forward
  32169. */
  32170. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32171. /**
  32172. * Register a function that will be executed after the physics step
  32173. * @param func The function to execute after physics step
  32174. */
  32175. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32176. /**
  32177. * Unregisters a function that will be executed after the physics step
  32178. * @param func The function to execute after physics step
  32179. */
  32180. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32181. /**
  32182. * register a function that will be executed when this impostor collides against a different body
  32183. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32184. * @param func Callback that is executed on collision
  32185. */
  32186. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32187. /**
  32188. * Unregisters the physics imposter on contact
  32189. * @param collideAgainst The physics object to collide against
  32190. * @param func Callback to execute on collision
  32191. */
  32192. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32193. private _tmpQuat;
  32194. private _tmpQuat2;
  32195. /**
  32196. * Get the parent rotation
  32197. * @returns The parent rotation
  32198. */
  32199. getParentsRotation(): Quaternion;
  32200. /**
  32201. * this function is executed by the physics engine.
  32202. */
  32203. beforeStep: () => void;
  32204. /**
  32205. * this function is executed by the physics engine
  32206. */
  32207. afterStep: () => void;
  32208. /**
  32209. * Legacy collision detection event support
  32210. */
  32211. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32212. /**
  32213. * event and body object due to cannon's event-based architecture.
  32214. */
  32215. onCollide: (e: {
  32216. body: any;
  32217. point: Nullable<Vector3>;
  32218. }) => void;
  32219. /**
  32220. * Apply a force
  32221. * @param force The force to apply
  32222. * @param contactPoint The contact point for the force
  32223. * @returns The physics imposter
  32224. */
  32225. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32226. /**
  32227. * Apply an impulse
  32228. * @param force The impulse force
  32229. * @param contactPoint The contact point for the impulse force
  32230. * @returns The physics imposter
  32231. */
  32232. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32233. /**
  32234. * A help function to create a joint
  32235. * @param otherImpostor A physics imposter used to create a joint
  32236. * @param jointType The type of joint
  32237. * @param jointData The data for the joint
  32238. * @returns The physics imposter
  32239. */
  32240. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32241. /**
  32242. * Add a joint to this impostor with a different impostor
  32243. * @param otherImpostor A physics imposter used to add a joint
  32244. * @param joint The joint to add
  32245. * @returns The physics imposter
  32246. */
  32247. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32248. /**
  32249. * Add an anchor to a cloth impostor
  32250. * @param otherImpostor rigid impostor to anchor to
  32251. * @param width ratio across width from 0 to 1
  32252. * @param height ratio up height from 0 to 1
  32253. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32254. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32255. * @returns impostor the soft imposter
  32256. */
  32257. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32258. /**
  32259. * Add a hook to a rope impostor
  32260. * @param otherImpostor rigid impostor to anchor to
  32261. * @param length ratio across rope from 0 to 1
  32262. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32263. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32264. * @returns impostor the rope imposter
  32265. */
  32266. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32267. /**
  32268. * Will keep this body still, in a sleep mode.
  32269. * @returns the physics imposter
  32270. */
  32271. sleep(): PhysicsImpostor;
  32272. /**
  32273. * Wake the body up.
  32274. * @returns The physics imposter
  32275. */
  32276. wakeUp(): PhysicsImpostor;
  32277. /**
  32278. * Clones the physics imposter
  32279. * @param newObject The physics imposter clones to this physics-enabled object
  32280. * @returns A nullable physics imposter
  32281. */
  32282. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32283. /**
  32284. * Disposes the physics imposter
  32285. */
  32286. dispose(): void;
  32287. /**
  32288. * Sets the delta position
  32289. * @param position The delta position amount
  32290. */
  32291. setDeltaPosition(position: Vector3): void;
  32292. /**
  32293. * Sets the delta rotation
  32294. * @param rotation The delta rotation amount
  32295. */
  32296. setDeltaRotation(rotation: Quaternion): void;
  32297. /**
  32298. * Gets the box size of the physics imposter and stores the result in the input parameter
  32299. * @param result Stores the box size
  32300. * @returns The physics imposter
  32301. */
  32302. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32303. /**
  32304. * Gets the radius of the physics imposter
  32305. * @returns Radius of the physics imposter
  32306. */
  32307. getRadius(): number;
  32308. /**
  32309. * Sync a bone with this impostor
  32310. * @param bone The bone to sync to the impostor.
  32311. * @param boneMesh The mesh that the bone is influencing.
  32312. * @param jointPivot The pivot of the joint / bone in local space.
  32313. * @param distToJoint Optional distance from the impostor to the joint.
  32314. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32315. */
  32316. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32317. /**
  32318. * Sync impostor to a bone
  32319. * @param bone The bone that the impostor will be synced to.
  32320. * @param boneMesh The mesh that the bone is influencing.
  32321. * @param jointPivot The pivot of the joint / bone in local space.
  32322. * @param distToJoint Optional distance from the impostor to the joint.
  32323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32324. * @param boneAxis Optional vector3 axis the bone is aligned with
  32325. */
  32326. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32327. /**
  32328. * No-Imposter type
  32329. */
  32330. static NoImpostor: number;
  32331. /**
  32332. * Sphere-Imposter type
  32333. */
  32334. static SphereImpostor: number;
  32335. /**
  32336. * Box-Imposter type
  32337. */
  32338. static BoxImpostor: number;
  32339. /**
  32340. * Plane-Imposter type
  32341. */
  32342. static PlaneImpostor: number;
  32343. /**
  32344. * Mesh-imposter type
  32345. */
  32346. static MeshImpostor: number;
  32347. /**
  32348. * Capsule-Impostor type (Ammo.js plugin only)
  32349. */
  32350. static CapsuleImpostor: number;
  32351. /**
  32352. * Cylinder-Imposter type
  32353. */
  32354. static CylinderImpostor: number;
  32355. /**
  32356. * Particle-Imposter type
  32357. */
  32358. static ParticleImpostor: number;
  32359. /**
  32360. * Heightmap-Imposter type
  32361. */
  32362. static HeightmapImpostor: number;
  32363. /**
  32364. * ConvexHull-Impostor type (Ammo.js plugin only)
  32365. */
  32366. static ConvexHullImpostor: number;
  32367. /**
  32368. * Custom-Imposter type (Ammo.js plugin only)
  32369. */
  32370. static CustomImpostor: number;
  32371. /**
  32372. * Rope-Imposter type
  32373. */
  32374. static RopeImpostor: number;
  32375. /**
  32376. * Cloth-Imposter type
  32377. */
  32378. static ClothImpostor: number;
  32379. /**
  32380. * Softbody-Imposter type
  32381. */
  32382. static SoftbodyImpostor: number;
  32383. }
  32384. }
  32385. declare module BABYLON {
  32386. /**
  32387. * @hidden
  32388. **/
  32389. export class _CreationDataStorage {
  32390. closePath?: boolean;
  32391. closeArray?: boolean;
  32392. idx: number[];
  32393. dashSize: number;
  32394. gapSize: number;
  32395. path3D: Path3D;
  32396. pathArray: Vector3[][];
  32397. arc: number;
  32398. radius: number;
  32399. cap: number;
  32400. tessellation: number;
  32401. }
  32402. /**
  32403. * @hidden
  32404. **/
  32405. class _InstanceDataStorage {
  32406. visibleInstances: any;
  32407. batchCache: _InstancesBatch;
  32408. instancesBufferSize: number;
  32409. instancesBuffer: Nullable<Buffer>;
  32410. instancesData: Float32Array;
  32411. overridenInstanceCount: number;
  32412. isFrozen: boolean;
  32413. previousBatch: Nullable<_InstancesBatch>;
  32414. hardwareInstancedRendering: boolean;
  32415. sideOrientation: number;
  32416. manualUpdate: boolean;
  32417. previousRenderId: number;
  32418. }
  32419. /**
  32420. * @hidden
  32421. **/
  32422. export class _InstancesBatch {
  32423. mustReturn: boolean;
  32424. visibleInstances: Nullable<InstancedMesh[]>[];
  32425. renderSelf: boolean[];
  32426. hardwareInstancedRendering: boolean[];
  32427. }
  32428. /**
  32429. * @hidden
  32430. **/
  32431. class _ThinInstanceDataStorage {
  32432. instancesCount: number;
  32433. matrixBuffer: Nullable<Buffer>;
  32434. matrixBufferSize: number;
  32435. matrixData: Nullable<Float32Array>;
  32436. boundingVectors: Array<Vector3>;
  32437. worldMatrices: Nullable<Matrix[]>;
  32438. }
  32439. /**
  32440. * Class used to represent renderable models
  32441. */
  32442. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32443. /**
  32444. * Mesh side orientation : usually the external or front surface
  32445. */
  32446. static readonly FRONTSIDE: number;
  32447. /**
  32448. * Mesh side orientation : usually the internal or back surface
  32449. */
  32450. static readonly BACKSIDE: number;
  32451. /**
  32452. * Mesh side orientation : both internal and external or front and back surfaces
  32453. */
  32454. static readonly DOUBLESIDE: number;
  32455. /**
  32456. * Mesh side orientation : by default, `FRONTSIDE`
  32457. */
  32458. static readonly DEFAULTSIDE: number;
  32459. /**
  32460. * Mesh cap setting : no cap
  32461. */
  32462. static readonly NO_CAP: number;
  32463. /**
  32464. * Mesh cap setting : one cap at the beginning of the mesh
  32465. */
  32466. static readonly CAP_START: number;
  32467. /**
  32468. * Mesh cap setting : one cap at the end of the mesh
  32469. */
  32470. static readonly CAP_END: number;
  32471. /**
  32472. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32473. */
  32474. static readonly CAP_ALL: number;
  32475. /**
  32476. * Mesh pattern setting : no flip or rotate
  32477. */
  32478. static readonly NO_FLIP: number;
  32479. /**
  32480. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32481. */
  32482. static readonly FLIP_TILE: number;
  32483. /**
  32484. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32485. */
  32486. static readonly ROTATE_TILE: number;
  32487. /**
  32488. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32489. */
  32490. static readonly FLIP_ROW: number;
  32491. /**
  32492. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32493. */
  32494. static readonly ROTATE_ROW: number;
  32495. /**
  32496. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32497. */
  32498. static readonly FLIP_N_ROTATE_TILE: number;
  32499. /**
  32500. * Mesh pattern setting : rotate pattern and rotate
  32501. */
  32502. static readonly FLIP_N_ROTATE_ROW: number;
  32503. /**
  32504. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32505. */
  32506. static readonly CENTER: number;
  32507. /**
  32508. * Mesh tile positioning : part tiles on left
  32509. */
  32510. static readonly LEFT: number;
  32511. /**
  32512. * Mesh tile positioning : part tiles on right
  32513. */
  32514. static readonly RIGHT: number;
  32515. /**
  32516. * Mesh tile positioning : part tiles on top
  32517. */
  32518. static readonly TOP: number;
  32519. /**
  32520. * Mesh tile positioning : part tiles on bottom
  32521. */
  32522. static readonly BOTTOM: number;
  32523. /**
  32524. * Gets the default side orientation.
  32525. * @param orientation the orientation to value to attempt to get
  32526. * @returns the default orientation
  32527. * @hidden
  32528. */
  32529. static _GetDefaultSideOrientation(orientation?: number): number;
  32530. private _internalMeshDataInfo;
  32531. get computeBonesUsingShaders(): boolean;
  32532. set computeBonesUsingShaders(value: boolean);
  32533. /**
  32534. * An event triggered before rendering the mesh
  32535. */
  32536. get onBeforeRenderObservable(): Observable<Mesh>;
  32537. /**
  32538. * An event triggered before binding the mesh
  32539. */
  32540. get onBeforeBindObservable(): Observable<Mesh>;
  32541. /**
  32542. * An event triggered after rendering the mesh
  32543. */
  32544. get onAfterRenderObservable(): Observable<Mesh>;
  32545. /**
  32546. * An event triggered before drawing the mesh
  32547. */
  32548. get onBeforeDrawObservable(): Observable<Mesh>;
  32549. private _onBeforeDrawObserver;
  32550. /**
  32551. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32552. */
  32553. set onBeforeDraw(callback: () => void);
  32554. get hasInstances(): boolean;
  32555. get hasThinInstances(): boolean;
  32556. /**
  32557. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32558. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32559. */
  32560. delayLoadState: number;
  32561. /**
  32562. * Gets the list of instances created from this mesh
  32563. * it is not supposed to be modified manually.
  32564. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32565. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32566. */
  32567. instances: InstancedMesh[];
  32568. /**
  32569. * Gets the file containing delay loading data for this mesh
  32570. */
  32571. delayLoadingFile: string;
  32572. /** @hidden */
  32573. _binaryInfo: any;
  32574. /**
  32575. * User defined function used to change how LOD level selection is done
  32576. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32577. */
  32578. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32579. /**
  32580. * Gets or sets the morph target manager
  32581. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32582. */
  32583. get morphTargetManager(): Nullable<MorphTargetManager>;
  32584. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32585. /** @hidden */
  32586. _creationDataStorage: Nullable<_CreationDataStorage>;
  32587. /** @hidden */
  32588. _geometry: Nullable<Geometry>;
  32589. /** @hidden */
  32590. _delayInfo: Array<string>;
  32591. /** @hidden */
  32592. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32593. /** @hidden */
  32594. _instanceDataStorage: _InstanceDataStorage;
  32595. /** @hidden */
  32596. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32597. private _effectiveMaterial;
  32598. /** @hidden */
  32599. _shouldGenerateFlatShading: boolean;
  32600. /** @hidden */
  32601. _originalBuilderSideOrientation: number;
  32602. /**
  32603. * Use this property to change the original side orientation defined at construction time
  32604. */
  32605. overrideMaterialSideOrientation: Nullable<number>;
  32606. /**
  32607. * Gets the source mesh (the one used to clone this one from)
  32608. */
  32609. get source(): Nullable<Mesh>;
  32610. /**
  32611. * Gets the list of clones of this mesh
  32612. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32613. * Note that useClonedMeshMap=true is the default setting
  32614. */
  32615. get cloneMeshMap(): Nullable<{
  32616. [id: string]: Mesh | undefined;
  32617. }>;
  32618. /**
  32619. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32620. */
  32621. get isUnIndexed(): boolean;
  32622. set isUnIndexed(value: boolean);
  32623. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32624. get worldMatrixInstancedBuffer(): Float32Array;
  32625. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32626. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32627. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32628. /**
  32629. * @constructor
  32630. * @param name The value used by scene.getMeshByName() to do a lookup.
  32631. * @param scene The scene to add this mesh to.
  32632. * @param parent The parent of this mesh, if it has one
  32633. * @param source An optional Mesh from which geometry is shared, cloned.
  32634. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32635. * When false, achieved by calling a clone(), also passing False.
  32636. * This will make creation of children, recursive.
  32637. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32638. */
  32639. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32640. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32641. doNotInstantiate: boolean;
  32642. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32643. /**
  32644. * Gets the class name
  32645. * @returns the string "Mesh".
  32646. */
  32647. getClassName(): string;
  32648. /** @hidden */
  32649. get _isMesh(): boolean;
  32650. /**
  32651. * Returns a description of this mesh
  32652. * @param fullDetails define if full details about this mesh must be used
  32653. * @returns a descriptive string representing this mesh
  32654. */
  32655. toString(fullDetails?: boolean): string;
  32656. /** @hidden */
  32657. _unBindEffect(): void;
  32658. /**
  32659. * Gets a boolean indicating if this mesh has LOD
  32660. */
  32661. get hasLODLevels(): boolean;
  32662. /**
  32663. * Gets the list of MeshLODLevel associated with the current mesh
  32664. * @returns an array of MeshLODLevel
  32665. */
  32666. getLODLevels(): MeshLODLevel[];
  32667. private _sortLODLevels;
  32668. /**
  32669. * Add a mesh as LOD level triggered at the given distance.
  32670. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32671. * @param distance The distance from the center of the object to show this level
  32672. * @param mesh The mesh to be added as LOD level (can be null)
  32673. * @return This mesh (for chaining)
  32674. */
  32675. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32676. /**
  32677. * Returns the LOD level mesh at the passed distance or null if not found.
  32678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32679. * @param distance The distance from the center of the object to show this level
  32680. * @returns a Mesh or `null`
  32681. */
  32682. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32683. /**
  32684. * Remove a mesh from the LOD array
  32685. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32686. * @param mesh defines the mesh to be removed
  32687. * @return This mesh (for chaining)
  32688. */
  32689. removeLODLevel(mesh: Mesh): Mesh;
  32690. /**
  32691. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32692. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32693. * @param camera defines the camera to use to compute distance
  32694. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32695. * @return This mesh (for chaining)
  32696. */
  32697. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32698. /**
  32699. * Gets the mesh internal Geometry object
  32700. */
  32701. get geometry(): Nullable<Geometry>;
  32702. /**
  32703. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32704. * @returns the total number of vertices
  32705. */
  32706. getTotalVertices(): number;
  32707. /**
  32708. * Returns the content of an associated vertex buffer
  32709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32710. * - VertexBuffer.PositionKind
  32711. * - VertexBuffer.UVKind
  32712. * - VertexBuffer.UV2Kind
  32713. * - VertexBuffer.UV3Kind
  32714. * - VertexBuffer.UV4Kind
  32715. * - VertexBuffer.UV5Kind
  32716. * - VertexBuffer.UV6Kind
  32717. * - VertexBuffer.ColorKind
  32718. * - VertexBuffer.MatricesIndicesKind
  32719. * - VertexBuffer.MatricesIndicesExtraKind
  32720. * - VertexBuffer.MatricesWeightsKind
  32721. * - VertexBuffer.MatricesWeightsExtraKind
  32722. * @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
  32723. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32724. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32725. */
  32726. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32727. /**
  32728. * Returns the mesh VertexBuffer object from the requested `kind`
  32729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32730. * - VertexBuffer.PositionKind
  32731. * - VertexBuffer.NormalKind
  32732. * - VertexBuffer.UVKind
  32733. * - VertexBuffer.UV2Kind
  32734. * - VertexBuffer.UV3Kind
  32735. * - VertexBuffer.UV4Kind
  32736. * - VertexBuffer.UV5Kind
  32737. * - VertexBuffer.UV6Kind
  32738. * - VertexBuffer.ColorKind
  32739. * - VertexBuffer.MatricesIndicesKind
  32740. * - VertexBuffer.MatricesIndicesExtraKind
  32741. * - VertexBuffer.MatricesWeightsKind
  32742. * - VertexBuffer.MatricesWeightsExtraKind
  32743. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32744. */
  32745. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32746. /**
  32747. * Tests if a specific vertex buffer is associated with this mesh
  32748. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32749. * - VertexBuffer.PositionKind
  32750. * - VertexBuffer.NormalKind
  32751. * - VertexBuffer.UVKind
  32752. * - VertexBuffer.UV2Kind
  32753. * - VertexBuffer.UV3Kind
  32754. * - VertexBuffer.UV4Kind
  32755. * - VertexBuffer.UV5Kind
  32756. * - VertexBuffer.UV6Kind
  32757. * - VertexBuffer.ColorKind
  32758. * - VertexBuffer.MatricesIndicesKind
  32759. * - VertexBuffer.MatricesIndicesExtraKind
  32760. * - VertexBuffer.MatricesWeightsKind
  32761. * - VertexBuffer.MatricesWeightsExtraKind
  32762. * @returns a boolean
  32763. */
  32764. isVerticesDataPresent(kind: string): boolean;
  32765. /**
  32766. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32767. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32768. * - VertexBuffer.PositionKind
  32769. * - VertexBuffer.UVKind
  32770. * - VertexBuffer.UV2Kind
  32771. * - VertexBuffer.UV3Kind
  32772. * - VertexBuffer.UV4Kind
  32773. * - VertexBuffer.UV5Kind
  32774. * - VertexBuffer.UV6Kind
  32775. * - VertexBuffer.ColorKind
  32776. * - VertexBuffer.MatricesIndicesKind
  32777. * - VertexBuffer.MatricesIndicesExtraKind
  32778. * - VertexBuffer.MatricesWeightsKind
  32779. * - VertexBuffer.MatricesWeightsExtraKind
  32780. * @returns a boolean
  32781. */
  32782. isVertexBufferUpdatable(kind: string): boolean;
  32783. /**
  32784. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32785. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32786. * - VertexBuffer.PositionKind
  32787. * - VertexBuffer.NormalKind
  32788. * - VertexBuffer.UVKind
  32789. * - VertexBuffer.UV2Kind
  32790. * - VertexBuffer.UV3Kind
  32791. * - VertexBuffer.UV4Kind
  32792. * - VertexBuffer.UV5Kind
  32793. * - VertexBuffer.UV6Kind
  32794. * - VertexBuffer.ColorKind
  32795. * - VertexBuffer.MatricesIndicesKind
  32796. * - VertexBuffer.MatricesIndicesExtraKind
  32797. * - VertexBuffer.MatricesWeightsKind
  32798. * - VertexBuffer.MatricesWeightsExtraKind
  32799. * @returns an array of strings
  32800. */
  32801. getVerticesDataKinds(): string[];
  32802. /**
  32803. * Returns a positive integer : the total number of indices in this mesh geometry.
  32804. * @returns the numner of indices or zero if the mesh has no geometry.
  32805. */
  32806. getTotalIndices(): number;
  32807. /**
  32808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32809. * @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.
  32810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32811. * @returns the indices array or an empty array if the mesh has no geometry
  32812. */
  32813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32814. get isBlocked(): boolean;
  32815. /**
  32816. * Determine if the current mesh is ready to be rendered
  32817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32818. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32819. * @returns true if all associated assets are ready (material, textures, shaders)
  32820. */
  32821. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32822. /**
  32823. * 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.
  32824. */
  32825. get areNormalsFrozen(): boolean;
  32826. /**
  32827. * 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.
  32828. * @returns the current mesh
  32829. */
  32830. freezeNormals(): Mesh;
  32831. /**
  32832. * 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
  32833. * @returns the current mesh
  32834. */
  32835. unfreezeNormals(): Mesh;
  32836. /**
  32837. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32838. */
  32839. set overridenInstanceCount(count: number);
  32840. /** @hidden */
  32841. _preActivate(): Mesh;
  32842. /** @hidden */
  32843. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32844. /** @hidden */
  32845. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32846. protected _afterComputeWorldMatrix(): void;
  32847. /** @hidden */
  32848. _postActivate(): void;
  32849. /**
  32850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32851. * This means the mesh underlying bounding box and sphere are recomputed.
  32852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32853. * @returns the current mesh
  32854. */
  32855. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32856. /** @hidden */
  32857. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32858. /**
  32859. * This function will subdivide the mesh into multiple submeshes
  32860. * @param count defines the expected number of submeshes
  32861. */
  32862. subdivide(count: number): void;
  32863. /**
  32864. * Copy a FloatArray into a specific associated vertex buffer
  32865. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32866. * - VertexBuffer.PositionKind
  32867. * - VertexBuffer.UVKind
  32868. * - VertexBuffer.UV2Kind
  32869. * - VertexBuffer.UV3Kind
  32870. * - VertexBuffer.UV4Kind
  32871. * - VertexBuffer.UV5Kind
  32872. * - VertexBuffer.UV6Kind
  32873. * - VertexBuffer.ColorKind
  32874. * - VertexBuffer.MatricesIndicesKind
  32875. * - VertexBuffer.MatricesIndicesExtraKind
  32876. * - VertexBuffer.MatricesWeightsKind
  32877. * - VertexBuffer.MatricesWeightsExtraKind
  32878. * @param data defines the data source
  32879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32880. * @param stride defines the data stride size (can be null)
  32881. * @returns the current mesh
  32882. */
  32883. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32884. /**
  32885. * Delete a vertex buffer associated with this mesh
  32886. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32887. * - VertexBuffer.PositionKind
  32888. * - VertexBuffer.UVKind
  32889. * - VertexBuffer.UV2Kind
  32890. * - VertexBuffer.UV3Kind
  32891. * - VertexBuffer.UV4Kind
  32892. * - VertexBuffer.UV5Kind
  32893. * - VertexBuffer.UV6Kind
  32894. * - VertexBuffer.ColorKind
  32895. * - VertexBuffer.MatricesIndicesKind
  32896. * - VertexBuffer.MatricesIndicesExtraKind
  32897. * - VertexBuffer.MatricesWeightsKind
  32898. * - VertexBuffer.MatricesWeightsExtraKind
  32899. */
  32900. removeVerticesData(kind: string): void;
  32901. /**
  32902. * Flags an associated vertex buffer as updatable
  32903. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32904. * - VertexBuffer.PositionKind
  32905. * - VertexBuffer.UVKind
  32906. * - VertexBuffer.UV2Kind
  32907. * - VertexBuffer.UV3Kind
  32908. * - VertexBuffer.UV4Kind
  32909. * - VertexBuffer.UV5Kind
  32910. * - VertexBuffer.UV6Kind
  32911. * - VertexBuffer.ColorKind
  32912. * - VertexBuffer.MatricesIndicesKind
  32913. * - VertexBuffer.MatricesIndicesExtraKind
  32914. * - VertexBuffer.MatricesWeightsKind
  32915. * - VertexBuffer.MatricesWeightsExtraKind
  32916. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32917. */
  32918. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32919. /**
  32920. * Sets the mesh global Vertex Buffer
  32921. * @param buffer defines the buffer to use
  32922. * @returns the current mesh
  32923. */
  32924. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32925. /**
  32926. * Update a specific associated vertex buffer
  32927. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32928. * - VertexBuffer.PositionKind
  32929. * - VertexBuffer.UVKind
  32930. * - VertexBuffer.UV2Kind
  32931. * - VertexBuffer.UV3Kind
  32932. * - VertexBuffer.UV4Kind
  32933. * - VertexBuffer.UV5Kind
  32934. * - VertexBuffer.UV6Kind
  32935. * - VertexBuffer.ColorKind
  32936. * - VertexBuffer.MatricesIndicesKind
  32937. * - VertexBuffer.MatricesIndicesExtraKind
  32938. * - VertexBuffer.MatricesWeightsKind
  32939. * - VertexBuffer.MatricesWeightsExtraKind
  32940. * @param data defines the data source
  32941. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32942. * @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)
  32943. * @returns the current mesh
  32944. */
  32945. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32946. /**
  32947. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32948. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32949. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32950. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32951. * @returns the current mesh
  32952. */
  32953. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32954. /**
  32955. * Creates a un-shared specific occurence of the geometry for the mesh.
  32956. * @returns the current mesh
  32957. */
  32958. makeGeometryUnique(): Mesh;
  32959. /**
  32960. * Set the index buffer of this mesh
  32961. * @param indices defines the source data
  32962. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32963. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32964. * @returns the current mesh
  32965. */
  32966. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32967. /**
  32968. * Update the current index buffer
  32969. * @param indices defines the source data
  32970. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32971. * @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)
  32972. * @returns the current mesh
  32973. */
  32974. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32975. /**
  32976. * Invert the geometry to move from a right handed system to a left handed one.
  32977. * @returns the current mesh
  32978. */
  32979. toLeftHanded(): Mesh;
  32980. /** @hidden */
  32981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32982. /** @hidden */
  32983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32984. /**
  32985. * Registers for this mesh a javascript function called just before the rendering process
  32986. * @param func defines the function to call before rendering this mesh
  32987. * @returns the current mesh
  32988. */
  32989. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32990. /**
  32991. * Disposes a previously registered javascript function called before the rendering
  32992. * @param func defines the function to remove
  32993. * @returns the current mesh
  32994. */
  32995. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32996. /**
  32997. * Registers for this mesh a javascript function called just after the rendering is complete
  32998. * @param func defines the function to call after rendering this mesh
  32999. * @returns the current mesh
  33000. */
  33001. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33002. /**
  33003. * Disposes a previously registered javascript function called after the rendering.
  33004. * @param func defines the function to remove
  33005. * @returns the current mesh
  33006. */
  33007. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33008. /** @hidden */
  33009. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33010. /** @hidden */
  33011. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33012. /** @hidden */
  33013. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33014. /** @hidden */
  33015. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33016. /** @hidden */
  33017. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33018. /** @hidden */
  33019. _rebuild(): void;
  33020. /** @hidden */
  33021. _freeze(): void;
  33022. /** @hidden */
  33023. _unFreeze(): void;
  33024. /**
  33025. * 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
  33026. * @param subMesh defines the subMesh to render
  33027. * @param enableAlphaMode defines if alpha mode can be changed
  33028. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33029. * @returns the current mesh
  33030. */
  33031. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33032. private _onBeforeDraw;
  33033. /**
  33034. * Renormalize the mesh and patch it up if there are no weights
  33035. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33036. * However in the case of zero weights then we set just a single influence to 1.
  33037. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33038. */
  33039. cleanMatrixWeights(): void;
  33040. private normalizeSkinFourWeights;
  33041. private normalizeSkinWeightsAndExtra;
  33042. /**
  33043. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33044. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33045. * the user know there was an issue with importing the mesh
  33046. * @returns a validation object with skinned, valid and report string
  33047. */
  33048. validateSkinning(): {
  33049. skinned: boolean;
  33050. valid: boolean;
  33051. report: string;
  33052. };
  33053. /** @hidden */
  33054. _checkDelayState(): Mesh;
  33055. private _queueLoad;
  33056. /**
  33057. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33058. * A mesh is in the frustum if its bounding box intersects the frustum
  33059. * @param frustumPlanes defines the frustum to test
  33060. * @returns true if the mesh is in the frustum planes
  33061. */
  33062. isInFrustum(frustumPlanes: Plane[]): boolean;
  33063. /**
  33064. * Sets the mesh material by the material or multiMaterial `id` property
  33065. * @param id is a string identifying the material or the multiMaterial
  33066. * @returns the current mesh
  33067. */
  33068. setMaterialByID(id: string): Mesh;
  33069. /**
  33070. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33071. * @returns an array of IAnimatable
  33072. */
  33073. getAnimatables(): IAnimatable[];
  33074. /**
  33075. * Modifies the mesh geometry according to the passed transformation matrix.
  33076. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33077. * The mesh normals are modified using the same transformation.
  33078. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33079. * @param transform defines the transform matrix to use
  33080. * @see https://doc.babylonjs.com/resources/baking_transformations
  33081. * @returns the current mesh
  33082. */
  33083. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33084. /**
  33085. * Modifies the mesh geometry according to its own current World Matrix.
  33086. * The mesh World Matrix is then reset.
  33087. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33089. * @see https://doc.babylonjs.com/resources/baking_transformations
  33090. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33091. * @returns the current mesh
  33092. */
  33093. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33094. /** @hidden */
  33095. get _positions(): Nullable<Vector3[]>;
  33096. /** @hidden */
  33097. _resetPointsArrayCache(): Mesh;
  33098. /** @hidden */
  33099. _generatePointsArray(): boolean;
  33100. /**
  33101. * Returns a new Mesh object generated from the current mesh properties.
  33102. * This method must not get confused with createInstance()
  33103. * @param name is a string, the name given to the new mesh
  33104. * @param newParent can be any Node object (default `null`)
  33105. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33106. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33107. * @returns a new mesh
  33108. */
  33109. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33110. /**
  33111. * Releases resources associated with this mesh.
  33112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33114. */
  33115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33116. /** @hidden */
  33117. _disposeInstanceSpecificData(): void;
  33118. /** @hidden */
  33119. _disposeThinInstanceSpecificData(): void;
  33120. /**
  33121. * Modifies the mesh geometry according to a displacement map.
  33122. * 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.
  33123. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33124. * @param url is a string, the URL from the image file is to be downloaded.
  33125. * @param minHeight is the lower limit of the displacement.
  33126. * @param maxHeight is the upper limit of the displacement.
  33127. * @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.
  33128. * @param uvOffset is an optional vector2 used to offset UV.
  33129. * @param uvScale is an optional vector2 used to scale UV.
  33130. * @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.
  33131. * @returns the Mesh.
  33132. */
  33133. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33134. /**
  33135. * Modifies the mesh geometry according to a displacementMap buffer.
  33136. * 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.
  33137. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33138. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33139. * @param heightMapWidth is the width of the buffer image.
  33140. * @param heightMapHeight is the height of the buffer image.
  33141. * @param minHeight is the lower limit of the displacement.
  33142. * @param maxHeight is the upper limit of the displacement.
  33143. * @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.
  33144. * @param uvOffset is an optional vector2 used to offset UV.
  33145. * @param uvScale is an optional vector2 used to scale UV.
  33146. * @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.
  33147. * @returns the Mesh.
  33148. */
  33149. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33150. /**
  33151. * Modify the mesh to get a flat shading rendering.
  33152. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33153. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33154. * @returns current mesh
  33155. */
  33156. convertToFlatShadedMesh(): Mesh;
  33157. /**
  33158. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33159. * In other words, more vertices, no more indices and a single bigger VBO.
  33160. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33161. * @returns current mesh
  33162. */
  33163. convertToUnIndexedMesh(): Mesh;
  33164. /**
  33165. * Inverses facet orientations.
  33166. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33167. * @param flipNormals will also inverts the normals
  33168. * @returns current mesh
  33169. */
  33170. flipFaces(flipNormals?: boolean): Mesh;
  33171. /**
  33172. * Increase the number of facets and hence vertices in a mesh
  33173. * Vertex normals are interpolated from existing vertex normals
  33174. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33175. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33176. */
  33177. increaseVertices(numberPerEdge: number): void;
  33178. /**
  33179. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33180. * This will undo any application of covertToFlatShadedMesh
  33181. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33182. */
  33183. forceSharedVertices(): void;
  33184. /** @hidden */
  33185. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33186. /** @hidden */
  33187. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33188. /**
  33189. * Creates a new InstancedMesh object from the mesh model.
  33190. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33191. * @param name defines the name of the new instance
  33192. * @returns a new InstancedMesh
  33193. */
  33194. createInstance(name: string): InstancedMesh;
  33195. /**
  33196. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33197. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33198. * @returns the current mesh
  33199. */
  33200. synchronizeInstances(): Mesh;
  33201. /**
  33202. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33203. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33204. * This should be used together with the simplification to avoid disappearing triangles.
  33205. * @param successCallback an optional success callback to be called after the optimization finished.
  33206. * @returns the current mesh
  33207. */
  33208. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33209. /**
  33210. * Serialize current mesh
  33211. * @param serializationObject defines the object which will receive the serialization data
  33212. */
  33213. serialize(serializationObject: any): void;
  33214. /** @hidden */
  33215. _syncGeometryWithMorphTargetManager(): void;
  33216. /** @hidden */
  33217. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33218. /**
  33219. * Returns a new Mesh object parsed from the source provided.
  33220. * @param parsedMesh is the source
  33221. * @param scene defines the hosting scene
  33222. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33223. * @returns a new Mesh
  33224. */
  33225. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33226. /**
  33227. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33229. * @param name defines the name of the mesh to create
  33230. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33231. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33232. * @param closePath creates a seam between the first and the last points of each path of the path array
  33233. * @param offset is taken in account only if the `pathArray` is containing a single path
  33234. * @param scene defines the hosting scene
  33235. * @param updatable defines if the mesh must be flagged as updatable
  33236. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33237. * @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)
  33238. * @returns a new Mesh
  33239. */
  33240. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33241. /**
  33242. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33243. * @param name defines the name of the mesh to create
  33244. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33245. * @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
  33246. * @param scene defines the hosting scene
  33247. * @param updatable defines if the mesh must be flagged as updatable
  33248. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33249. * @returns a new Mesh
  33250. */
  33251. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33252. /**
  33253. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33254. * @param name defines the name of the mesh to create
  33255. * @param size sets the size (float) of each box side (default 1)
  33256. * @param scene defines the hosting scene
  33257. * @param updatable defines if the mesh must be flagged as updatable
  33258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33259. * @returns a new Mesh
  33260. */
  33261. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33262. /**
  33263. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33264. * @param name defines the name of the mesh to create
  33265. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33266. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33267. * @param scene defines the hosting scene
  33268. * @param updatable defines if the mesh must be flagged as updatable
  33269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33270. * @returns a new Mesh
  33271. */
  33272. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33273. /**
  33274. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33275. * @param name defines the name of the mesh to create
  33276. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33277. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33278. * @param scene defines the hosting scene
  33279. * @returns a new Mesh
  33280. */
  33281. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33282. /**
  33283. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33284. * @param name defines the name of the mesh to create
  33285. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33286. * @param diameterTop set the top cap diameter (floats, default 1)
  33287. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33288. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33289. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33290. * @param scene defines the hosting scene
  33291. * @param updatable defines if the mesh must be flagged as updatable
  33292. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33293. * @returns a new Mesh
  33294. */
  33295. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33296. /**
  33297. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33298. * @param name defines the name of the mesh to create
  33299. * @param diameter sets the diameter size (float) of the torus (default 1)
  33300. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33301. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33302. * @param scene defines the hosting scene
  33303. * @param updatable defines if the mesh must be flagged as updatable
  33304. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33305. * @returns a new Mesh
  33306. */
  33307. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33308. /**
  33309. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33310. * @param name defines the name of the mesh to create
  33311. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33312. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33313. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33314. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33315. * @param p the number of windings on X axis (positive integers, default 2)
  33316. * @param q the number of windings on Y axis (positive integers, default 3)
  33317. * @param scene defines the hosting scene
  33318. * @param updatable defines if the mesh must be flagged as updatable
  33319. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33320. * @returns a new Mesh
  33321. */
  33322. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33323. /**
  33324. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33325. * @param name defines the name of the mesh to create
  33326. * @param points is an array successive Vector3
  33327. * @param scene defines the hosting scene
  33328. * @param updatable defines if the mesh must be flagged as updatable
  33329. * @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).
  33330. * @returns a new Mesh
  33331. */
  33332. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33333. /**
  33334. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33335. * @param name defines the name of the mesh to create
  33336. * @param points is an array successive Vector3
  33337. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33338. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33339. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33340. * @param scene defines the hosting scene
  33341. * @param updatable defines if the mesh must be flagged as updatable
  33342. * @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)
  33343. * @returns a new Mesh
  33344. */
  33345. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33346. /**
  33347. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33348. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33349. * 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.
  33350. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33351. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33352. * Remember you can only change the shape positions, not their number when updating a polygon.
  33353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33354. * @param name defines the name of the mesh to create
  33355. * @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
  33356. * @param scene defines the hosting scene
  33357. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33358. * @param updatable defines if the mesh must be flagged as updatable
  33359. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33360. * @param earcutInjection can be used to inject your own earcut reference
  33361. * @returns a new Mesh
  33362. */
  33363. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33364. /**
  33365. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33367. * @param name defines the name of the mesh to create
  33368. * @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
  33369. * @param depth defines the height of extrusion
  33370. * @param scene defines the hosting scene
  33371. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33372. * @param updatable defines if the mesh must be flagged as updatable
  33373. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33374. * @param earcutInjection can be used to inject your own earcut reference
  33375. * @returns a new Mesh
  33376. */
  33377. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33378. /**
  33379. * Creates an extruded shape mesh.
  33380. * 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
  33381. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33383. * @param name defines the name of the mesh to create
  33384. * @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
  33385. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33386. * @param scale is the value to scale the shape
  33387. * @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
  33388. * @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
  33389. * @param scene defines the hosting scene
  33390. * @param updatable defines if the mesh must be flagged as updatable
  33391. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33392. * @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)
  33393. * @returns a new Mesh
  33394. */
  33395. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33396. /**
  33397. * Creates an custom extruded shape mesh.
  33398. * The custom extrusion is a parametric shape.
  33399. * It has no predefined shape. Its final shape will depend on the input parameters.
  33400. * Please consider using the same method from the MeshBuilder class instead
  33401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33402. * @param name defines the name of the mesh to create
  33403. * @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
  33404. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33405. * @param scaleFunction is a custom Javascript function called on each path point
  33406. * @param rotationFunction is a custom Javascript function called on each path point
  33407. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33408. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33409. * @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
  33410. * @param scene defines the hosting scene
  33411. * @param updatable defines if the mesh must be flagged as updatable
  33412. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33413. * @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)
  33414. * @returns a new Mesh
  33415. */
  33416. 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;
  33417. /**
  33418. * Creates lathe mesh.
  33419. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33420. * Please consider using the same method from the MeshBuilder class instead
  33421. * @param name defines the name of the mesh to create
  33422. * @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
  33423. * @param radius is the radius value of the lathe
  33424. * @param tessellation is the side number of the lathe.
  33425. * @param scene defines the hosting scene
  33426. * @param updatable defines if the mesh must be flagged as updatable
  33427. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33428. * @returns a new Mesh
  33429. */
  33430. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33431. /**
  33432. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33433. * @param name defines the name of the mesh to create
  33434. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33435. * @param scene defines the hosting scene
  33436. * @param updatable defines if the mesh must be flagged as updatable
  33437. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33438. * @returns a new Mesh
  33439. */
  33440. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33441. /**
  33442. * Creates a ground mesh.
  33443. * Please consider using the same method from the MeshBuilder class instead
  33444. * @param name defines the name of the mesh to create
  33445. * @param width set the width of the ground
  33446. * @param height set the height of the ground
  33447. * @param subdivisions sets the number of subdivisions per side
  33448. * @param scene defines the hosting scene
  33449. * @param updatable defines if the mesh must be flagged as updatable
  33450. * @returns a new Mesh
  33451. */
  33452. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33453. /**
  33454. * Creates a tiled ground mesh.
  33455. * Please consider using the same method from the MeshBuilder class instead
  33456. * @param name defines the name of the mesh to create
  33457. * @param xmin set the ground minimum X coordinate
  33458. * @param zmin set the ground minimum Y coordinate
  33459. * @param xmax set the ground maximum X coordinate
  33460. * @param zmax set the ground maximum Z coordinate
  33461. * @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
  33462. * @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
  33463. * @param scene defines the hosting scene
  33464. * @param updatable defines if the mesh must be flagged as updatable
  33465. * @returns a new Mesh
  33466. */
  33467. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33468. w: number;
  33469. h: number;
  33470. }, precision: {
  33471. w: number;
  33472. h: number;
  33473. }, scene: Scene, updatable?: boolean): Mesh;
  33474. /**
  33475. * Creates a ground mesh from a height map.
  33476. * Please consider using the same method from the MeshBuilder class instead
  33477. * @see https://doc.babylonjs.com/babylon101/height_map
  33478. * @param name defines the name of the mesh to create
  33479. * @param url sets the URL of the height map image resource
  33480. * @param width set the ground width size
  33481. * @param height set the ground height size
  33482. * @param subdivisions sets the number of subdivision per side
  33483. * @param minHeight is the minimum altitude on the ground
  33484. * @param maxHeight is the maximum altitude on the ground
  33485. * @param scene defines the hosting scene
  33486. * @param updatable defines if the mesh must be flagged as updatable
  33487. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33488. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33489. * @returns a new Mesh
  33490. */
  33491. 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;
  33492. /**
  33493. * Creates a tube mesh.
  33494. * The tube is a parametric shape.
  33495. * It has no predefined shape. Its final shape will depend on the input parameters.
  33496. * Please consider using the same method from the MeshBuilder class instead
  33497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33498. * @param name defines the name of the mesh to create
  33499. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33500. * @param radius sets the tube radius size
  33501. * @param tessellation is the number of sides on the tubular surface
  33502. * @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
  33503. * @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
  33504. * @param scene defines the hosting scene
  33505. * @param updatable defines if the mesh must be flagged as updatable
  33506. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33507. * @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)
  33508. * @returns a new Mesh
  33509. */
  33510. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33511. (i: number, distance: number): number;
  33512. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33513. /**
  33514. * Creates a polyhedron mesh.
  33515. * Please consider using the same method from the MeshBuilder class instead.
  33516. * * 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
  33517. * * The parameter `size` (positive float, default 1) sets the polygon size
  33518. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33519. * * 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`
  33520. * * 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
  33521. * * 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)`)
  33522. * * 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
  33523. * * 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
  33524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33525. * * 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
  33526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33527. * @param name defines the name of the mesh to create
  33528. * @param options defines the options used to create the mesh
  33529. * @param scene defines the hosting scene
  33530. * @returns a new Mesh
  33531. */
  33532. static CreatePolyhedron(name: string, options: {
  33533. type?: number;
  33534. size?: number;
  33535. sizeX?: number;
  33536. sizeY?: number;
  33537. sizeZ?: number;
  33538. custom?: any;
  33539. faceUV?: Vector4[];
  33540. faceColors?: Color4[];
  33541. updatable?: boolean;
  33542. sideOrientation?: number;
  33543. }, scene: Scene): Mesh;
  33544. /**
  33545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33547. * * 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`)
  33548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33549. * * 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
  33550. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33551. * * 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
  33552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33553. * @param name defines the name of the mesh
  33554. * @param options defines the options used to create the mesh
  33555. * @param scene defines the hosting scene
  33556. * @returns a new Mesh
  33557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33558. */
  33559. static CreateIcoSphere(name: string, options: {
  33560. radius?: number;
  33561. flat?: boolean;
  33562. subdivisions?: number;
  33563. sideOrientation?: number;
  33564. updatable?: boolean;
  33565. }, scene: Scene): Mesh;
  33566. /**
  33567. * Creates a decal mesh.
  33568. * Please consider using the same method from the MeshBuilder class instead.
  33569. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33570. * @param name defines the name of the mesh
  33571. * @param sourceMesh defines the mesh receiving the decal
  33572. * @param position sets the position of the decal in world coordinates
  33573. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33574. * @param size sets the decal scaling
  33575. * @param angle sets the angle to rotate the decal
  33576. * @returns a new Mesh
  33577. */
  33578. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33579. /** Creates a Capsule Mesh
  33580. * @param name defines the name of the mesh.
  33581. * @param options the constructors options used to shape the mesh.
  33582. * @param scene defines the scene the mesh is scoped to.
  33583. * @returns the capsule mesh
  33584. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33585. */
  33586. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33587. /**
  33588. * Prepare internal position array for software CPU skinning
  33589. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33590. */
  33591. setPositionsForCPUSkinning(): Float32Array;
  33592. /**
  33593. * Prepare internal normal array for software CPU skinning
  33594. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33595. */
  33596. setNormalsForCPUSkinning(): Float32Array;
  33597. /**
  33598. * Updates the vertex buffer by applying transformation from the bones
  33599. * @param skeleton defines the skeleton to apply to current mesh
  33600. * @returns the current mesh
  33601. */
  33602. applySkeleton(skeleton: Skeleton): Mesh;
  33603. /**
  33604. * 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
  33605. * @param meshes defines the list of meshes to scan
  33606. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33607. */
  33608. static MinMax(meshes: AbstractMesh[]): {
  33609. min: Vector3;
  33610. max: Vector3;
  33611. };
  33612. /**
  33613. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33614. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33615. * @returns a vector3
  33616. */
  33617. static Center(meshesOrMinMaxVector: {
  33618. min: Vector3;
  33619. max: Vector3;
  33620. } | AbstractMesh[]): Vector3;
  33621. /**
  33622. * Merge the array of meshes into a single mesh for performance reasons.
  33623. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33624. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33625. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33626. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33627. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33628. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33629. * @returns a new mesh
  33630. */
  33631. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33632. /** @hidden */
  33633. addInstance(instance: InstancedMesh): void;
  33634. /** @hidden */
  33635. removeInstance(instance: InstancedMesh): void;
  33636. }
  33637. }
  33638. declare module BABYLON {
  33639. /**
  33640. * This is the base class of all the camera used in the application.
  33641. * @see https://doc.babylonjs.com/features/cameras
  33642. */
  33643. export class Camera extends Node {
  33644. /** @hidden */
  33645. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33646. /**
  33647. * This is the default projection mode used by the cameras.
  33648. * It helps recreating a feeling of perspective and better appreciate depth.
  33649. * This is the best way to simulate real life cameras.
  33650. */
  33651. static readonly PERSPECTIVE_CAMERA: number;
  33652. /**
  33653. * This helps creating camera with an orthographic mode.
  33654. * 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.
  33655. */
  33656. static readonly ORTHOGRAPHIC_CAMERA: number;
  33657. /**
  33658. * This is the default FOV mode for perspective cameras.
  33659. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33660. */
  33661. static readonly FOVMODE_VERTICAL_FIXED: number;
  33662. /**
  33663. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33664. */
  33665. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33666. /**
  33667. * This specifies ther is no need for a camera rig.
  33668. * Basically only one eye is rendered corresponding to the camera.
  33669. */
  33670. static readonly RIG_MODE_NONE: number;
  33671. /**
  33672. * Simulates a camera Rig with one blue eye and one red eye.
  33673. * This can be use with 3d blue and red glasses.
  33674. */
  33675. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33676. /**
  33677. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33678. */
  33679. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33680. /**
  33681. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33682. */
  33683. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33684. /**
  33685. * Defines that both eyes of the camera will be rendered over under each other.
  33686. */
  33687. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33688. /**
  33689. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33690. */
  33691. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33692. /**
  33693. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33694. */
  33695. static readonly RIG_MODE_VR: number;
  33696. /**
  33697. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33698. */
  33699. static readonly RIG_MODE_WEBVR: number;
  33700. /**
  33701. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33702. */
  33703. static readonly RIG_MODE_CUSTOM: number;
  33704. /**
  33705. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33706. */
  33707. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33708. /**
  33709. * Define the input manager associated with the camera.
  33710. */
  33711. inputs: CameraInputsManager<Camera>;
  33712. /** @hidden */
  33713. _position: Vector3;
  33714. /**
  33715. * Define the current local position of the camera in the scene
  33716. */
  33717. get position(): Vector3;
  33718. set position(newPosition: Vector3);
  33719. protected _upVector: Vector3;
  33720. /**
  33721. * The vector the camera should consider as up.
  33722. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33723. */
  33724. set upVector(vec: Vector3);
  33725. get upVector(): Vector3;
  33726. /**
  33727. * Define the current limit on the left side for an orthographic camera
  33728. * In scene unit
  33729. */
  33730. orthoLeft: Nullable<number>;
  33731. /**
  33732. * Define the current limit on the right side for an orthographic camera
  33733. * In scene unit
  33734. */
  33735. orthoRight: Nullable<number>;
  33736. /**
  33737. * Define the current limit on the bottom side for an orthographic camera
  33738. * In scene unit
  33739. */
  33740. orthoBottom: Nullable<number>;
  33741. /**
  33742. * Define the current limit on the top side for an orthographic camera
  33743. * In scene unit
  33744. */
  33745. orthoTop: Nullable<number>;
  33746. /**
  33747. * Field Of View is set in Radians. (default is 0.8)
  33748. */
  33749. fov: number;
  33750. /**
  33751. * Define the minimum distance the camera can see from.
  33752. * This is important to note that the depth buffer are not infinite and the closer it starts
  33753. * the more your scene might encounter depth fighting issue.
  33754. */
  33755. minZ: number;
  33756. /**
  33757. * Define the maximum distance the camera can see to.
  33758. * This is important to note that the depth buffer are not infinite and the further it end
  33759. * the more your scene might encounter depth fighting issue.
  33760. */
  33761. maxZ: number;
  33762. /**
  33763. * Define the default inertia of the camera.
  33764. * This helps giving a smooth feeling to the camera movement.
  33765. */
  33766. inertia: number;
  33767. /**
  33768. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33769. */
  33770. mode: number;
  33771. /**
  33772. * Define whether the camera is intermediate.
  33773. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33774. */
  33775. isIntermediate: boolean;
  33776. /**
  33777. * Define the viewport of the camera.
  33778. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33779. */
  33780. viewport: Viewport;
  33781. /**
  33782. * Restricts the camera to viewing objects with the same layerMask.
  33783. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33784. */
  33785. layerMask: number;
  33786. /**
  33787. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33788. */
  33789. fovMode: number;
  33790. /**
  33791. * Rig mode of the camera.
  33792. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33793. * This is normally controlled byt the camera themselves as internal use.
  33794. */
  33795. cameraRigMode: number;
  33796. /**
  33797. * Defines the distance between both "eyes" in case of a RIG
  33798. */
  33799. interaxialDistance: number;
  33800. /**
  33801. * Defines if stereoscopic rendering is done side by side or over under.
  33802. */
  33803. isStereoscopicSideBySide: boolean;
  33804. /**
  33805. * 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
  33806. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33807. * else in the scene. (Eg. security camera)
  33808. *
  33809. * 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)
  33810. */
  33811. customRenderTargets: RenderTargetTexture[];
  33812. /**
  33813. * When set, the camera will render to this render target instead of the default canvas
  33814. *
  33815. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33816. */
  33817. outputRenderTarget: Nullable<RenderTargetTexture>;
  33818. /**
  33819. * Observable triggered when the camera view matrix has changed.
  33820. */
  33821. onViewMatrixChangedObservable: Observable<Camera>;
  33822. /**
  33823. * Observable triggered when the camera Projection matrix has changed.
  33824. */
  33825. onProjectionMatrixChangedObservable: Observable<Camera>;
  33826. /**
  33827. * Observable triggered when the inputs have been processed.
  33828. */
  33829. onAfterCheckInputsObservable: Observable<Camera>;
  33830. /**
  33831. * Observable triggered when reset has been called and applied to the camera.
  33832. */
  33833. onRestoreStateObservable: Observable<Camera>;
  33834. /**
  33835. * Is this camera a part of a rig system?
  33836. */
  33837. isRigCamera: boolean;
  33838. /**
  33839. * If isRigCamera set to true this will be set with the parent camera.
  33840. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33841. */
  33842. rigParent?: Camera;
  33843. /** @hidden */
  33844. _cameraRigParams: any;
  33845. /** @hidden */
  33846. _rigCameras: Camera[];
  33847. /** @hidden */
  33848. _rigPostProcess: Nullable<PostProcess>;
  33849. protected _webvrViewMatrix: Matrix;
  33850. /** @hidden */
  33851. _skipRendering: boolean;
  33852. /** @hidden */
  33853. _projectionMatrix: Matrix;
  33854. /** @hidden */
  33855. _postProcesses: Nullable<PostProcess>[];
  33856. /** @hidden */
  33857. _activeMeshes: SmartArray<AbstractMesh>;
  33858. protected _globalPosition: Vector3;
  33859. /** @hidden */
  33860. _computedViewMatrix: Matrix;
  33861. private _doNotComputeProjectionMatrix;
  33862. private _transformMatrix;
  33863. private _frustumPlanes;
  33864. private _refreshFrustumPlanes;
  33865. private _storedFov;
  33866. private _stateStored;
  33867. /**
  33868. * Instantiates a new camera object.
  33869. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33870. * @see https://doc.babylonjs.com/features/cameras
  33871. * @param name Defines the name of the camera in the scene
  33872. * @param position Defines the position of the camera
  33873. * @param scene Defines the scene the camera belongs too
  33874. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33875. */
  33876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33877. /**
  33878. * Store current camera state (fov, position, etc..)
  33879. * @returns the camera
  33880. */
  33881. storeState(): Camera;
  33882. /**
  33883. * Restores the camera state values if it has been stored. You must call storeState() first
  33884. */
  33885. protected _restoreStateValues(): boolean;
  33886. /**
  33887. * Restored camera state. You must call storeState() first.
  33888. * @returns true if restored and false otherwise
  33889. */
  33890. restoreState(): boolean;
  33891. /**
  33892. * Gets the class name of the camera.
  33893. * @returns the class name
  33894. */
  33895. getClassName(): string;
  33896. /** @hidden */
  33897. readonly _isCamera: boolean;
  33898. /**
  33899. * Gets a string representation of the camera useful for debug purpose.
  33900. * @param fullDetails Defines that a more verboe level of logging is required
  33901. * @returns the string representation
  33902. */
  33903. toString(fullDetails?: boolean): string;
  33904. /**
  33905. * Gets the current world space position of the camera.
  33906. */
  33907. get globalPosition(): Vector3;
  33908. /**
  33909. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33910. * @returns the active meshe list
  33911. */
  33912. getActiveMeshes(): SmartArray<AbstractMesh>;
  33913. /**
  33914. * Check whether a mesh is part of the current active mesh list of the camera
  33915. * @param mesh Defines the mesh to check
  33916. * @returns true if active, false otherwise
  33917. */
  33918. isActiveMesh(mesh: Mesh): boolean;
  33919. /**
  33920. * Is this camera ready to be used/rendered
  33921. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33922. * @return true if the camera is ready
  33923. */
  33924. isReady(completeCheck?: boolean): boolean;
  33925. /** @hidden */
  33926. _initCache(): void;
  33927. /** @hidden */
  33928. _updateCache(ignoreParentClass?: boolean): void;
  33929. /** @hidden */
  33930. _isSynchronized(): boolean;
  33931. /** @hidden */
  33932. _isSynchronizedViewMatrix(): boolean;
  33933. /** @hidden */
  33934. _isSynchronizedProjectionMatrix(): boolean;
  33935. /**
  33936. * Attach the input controls to a specific dom element to get the input from.
  33937. * @param element Defines the element the controls should be listened from
  33938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33939. */
  33940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33941. /**
  33942. * Detach the current controls from the specified dom element.
  33943. * @param element Defines the element to stop listening the inputs from
  33944. */
  33945. detachControl(element: HTMLElement): void;
  33946. /**
  33947. * Update the camera state according to the different inputs gathered during the frame.
  33948. */
  33949. update(): void;
  33950. /** @hidden */
  33951. _checkInputs(): void;
  33952. /** @hidden */
  33953. get rigCameras(): Camera[];
  33954. /**
  33955. * Gets the post process used by the rig cameras
  33956. */
  33957. get rigPostProcess(): Nullable<PostProcess>;
  33958. /**
  33959. * Internal, gets the first post proces.
  33960. * @returns the first post process to be run on this camera.
  33961. */
  33962. _getFirstPostProcess(): Nullable<PostProcess>;
  33963. private _cascadePostProcessesToRigCams;
  33964. /**
  33965. * Attach a post process to the camera.
  33966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33967. * @param postProcess The post process to attach to the camera
  33968. * @param insertAt The position of the post process in case several of them are in use in the scene
  33969. * @returns the position the post process has been inserted at
  33970. */
  33971. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33972. /**
  33973. * Detach a post process to the camera.
  33974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33975. * @param postProcess The post process to detach from the camera
  33976. */
  33977. detachPostProcess(postProcess: PostProcess): void;
  33978. /**
  33979. * Gets the current world matrix of the camera
  33980. */
  33981. getWorldMatrix(): Matrix;
  33982. /** @hidden */
  33983. _getViewMatrix(): Matrix;
  33984. /**
  33985. * Gets the current view matrix of the camera.
  33986. * @param force forces the camera to recompute the matrix without looking at the cached state
  33987. * @returns the view matrix
  33988. */
  33989. getViewMatrix(force?: boolean): Matrix;
  33990. /**
  33991. * Freeze the projection matrix.
  33992. * It will prevent the cache check of the camera projection compute and can speed up perf
  33993. * if no parameter of the camera are meant to change
  33994. * @param projection Defines manually a projection if necessary
  33995. */
  33996. freezeProjectionMatrix(projection?: Matrix): void;
  33997. /**
  33998. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  33999. */
  34000. unfreezeProjectionMatrix(): void;
  34001. /**
  34002. * Gets the current projection matrix of the camera.
  34003. * @param force forces the camera to recompute the matrix without looking at the cached state
  34004. * @returns the projection matrix
  34005. */
  34006. getProjectionMatrix(force?: boolean): Matrix;
  34007. /**
  34008. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34009. * @returns a Matrix
  34010. */
  34011. getTransformationMatrix(): Matrix;
  34012. private _updateFrustumPlanes;
  34013. /**
  34014. * Checks if a cullable object (mesh...) is in the camera frustum
  34015. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34016. * @param target The object to check
  34017. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34018. * @returns true if the object is in frustum otherwise false
  34019. */
  34020. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34021. /**
  34022. * Checks if a cullable object (mesh...) is in the camera frustum
  34023. * Unlike isInFrustum this cheks the full bounding box
  34024. * @param target The object to check
  34025. * @returns true if the object is in frustum otherwise false
  34026. */
  34027. isCompletelyInFrustum(target: ICullable): boolean;
  34028. /**
  34029. * Gets a ray in the forward direction from the camera.
  34030. * @param length Defines the length of the ray to create
  34031. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34032. * @param origin Defines the start point of the ray which defaults to the camera position
  34033. * @returns the forward ray
  34034. */
  34035. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34036. /**
  34037. * Gets a ray in the forward direction from the camera.
  34038. * @param refRay the ray to (re)use when setting the values
  34039. * @param length Defines the length of the ray to create
  34040. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34041. * @param origin Defines the start point of the ray which defaults to the camera position
  34042. * @returns the forward ray
  34043. */
  34044. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34045. /**
  34046. * Releases resources associated with this node.
  34047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34049. */
  34050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34051. /** @hidden */
  34052. _isLeftCamera: boolean;
  34053. /**
  34054. * Gets the left camera of a rig setup in case of Rigged Camera
  34055. */
  34056. get isLeftCamera(): boolean;
  34057. /** @hidden */
  34058. _isRightCamera: boolean;
  34059. /**
  34060. * Gets the right camera of a rig setup in case of Rigged Camera
  34061. */
  34062. get isRightCamera(): boolean;
  34063. /**
  34064. * Gets the left camera of a rig setup in case of Rigged Camera
  34065. */
  34066. get leftCamera(): Nullable<FreeCamera>;
  34067. /**
  34068. * Gets the right camera of a rig setup in case of Rigged Camera
  34069. */
  34070. get rightCamera(): Nullable<FreeCamera>;
  34071. /**
  34072. * Gets the left camera target of a rig setup in case of Rigged Camera
  34073. * @returns the target position
  34074. */
  34075. getLeftTarget(): Nullable<Vector3>;
  34076. /**
  34077. * Gets the right camera target of a rig setup in case of Rigged Camera
  34078. * @returns the target position
  34079. */
  34080. getRightTarget(): Nullable<Vector3>;
  34081. /**
  34082. * @hidden
  34083. */
  34084. setCameraRigMode(mode: number, rigParams: any): void;
  34085. /** @hidden */
  34086. static _setStereoscopicRigMode(camera: Camera): void;
  34087. /** @hidden */
  34088. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34089. /** @hidden */
  34090. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34091. /** @hidden */
  34092. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34093. /** @hidden */
  34094. _getVRProjectionMatrix(): Matrix;
  34095. protected _updateCameraRotationMatrix(): void;
  34096. protected _updateWebVRCameraRotationMatrix(): void;
  34097. /**
  34098. * This function MUST be overwritten by the different WebVR cameras available.
  34099. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34100. * @hidden
  34101. */
  34102. _getWebVRProjectionMatrix(): Matrix;
  34103. /**
  34104. * This function MUST be overwritten by the different WebVR cameras available.
  34105. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34106. * @hidden
  34107. */
  34108. _getWebVRViewMatrix(): Matrix;
  34109. /** @hidden */
  34110. setCameraRigParameter(name: string, value: any): void;
  34111. /**
  34112. * needs to be overridden by children so sub has required properties to be copied
  34113. * @hidden
  34114. */
  34115. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34116. /**
  34117. * May need to be overridden by children
  34118. * @hidden
  34119. */
  34120. _updateRigCameras(): void;
  34121. /** @hidden */
  34122. _setupInputs(): void;
  34123. /**
  34124. * Serialiaze the camera setup to a json represention
  34125. * @returns the JSON representation
  34126. */
  34127. serialize(): any;
  34128. /**
  34129. * Clones the current camera.
  34130. * @param name The cloned camera name
  34131. * @returns the cloned camera
  34132. */
  34133. clone(name: string): Camera;
  34134. /**
  34135. * Gets the direction of the camera relative to a given local axis.
  34136. * @param localAxis Defines the reference axis to provide a relative direction.
  34137. * @return the direction
  34138. */
  34139. getDirection(localAxis: Vector3): Vector3;
  34140. /**
  34141. * Returns the current camera absolute rotation
  34142. */
  34143. get absoluteRotation(): Quaternion;
  34144. /**
  34145. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34146. * @param localAxis Defines the reference axis to provide a relative direction.
  34147. * @param result Defines the vector to store the result in
  34148. */
  34149. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34150. /**
  34151. * Gets a camera constructor for a given camera type
  34152. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34153. * @param name The name of the camera the result will be able to instantiate
  34154. * @param scene The scene the result will construct the camera in
  34155. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34156. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34157. * @returns a factory method to construc the camera
  34158. */
  34159. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34160. /**
  34161. * Compute the world matrix of the camera.
  34162. * @returns the camera world matrix
  34163. */
  34164. computeWorldMatrix(): Matrix;
  34165. /**
  34166. * Parse a JSON and creates the camera from the parsed information
  34167. * @param parsedCamera The JSON to parse
  34168. * @param scene The scene to instantiate the camera in
  34169. * @returns the newly constructed camera
  34170. */
  34171. static Parse(parsedCamera: any, scene: Scene): Camera;
  34172. }
  34173. }
  34174. declare module BABYLON {
  34175. /**
  34176. * Class containing static functions to help procedurally build meshes
  34177. */
  34178. export class DiscBuilder {
  34179. /**
  34180. * Creates a plane polygonal mesh. By default, this is a disc
  34181. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34182. * * 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
  34183. * * 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
  34184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34185. * * 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
  34186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34187. * @param name defines the name of the mesh
  34188. * @param options defines the options used to create the mesh
  34189. * @param scene defines the hosting scene
  34190. * @returns the plane polygonal mesh
  34191. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34192. */
  34193. static CreateDisc(name: string, options: {
  34194. radius?: number;
  34195. tessellation?: number;
  34196. arc?: number;
  34197. updatable?: boolean;
  34198. sideOrientation?: number;
  34199. frontUVs?: Vector4;
  34200. backUVs?: Vector4;
  34201. }, scene?: Nullable<Scene>): Mesh;
  34202. }
  34203. }
  34204. declare module BABYLON {
  34205. /**
  34206. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34207. *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.
  34208. * The SPS is also a particle system. It provides some methods to manage the particles.
  34209. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34210. *
  34211. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34212. */
  34213. export class SolidParticleSystem implements IDisposable {
  34214. /**
  34215. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34216. * Example : var p = SPS.particles[i];
  34217. */
  34218. particles: SolidParticle[];
  34219. /**
  34220. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34221. */
  34222. nbParticles: number;
  34223. /**
  34224. * If the particles must ever face the camera (default false). Useful for planar particles.
  34225. */
  34226. billboard: boolean;
  34227. /**
  34228. * Recompute normals when adding a shape
  34229. */
  34230. recomputeNormals: boolean;
  34231. /**
  34232. * This a counter ofr your own usage. It's not set by any SPS functions.
  34233. */
  34234. counter: number;
  34235. /**
  34236. * The SPS name. This name is also given to the underlying mesh.
  34237. */
  34238. name: string;
  34239. /**
  34240. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34241. */
  34242. mesh: Mesh;
  34243. /**
  34244. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34245. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34246. */
  34247. vars: any;
  34248. /**
  34249. * This array is populated when the SPS is set as 'pickable'.
  34250. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34251. * Each element of this array is an object `{idx: int, faceId: int}`.
  34252. * `idx` is the picked particle index in the `SPS.particles` array
  34253. * `faceId` is the picked face index counted within this particle.
  34254. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34255. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34256. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34257. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34258. */
  34259. pickedParticles: {
  34260. idx: number;
  34261. faceId: number;
  34262. }[];
  34263. /**
  34264. * This array is populated when the SPS is set as 'pickable'
  34265. * Each key of this array is a submesh index.
  34266. * Each element of this array is a second array defined like this :
  34267. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34268. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34269. * `idx` is the picked particle index in the `SPS.particles` array
  34270. * `faceId` is the picked face index counted within this particle.
  34271. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34272. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34273. */
  34274. pickedBySubMesh: {
  34275. idx: number;
  34276. faceId: number;
  34277. }[][];
  34278. /**
  34279. * This array is populated when `enableDepthSort` is set to true.
  34280. * Each element of this array is an instance of the class DepthSortedParticle.
  34281. */
  34282. depthSortedParticles: DepthSortedParticle[];
  34283. /**
  34284. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34285. * @hidden
  34286. */
  34287. _bSphereOnly: boolean;
  34288. /**
  34289. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34290. * @hidden
  34291. */
  34292. _bSphereRadiusFactor: number;
  34293. private _scene;
  34294. private _positions;
  34295. private _indices;
  34296. private _normals;
  34297. private _colors;
  34298. private _uvs;
  34299. private _indices32;
  34300. private _positions32;
  34301. private _normals32;
  34302. private _fixedNormal32;
  34303. private _colors32;
  34304. private _uvs32;
  34305. private _index;
  34306. private _updatable;
  34307. private _pickable;
  34308. private _isVisibilityBoxLocked;
  34309. private _alwaysVisible;
  34310. private _depthSort;
  34311. private _expandable;
  34312. private _shapeCounter;
  34313. private _copy;
  34314. private _color;
  34315. private _computeParticleColor;
  34316. private _computeParticleTexture;
  34317. private _computeParticleRotation;
  34318. private _computeParticleVertex;
  34319. private _computeBoundingBox;
  34320. private _depthSortParticles;
  34321. private _camera;
  34322. private _mustUnrotateFixedNormals;
  34323. private _particlesIntersect;
  34324. private _needs32Bits;
  34325. private _isNotBuilt;
  34326. private _lastParticleId;
  34327. private _idxOfId;
  34328. private _multimaterialEnabled;
  34329. private _useModelMaterial;
  34330. private _indicesByMaterial;
  34331. private _materialIndexes;
  34332. private _depthSortFunction;
  34333. private _materialSortFunction;
  34334. private _materials;
  34335. private _multimaterial;
  34336. private _materialIndexesById;
  34337. private _defaultMaterial;
  34338. private _autoUpdateSubMeshes;
  34339. private _tmpVertex;
  34340. /**
  34341. * Creates a SPS (Solid Particle System) object.
  34342. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34343. * @param scene (Scene) is the scene in which the SPS is added.
  34344. * @param options defines the options of the sps e.g.
  34345. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34346. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34347. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34348. * * 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.
  34349. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34350. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34351. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34352. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34353. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34354. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34355. */
  34356. constructor(name: string, scene: Scene, options?: {
  34357. updatable?: boolean;
  34358. isPickable?: boolean;
  34359. enableDepthSort?: boolean;
  34360. particleIntersection?: boolean;
  34361. boundingSphereOnly?: boolean;
  34362. bSphereRadiusFactor?: number;
  34363. expandable?: boolean;
  34364. useModelMaterial?: boolean;
  34365. enableMultiMaterial?: boolean;
  34366. });
  34367. /**
  34368. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34369. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34370. * @returns the created mesh
  34371. */
  34372. buildMesh(): Mesh;
  34373. /**
  34374. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34375. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34376. * Thus the particles generated from `digest()` have their property `position` set yet.
  34377. * @param mesh ( Mesh ) is the mesh to be digested
  34378. * @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
  34379. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34380. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34381. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34382. * @returns the current SPS
  34383. */
  34384. digest(mesh: Mesh, options?: {
  34385. facetNb?: number;
  34386. number?: number;
  34387. delta?: number;
  34388. storage?: [];
  34389. }): SolidParticleSystem;
  34390. /**
  34391. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34392. * @hidden
  34393. */
  34394. private _unrotateFixedNormals;
  34395. /**
  34396. * Resets the temporary working copy particle
  34397. * @hidden
  34398. */
  34399. private _resetCopy;
  34400. /**
  34401. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34402. * @param p the current index in the positions array to be updated
  34403. * @param ind the current index in the indices array
  34404. * @param shape a Vector3 array, the shape geometry
  34405. * @param positions the positions array to be updated
  34406. * @param meshInd the shape indices array
  34407. * @param indices the indices array to be updated
  34408. * @param meshUV the shape uv array
  34409. * @param uvs the uv array to be updated
  34410. * @param meshCol the shape color array
  34411. * @param colors the color array to be updated
  34412. * @param meshNor the shape normals array
  34413. * @param normals the normals array to be updated
  34414. * @param idx the particle index
  34415. * @param idxInShape the particle index in its shape
  34416. * @param options the addShape() method passed options
  34417. * @model the particle model
  34418. * @hidden
  34419. */
  34420. private _meshBuilder;
  34421. /**
  34422. * Returns a shape Vector3 array from positions float array
  34423. * @param positions float array
  34424. * @returns a vector3 array
  34425. * @hidden
  34426. */
  34427. private _posToShape;
  34428. /**
  34429. * Returns a shapeUV array from a float uvs (array deep copy)
  34430. * @param uvs as a float array
  34431. * @returns a shapeUV array
  34432. * @hidden
  34433. */
  34434. private _uvsToShapeUV;
  34435. /**
  34436. * Adds a new particle object in the particles array
  34437. * @param idx particle index in particles array
  34438. * @param id particle id
  34439. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34440. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34441. * @param model particle ModelShape object
  34442. * @param shapeId model shape identifier
  34443. * @param idxInShape index of the particle in the current model
  34444. * @param bInfo model bounding info object
  34445. * @param storage target storage array, if any
  34446. * @hidden
  34447. */
  34448. private _addParticle;
  34449. /**
  34450. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34451. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34452. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34453. * @param nb (positive integer) the number of particles to be created from this model
  34454. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34455. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34456. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34457. * @returns the number of shapes in the system
  34458. */
  34459. addShape(mesh: Mesh, nb: number, options?: {
  34460. positionFunction?: any;
  34461. vertexFunction?: any;
  34462. storage?: [];
  34463. }): number;
  34464. /**
  34465. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34466. * @hidden
  34467. */
  34468. private _rebuildParticle;
  34469. /**
  34470. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34471. * @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.
  34472. * @returns the SPS.
  34473. */
  34474. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34475. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34476. * Returns an array with the removed particles.
  34477. * 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.
  34478. * The SPS can't be empty so at least one particle needs to remain in place.
  34479. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34480. * @param start index of the first particle to remove
  34481. * @param end index of the last particle to remove (included)
  34482. * @returns an array populated with the removed particles
  34483. */
  34484. removeParticles(start: number, end: number): SolidParticle[];
  34485. /**
  34486. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34487. * @param solidParticleArray an array populated with Solid Particles objects
  34488. * @returns the SPS
  34489. */
  34490. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34491. /**
  34492. * Creates a new particle and modifies the SPS mesh geometry :
  34493. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34494. * - calls _addParticle() to populate the particle array
  34495. * factorized code from addShape() and insertParticlesFromArray()
  34496. * @param idx particle index in the particles array
  34497. * @param i particle index in its shape
  34498. * @param modelShape particle ModelShape object
  34499. * @param shape shape vertex array
  34500. * @param meshInd shape indices array
  34501. * @param meshUV shape uv array
  34502. * @param meshCol shape color array
  34503. * @param meshNor shape normals array
  34504. * @param bbInfo shape bounding info
  34505. * @param storage target particle storage
  34506. * @options addShape() passed options
  34507. * @hidden
  34508. */
  34509. private _insertNewParticle;
  34510. /**
  34511. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34512. * This method calls `updateParticle()` for each particle of the SPS.
  34513. * For an animated SPS, it is usually called within the render loop.
  34514. * 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.
  34515. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34516. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34517. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34518. * @returns the SPS.
  34519. */
  34520. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34521. /**
  34522. * Disposes the SPS.
  34523. */
  34524. dispose(): void;
  34525. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34526. * idx is the particle index in the SPS
  34527. * faceId is the picked face index counted within this particle.
  34528. * Returns null if the pickInfo can't identify a picked particle.
  34529. * @param pickingInfo (PickingInfo object)
  34530. * @returns {idx: number, faceId: number} or null
  34531. */
  34532. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34533. idx: number;
  34534. faceId: number;
  34535. }>;
  34536. /**
  34537. * Returns a SolidParticle object from its identifier : particle.id
  34538. * @param id (integer) the particle Id
  34539. * @returns the searched particle or null if not found in the SPS.
  34540. */
  34541. getParticleById(id: number): Nullable<SolidParticle>;
  34542. /**
  34543. * Returns a new array populated with the particles having the passed shapeId.
  34544. * @param shapeId (integer) the shape identifier
  34545. * @returns a new solid particle array
  34546. */
  34547. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34548. /**
  34549. * Populates the passed array "ref" with the particles having the passed shapeId.
  34550. * @param shapeId the shape identifier
  34551. * @returns the SPS
  34552. * @param ref
  34553. */
  34554. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34555. /**
  34556. * Computes the required SubMeshes according the materials assigned to the particles.
  34557. * @returns the solid particle system.
  34558. * Does nothing if called before the SPS mesh is built.
  34559. */
  34560. computeSubMeshes(): SolidParticleSystem;
  34561. /**
  34562. * Sorts the solid particles by material when MultiMaterial is enabled.
  34563. * Updates the indices32 array.
  34564. * Updates the indicesByMaterial array.
  34565. * Updates the mesh indices array.
  34566. * @returns the SPS
  34567. * @hidden
  34568. */
  34569. private _sortParticlesByMaterial;
  34570. /**
  34571. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34572. * @hidden
  34573. */
  34574. private _setMaterialIndexesById;
  34575. /**
  34576. * Returns an array with unique values of Materials from the passed array
  34577. * @param array the material array to be checked and filtered
  34578. * @hidden
  34579. */
  34580. private _filterUniqueMaterialId;
  34581. /**
  34582. * Sets a new Standard Material as _defaultMaterial if not already set.
  34583. * @hidden
  34584. */
  34585. private _setDefaultMaterial;
  34586. /**
  34587. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34588. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34589. * @returns the SPS.
  34590. */
  34591. refreshVisibleSize(): SolidParticleSystem;
  34592. /**
  34593. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34594. * @param size the size (float) of the visibility box
  34595. * note : this doesn't lock the SPS mesh bounding box.
  34596. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34597. */
  34598. setVisibilityBox(size: number): void;
  34599. /**
  34600. * Gets whether the SPS as always visible or not
  34601. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34602. */
  34603. get isAlwaysVisible(): boolean;
  34604. /**
  34605. * Sets the SPS as always visible or not
  34606. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34607. */
  34608. set isAlwaysVisible(val: boolean);
  34609. /**
  34610. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34611. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34612. */
  34613. set isVisibilityBoxLocked(val: boolean);
  34614. /**
  34615. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34616. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34617. */
  34618. get isVisibilityBoxLocked(): boolean;
  34619. /**
  34620. * Tells to `setParticles()` to compute the particle rotations or not.
  34621. * Default value : true. The SPS is faster when it's set to false.
  34622. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34623. */
  34624. set computeParticleRotation(val: boolean);
  34625. /**
  34626. * Tells to `setParticles()` to compute the particle colors or not.
  34627. * Default value : true. The SPS is faster when it's set to false.
  34628. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34629. */
  34630. set computeParticleColor(val: boolean);
  34631. set computeParticleTexture(val: boolean);
  34632. /**
  34633. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34634. * Default value : false. The SPS is faster when it's set to false.
  34635. * Note : the particle custom vertex positions aren't stored values.
  34636. */
  34637. set computeParticleVertex(val: boolean);
  34638. /**
  34639. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34640. */
  34641. set computeBoundingBox(val: boolean);
  34642. /**
  34643. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34645. * Default : `true`
  34646. */
  34647. set depthSortParticles(val: boolean);
  34648. /**
  34649. * Gets if `setParticles()` computes the particle rotations or not.
  34650. * Default value : true. The SPS is faster when it's set to false.
  34651. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34652. */
  34653. get computeParticleRotation(): boolean;
  34654. /**
  34655. * Gets if `setParticles()` computes the particle colors or not.
  34656. * Default value : true. The SPS is faster when it's set to false.
  34657. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34658. */
  34659. get computeParticleColor(): boolean;
  34660. /**
  34661. * Gets if `setParticles()` computes the particle textures or not.
  34662. * Default value : true. The SPS is faster when it's set to false.
  34663. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34664. */
  34665. get computeParticleTexture(): boolean;
  34666. /**
  34667. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34668. * Default value : false. The SPS is faster when it's set to false.
  34669. * Note : the particle custom vertex positions aren't stored values.
  34670. */
  34671. get computeParticleVertex(): boolean;
  34672. /**
  34673. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34674. */
  34675. get computeBoundingBox(): boolean;
  34676. /**
  34677. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34678. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34679. * Default : `true`
  34680. */
  34681. get depthSortParticles(): boolean;
  34682. /**
  34683. * Gets if the SPS is created as expandable at construction time.
  34684. * Default : `false`
  34685. */
  34686. get expandable(): boolean;
  34687. /**
  34688. * Gets if the SPS supports the Multi Materials
  34689. */
  34690. get multimaterialEnabled(): boolean;
  34691. /**
  34692. * Gets if the SPS uses the model materials for its own multimaterial.
  34693. */
  34694. get useModelMaterial(): boolean;
  34695. /**
  34696. * The SPS used material array.
  34697. */
  34698. get materials(): Material[];
  34699. /**
  34700. * Sets the SPS MultiMaterial from the passed materials.
  34701. * Note : the passed array is internally copied and not used then by reference.
  34702. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34703. */
  34704. setMultiMaterial(materials: Material[]): void;
  34705. /**
  34706. * The SPS computed multimaterial object
  34707. */
  34708. get multimaterial(): MultiMaterial;
  34709. set multimaterial(mm: MultiMaterial);
  34710. /**
  34711. * If the subMeshes must be updated on the next call to setParticles()
  34712. */
  34713. get autoUpdateSubMeshes(): boolean;
  34714. set autoUpdateSubMeshes(val: boolean);
  34715. /**
  34716. * This function does nothing. It may be overwritten to set all the particle first values.
  34717. * The SPS doesn't call this function, you may have to call it by your own.
  34718. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34719. */
  34720. initParticles(): void;
  34721. /**
  34722. * This function does nothing. It may be overwritten to recycle a particle.
  34723. * The SPS doesn't call this function, you may have to call it by your own.
  34724. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34725. * @param particle The particle to recycle
  34726. * @returns the recycled particle
  34727. */
  34728. recycleParticle(particle: SolidParticle): SolidParticle;
  34729. /**
  34730. * Updates a particle : this function should be overwritten by the user.
  34731. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34732. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34733. * @example : just set a particle position or velocity and recycle conditions
  34734. * @param particle The particle to update
  34735. * @returns the updated particle
  34736. */
  34737. updateParticle(particle: SolidParticle): SolidParticle;
  34738. /**
  34739. * Updates a vertex of a particle : it can be overwritten by the user.
  34740. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34741. * @param particle the current particle
  34742. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34743. * @param pt the index of the current vertex in the particle shape
  34744. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34745. * @example : just set a vertex particle position or color
  34746. * @returns the sps
  34747. */
  34748. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34749. /**
  34750. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34751. * This does nothing and may be overwritten by the user.
  34752. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34753. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34754. * @param update the boolean update value actually passed to setParticles()
  34755. */
  34756. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34757. /**
  34758. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34759. * This will be passed three parameters.
  34760. * This does nothing and may be overwritten by the user.
  34761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34763. * @param update the boolean update value actually passed to setParticles()
  34764. */
  34765. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34766. }
  34767. }
  34768. declare module BABYLON {
  34769. /**
  34770. * Represents one particle of a solid particle system.
  34771. */
  34772. export class SolidParticle {
  34773. /**
  34774. * particle global index
  34775. */
  34776. idx: number;
  34777. /**
  34778. * particle identifier
  34779. */
  34780. id: number;
  34781. /**
  34782. * The color of the particle
  34783. */
  34784. color: Nullable<Color4>;
  34785. /**
  34786. * The world space position of the particle.
  34787. */
  34788. position: Vector3;
  34789. /**
  34790. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34791. */
  34792. rotation: Vector3;
  34793. /**
  34794. * The world space rotation quaternion of the particle.
  34795. */
  34796. rotationQuaternion: Nullable<Quaternion>;
  34797. /**
  34798. * The scaling of the particle.
  34799. */
  34800. scaling: Vector3;
  34801. /**
  34802. * The uvs of the particle.
  34803. */
  34804. uvs: Vector4;
  34805. /**
  34806. * The current speed of the particle.
  34807. */
  34808. velocity: Vector3;
  34809. /**
  34810. * The pivot point in the particle local space.
  34811. */
  34812. pivot: Vector3;
  34813. /**
  34814. * Must the particle be translated from its pivot point in its local space ?
  34815. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34816. * Default : false
  34817. */
  34818. translateFromPivot: boolean;
  34819. /**
  34820. * Is the particle active or not ?
  34821. */
  34822. alive: boolean;
  34823. /**
  34824. * Is the particle visible or not ?
  34825. */
  34826. isVisible: boolean;
  34827. /**
  34828. * Index of this particle in the global "positions" array (Internal use)
  34829. * @hidden
  34830. */
  34831. _pos: number;
  34832. /**
  34833. * @hidden Index of this particle in the global "indices" array (Internal use)
  34834. */
  34835. _ind: number;
  34836. /**
  34837. * @hidden ModelShape of this particle (Internal use)
  34838. */
  34839. _model: ModelShape;
  34840. /**
  34841. * ModelShape id of this particle
  34842. */
  34843. shapeId: number;
  34844. /**
  34845. * Index of the particle in its shape id
  34846. */
  34847. idxInShape: number;
  34848. /**
  34849. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34850. */
  34851. _modelBoundingInfo: BoundingInfo;
  34852. /**
  34853. * @hidden Particle BoundingInfo object (Internal use)
  34854. */
  34855. _boundingInfo: BoundingInfo;
  34856. /**
  34857. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34858. */
  34859. _sps: SolidParticleSystem;
  34860. /**
  34861. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34862. */
  34863. _stillInvisible: boolean;
  34864. /**
  34865. * @hidden Last computed particle rotation matrix
  34866. */
  34867. _rotationMatrix: number[];
  34868. /**
  34869. * Parent particle Id, if any.
  34870. * Default null.
  34871. */
  34872. parentId: Nullable<number>;
  34873. /**
  34874. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34875. */
  34876. materialIndex: Nullable<number>;
  34877. /**
  34878. * Custom object or properties.
  34879. */
  34880. props: Nullable<any>;
  34881. /**
  34882. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34883. * The possible values are :
  34884. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34885. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34887. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34888. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34889. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34890. * */
  34891. cullingStrategy: number;
  34892. /**
  34893. * @hidden Internal global position in the SPS.
  34894. */
  34895. _globalPosition: Vector3;
  34896. /**
  34897. * Creates a Solid Particle object.
  34898. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34899. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34900. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34901. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34902. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34903. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34904. * @param shapeId (integer) is the model shape identifier in the SPS.
  34905. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34906. * @param sps defines the sps it is associated to
  34907. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34908. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34909. */
  34910. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34911. /**
  34912. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34913. * @param target the particle target
  34914. * @returns the current particle
  34915. */
  34916. copyToRef(target: SolidParticle): SolidParticle;
  34917. /**
  34918. * Legacy support, changed scale to scaling
  34919. */
  34920. get scale(): Vector3;
  34921. /**
  34922. * Legacy support, changed scale to scaling
  34923. */
  34924. set scale(scale: Vector3);
  34925. /**
  34926. * Legacy support, changed quaternion to rotationQuaternion
  34927. */
  34928. get quaternion(): Nullable<Quaternion>;
  34929. /**
  34930. * Legacy support, changed quaternion to rotationQuaternion
  34931. */
  34932. set quaternion(q: Nullable<Quaternion>);
  34933. /**
  34934. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34935. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34936. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34937. * @returns true if it intersects
  34938. */
  34939. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34940. /**
  34941. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34942. * A particle is in the frustum if its bounding box intersects the frustum
  34943. * @param frustumPlanes defines the frustum to test
  34944. * @returns true if the particle is in the frustum planes
  34945. */
  34946. isInFrustum(frustumPlanes: Plane[]): boolean;
  34947. /**
  34948. * get the rotation matrix of the particle
  34949. * @hidden
  34950. */
  34951. getRotationMatrix(m: Matrix): void;
  34952. }
  34953. /**
  34954. * Represents the shape of the model used by one particle of a solid particle system.
  34955. * SPS internal tool, don't use it manually.
  34956. */
  34957. export class ModelShape {
  34958. /**
  34959. * The shape id
  34960. * @hidden
  34961. */
  34962. shapeID: number;
  34963. /**
  34964. * flat array of model positions (internal use)
  34965. * @hidden
  34966. */
  34967. _shape: Vector3[];
  34968. /**
  34969. * flat array of model UVs (internal use)
  34970. * @hidden
  34971. */
  34972. _shapeUV: number[];
  34973. /**
  34974. * color array of the model
  34975. * @hidden
  34976. */
  34977. _shapeColors: number[];
  34978. /**
  34979. * indices array of the model
  34980. * @hidden
  34981. */
  34982. _indices: number[];
  34983. /**
  34984. * normals array of the model
  34985. * @hidden
  34986. */
  34987. _normals: number[];
  34988. /**
  34989. * length of the shape in the model indices array (internal use)
  34990. * @hidden
  34991. */
  34992. _indicesLength: number;
  34993. /**
  34994. * Custom position function (internal use)
  34995. * @hidden
  34996. */
  34997. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34998. /**
  34999. * Custom vertex function (internal use)
  35000. * @hidden
  35001. */
  35002. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35003. /**
  35004. * Model material (internal use)
  35005. * @hidden
  35006. */
  35007. _material: Nullable<Material>;
  35008. /**
  35009. * 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.
  35010. * SPS internal tool, don't use it manually.
  35011. * @hidden
  35012. */
  35013. 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>);
  35014. }
  35015. /**
  35016. * Represents a Depth Sorted Particle in the solid particle system.
  35017. * @hidden
  35018. */
  35019. export class DepthSortedParticle {
  35020. /**
  35021. * Particle index
  35022. */
  35023. idx: number;
  35024. /**
  35025. * Index of the particle in the "indices" array
  35026. */
  35027. ind: number;
  35028. /**
  35029. * Length of the particle shape in the "indices" array
  35030. */
  35031. indicesLength: number;
  35032. /**
  35033. * Squared distance from the particle to the camera
  35034. */
  35035. sqDistance: number;
  35036. /**
  35037. * Material index when used with MultiMaterials
  35038. */
  35039. materialIndex: number;
  35040. /**
  35041. * Creates a new sorted particle
  35042. * @param materialIndex
  35043. */
  35044. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35045. }
  35046. /**
  35047. * Represents a solid particle vertex
  35048. */
  35049. export class SolidParticleVertex {
  35050. /**
  35051. * Vertex position
  35052. */
  35053. position: Vector3;
  35054. /**
  35055. * Vertex color
  35056. */
  35057. color: Color4;
  35058. /**
  35059. * Vertex UV
  35060. */
  35061. uv: Vector2;
  35062. /**
  35063. * Creates a new solid particle vertex
  35064. */
  35065. constructor();
  35066. /** Vertex x coordinate */
  35067. get x(): number;
  35068. set x(val: number);
  35069. /** Vertex y coordinate */
  35070. get y(): number;
  35071. set y(val: number);
  35072. /** Vertex z coordinate */
  35073. get z(): number;
  35074. set z(val: number);
  35075. }
  35076. }
  35077. declare module BABYLON {
  35078. /**
  35079. * @hidden
  35080. */
  35081. export class _MeshCollisionData {
  35082. _checkCollisions: boolean;
  35083. _collisionMask: number;
  35084. _collisionGroup: number;
  35085. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35086. _collider: Nullable<Collider>;
  35087. _oldPositionForCollisions: Vector3;
  35088. _diffPositionForCollisions: Vector3;
  35089. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35090. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35091. _collisionResponse: boolean;
  35092. }
  35093. }
  35094. declare module BABYLON {
  35095. /** @hidden */
  35096. class _FacetDataStorage {
  35097. facetPositions: Vector3[];
  35098. facetNormals: Vector3[];
  35099. facetPartitioning: number[][];
  35100. facetNb: number;
  35101. partitioningSubdivisions: number;
  35102. partitioningBBoxRatio: number;
  35103. facetDataEnabled: boolean;
  35104. facetParameters: any;
  35105. bbSize: Vector3;
  35106. subDiv: {
  35107. max: number;
  35108. X: number;
  35109. Y: number;
  35110. Z: number;
  35111. };
  35112. facetDepthSort: boolean;
  35113. facetDepthSortEnabled: boolean;
  35114. depthSortedIndices: IndicesArray;
  35115. depthSortedFacets: {
  35116. ind: number;
  35117. sqDistance: number;
  35118. }[];
  35119. facetDepthSortFunction: (f1: {
  35120. ind: number;
  35121. sqDistance: number;
  35122. }, f2: {
  35123. ind: number;
  35124. sqDistance: number;
  35125. }) => number;
  35126. facetDepthSortFrom: Vector3;
  35127. facetDepthSortOrigin: Vector3;
  35128. invertedMatrix: Matrix;
  35129. }
  35130. /**
  35131. * @hidden
  35132. **/
  35133. class _InternalAbstractMeshDataInfo {
  35134. _hasVertexAlpha: boolean;
  35135. _useVertexColors: boolean;
  35136. _numBoneInfluencers: number;
  35137. _applyFog: boolean;
  35138. _receiveShadows: boolean;
  35139. _facetData: _FacetDataStorage;
  35140. _visibility: number;
  35141. _skeleton: Nullable<Skeleton>;
  35142. _layerMask: number;
  35143. _computeBonesUsingShaders: boolean;
  35144. _isActive: boolean;
  35145. _onlyForInstances: boolean;
  35146. _isActiveIntermediate: boolean;
  35147. _onlyForInstancesIntermediate: boolean;
  35148. _actAsRegularMesh: boolean;
  35149. }
  35150. /**
  35151. * Class used to store all common mesh properties
  35152. */
  35153. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35154. /** No occlusion */
  35155. static OCCLUSION_TYPE_NONE: number;
  35156. /** Occlusion set to optimisitic */
  35157. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35158. /** Occlusion set to strict */
  35159. static OCCLUSION_TYPE_STRICT: number;
  35160. /** Use an accurante occlusion algorithm */
  35161. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35162. /** Use a conservative occlusion algorithm */
  35163. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35164. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35165. * Test order :
  35166. * Is the bounding sphere outside the frustum ?
  35167. * If not, are the bounding box vertices outside the frustum ?
  35168. * It not, then the cullable object is in the frustum.
  35169. */
  35170. static readonly CULLINGSTRATEGY_STANDARD: number;
  35171. /** Culling strategy : Bounding Sphere Only.
  35172. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35173. * It's also less accurate than the standard because some not visible objects can still be selected.
  35174. * Test : is the bounding sphere outside the frustum ?
  35175. * If not, then the cullable object is in the frustum.
  35176. */
  35177. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35178. /** Culling strategy : Optimistic Inclusion.
  35179. * This in an inclusion test first, then the standard exclusion test.
  35180. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35181. * 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.
  35182. * Anyway, it's as accurate as the standard strategy.
  35183. * Test :
  35184. * Is the cullable object bounding sphere center in the frustum ?
  35185. * If not, apply the default culling strategy.
  35186. */
  35187. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35188. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35189. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35190. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35191. * 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.
  35192. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35193. * Test :
  35194. * Is the cullable object bounding sphere center in the frustum ?
  35195. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35196. */
  35197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35198. /**
  35199. * No billboard
  35200. */
  35201. static get BILLBOARDMODE_NONE(): number;
  35202. /** Billboard on X axis */
  35203. static get BILLBOARDMODE_X(): number;
  35204. /** Billboard on Y axis */
  35205. static get BILLBOARDMODE_Y(): number;
  35206. /** Billboard on Z axis */
  35207. static get BILLBOARDMODE_Z(): number;
  35208. /** Billboard on all axes */
  35209. static get BILLBOARDMODE_ALL(): number;
  35210. /** Billboard on using position instead of orientation */
  35211. static get BILLBOARDMODE_USE_POSITION(): number;
  35212. /** @hidden */
  35213. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35214. /**
  35215. * The culling strategy to use to check whether the mesh must be rendered or not.
  35216. * This value can be changed at any time and will be used on the next render mesh selection.
  35217. * The possible values are :
  35218. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35219. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35220. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35222. * Please read each static variable documentation to get details about the culling process.
  35223. * */
  35224. cullingStrategy: number;
  35225. /**
  35226. * Gets the number of facets in the mesh
  35227. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35228. */
  35229. get facetNb(): number;
  35230. /**
  35231. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35232. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35233. */
  35234. get partitioningSubdivisions(): number;
  35235. set partitioningSubdivisions(nb: number);
  35236. /**
  35237. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35238. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35240. */
  35241. get partitioningBBoxRatio(): number;
  35242. set partitioningBBoxRatio(ratio: number);
  35243. /**
  35244. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35245. * Works only for updatable meshes.
  35246. * Doesn't work with multi-materials
  35247. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35248. */
  35249. get mustDepthSortFacets(): boolean;
  35250. set mustDepthSortFacets(sort: boolean);
  35251. /**
  35252. * The location (Vector3) where the facet depth sort must be computed from.
  35253. * By default, the active camera position.
  35254. * Used only when facet depth sort is enabled
  35255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35256. */
  35257. get facetDepthSortFrom(): Vector3;
  35258. set facetDepthSortFrom(location: Vector3);
  35259. /**
  35260. * gets a boolean indicating if facetData is enabled
  35261. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35262. */
  35263. get isFacetDataEnabled(): boolean;
  35264. /** @hidden */
  35265. _updateNonUniformScalingState(value: boolean): boolean;
  35266. /**
  35267. * An event triggered when this mesh collides with another one
  35268. */
  35269. onCollideObservable: Observable<AbstractMesh>;
  35270. /** Set a function to call when this mesh collides with another one */
  35271. set onCollide(callback: () => void);
  35272. /**
  35273. * An event triggered when the collision's position changes
  35274. */
  35275. onCollisionPositionChangeObservable: Observable<Vector3>;
  35276. /** Set a function to call when the collision's position changes */
  35277. set onCollisionPositionChange(callback: () => void);
  35278. /**
  35279. * An event triggered when material is changed
  35280. */
  35281. onMaterialChangedObservable: Observable<AbstractMesh>;
  35282. /**
  35283. * Gets or sets the orientation for POV movement & rotation
  35284. */
  35285. definedFacingForward: boolean;
  35286. /** @hidden */
  35287. _occlusionQuery: Nullable<WebGLQuery>;
  35288. /** @hidden */
  35289. _renderingGroup: Nullable<RenderingGroup>;
  35290. /**
  35291. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35292. */
  35293. get visibility(): number;
  35294. /**
  35295. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35296. */
  35297. set visibility(value: number);
  35298. /** Gets or sets the alpha index used to sort transparent meshes
  35299. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35300. */
  35301. alphaIndex: number;
  35302. /**
  35303. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35304. */
  35305. isVisible: boolean;
  35306. /**
  35307. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35308. */
  35309. isPickable: boolean;
  35310. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35311. showSubMeshesBoundingBox: boolean;
  35312. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35313. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35314. */
  35315. isBlocker: boolean;
  35316. /**
  35317. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35318. */
  35319. enablePointerMoveEvents: boolean;
  35320. private _renderingGroupId;
  35321. /**
  35322. * Specifies the rendering group id for this mesh (0 by default)
  35323. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35324. */
  35325. get renderingGroupId(): number;
  35326. set renderingGroupId(value: number);
  35327. private _material;
  35328. /** Gets or sets current material */
  35329. get material(): Nullable<Material>;
  35330. set material(value: Nullable<Material>);
  35331. /**
  35332. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35333. * @see https://doc.babylonjs.com/babylon101/shadows
  35334. */
  35335. get receiveShadows(): boolean;
  35336. set receiveShadows(value: boolean);
  35337. /** Defines color to use when rendering outline */
  35338. outlineColor: Color3;
  35339. /** Define width to use when rendering outline */
  35340. outlineWidth: number;
  35341. /** Defines color to use when rendering overlay */
  35342. overlayColor: Color3;
  35343. /** Defines alpha to use when rendering overlay */
  35344. overlayAlpha: number;
  35345. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35346. get hasVertexAlpha(): boolean;
  35347. set hasVertexAlpha(value: boolean);
  35348. /** 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) */
  35349. get useVertexColors(): boolean;
  35350. set useVertexColors(value: boolean);
  35351. /**
  35352. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35353. */
  35354. get computeBonesUsingShaders(): boolean;
  35355. set computeBonesUsingShaders(value: boolean);
  35356. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35357. get numBoneInfluencers(): number;
  35358. set numBoneInfluencers(value: number);
  35359. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35360. get applyFog(): boolean;
  35361. set applyFog(value: boolean);
  35362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35363. useOctreeForRenderingSelection: boolean;
  35364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35365. useOctreeForPicking: boolean;
  35366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35367. useOctreeForCollisions: boolean;
  35368. /**
  35369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35370. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35371. */
  35372. get layerMask(): number;
  35373. set layerMask(value: number);
  35374. /**
  35375. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35376. */
  35377. alwaysSelectAsActiveMesh: boolean;
  35378. /**
  35379. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35380. */
  35381. doNotSyncBoundingInfo: boolean;
  35382. /**
  35383. * Gets or sets the current action manager
  35384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35385. */
  35386. actionManager: Nullable<AbstractActionManager>;
  35387. private _meshCollisionData;
  35388. /**
  35389. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35390. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35391. */
  35392. ellipsoid: Vector3;
  35393. /**
  35394. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35395. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35396. */
  35397. ellipsoidOffset: Vector3;
  35398. /**
  35399. * Gets or sets a collision mask used to mask collisions (default is -1).
  35400. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35401. */
  35402. get collisionMask(): number;
  35403. set collisionMask(mask: number);
  35404. /**
  35405. * Gets or sets a collision response flag (default is true).
  35406. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35407. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35408. * to respond to the collision.
  35409. */
  35410. get collisionResponse(): boolean;
  35411. set collisionResponse(response: boolean);
  35412. /**
  35413. * Gets or sets the current collision group mask (-1 by default).
  35414. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35415. */
  35416. get collisionGroup(): number;
  35417. set collisionGroup(mask: number);
  35418. /**
  35419. * Gets or sets current surrounding meshes (null by default).
  35420. *
  35421. * By default collision detection is tested against every mesh in the scene.
  35422. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35423. * meshes will be tested for the collision.
  35424. *
  35425. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35426. */
  35427. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35428. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35429. /**
  35430. * Defines edge width used when edgesRenderer is enabled
  35431. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35432. */
  35433. edgesWidth: number;
  35434. /**
  35435. * Defines edge color used when edgesRenderer is enabled
  35436. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35437. */
  35438. edgesColor: Color4;
  35439. /** @hidden */
  35440. _edgesRenderer: Nullable<IEdgesRenderer>;
  35441. /** @hidden */
  35442. _masterMesh: Nullable<AbstractMesh>;
  35443. /** @hidden */
  35444. _boundingInfo: Nullable<BoundingInfo>;
  35445. /** @hidden */
  35446. _renderId: number;
  35447. /**
  35448. * Gets or sets the list of subMeshes
  35449. * @see https://doc.babylonjs.com/how_to/multi_materials
  35450. */
  35451. subMeshes: SubMesh[];
  35452. /** @hidden */
  35453. _intersectionsInProgress: AbstractMesh[];
  35454. /** @hidden */
  35455. _unIndexed: boolean;
  35456. /** @hidden */
  35457. _lightSources: Light[];
  35458. /** Gets the list of lights affecting that mesh */
  35459. get lightSources(): Light[];
  35460. /** @hidden */
  35461. get _positions(): Nullable<Vector3[]>;
  35462. /** @hidden */
  35463. _waitingData: {
  35464. lods: Nullable<any>;
  35465. actions: Nullable<any>;
  35466. freezeWorldMatrix: Nullable<boolean>;
  35467. };
  35468. /** @hidden */
  35469. _bonesTransformMatrices: Nullable<Float32Array>;
  35470. /** @hidden */
  35471. _transformMatrixTexture: Nullable<RawTexture>;
  35472. /**
  35473. * Gets or sets a skeleton to apply skining transformations
  35474. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35475. */
  35476. set skeleton(value: Nullable<Skeleton>);
  35477. get skeleton(): Nullable<Skeleton>;
  35478. /**
  35479. * An event triggered when the mesh is rebuilt.
  35480. */
  35481. onRebuildObservable: Observable<AbstractMesh>;
  35482. /**
  35483. * Creates a new AbstractMesh
  35484. * @param name defines the name of the mesh
  35485. * @param scene defines the hosting scene
  35486. */
  35487. constructor(name: string, scene?: Nullable<Scene>);
  35488. /**
  35489. * Returns the string "AbstractMesh"
  35490. * @returns "AbstractMesh"
  35491. */
  35492. getClassName(): string;
  35493. /**
  35494. * Gets a string representation of the current mesh
  35495. * @param fullDetails defines a boolean indicating if full details must be included
  35496. * @returns a string representation of the current mesh
  35497. */
  35498. toString(fullDetails?: boolean): string;
  35499. /**
  35500. * @hidden
  35501. */
  35502. protected _getEffectiveParent(): Nullable<Node>;
  35503. /** @hidden */
  35504. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35505. /** @hidden */
  35506. _rebuild(): void;
  35507. /** @hidden */
  35508. _resyncLightSources(): void;
  35509. /** @hidden */
  35510. _resyncLightSource(light: Light): void;
  35511. /** @hidden */
  35512. _unBindEffect(): void;
  35513. /** @hidden */
  35514. _removeLightSource(light: Light, dispose: boolean): void;
  35515. private _markSubMeshesAsDirty;
  35516. /** @hidden */
  35517. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35518. /** @hidden */
  35519. _markSubMeshesAsAttributesDirty(): void;
  35520. /** @hidden */
  35521. _markSubMeshesAsMiscDirty(): void;
  35522. /**
  35523. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35524. */
  35525. get scaling(): Vector3;
  35526. set scaling(newScaling: Vector3);
  35527. /**
  35528. * Returns true if the mesh is blocked. Implemented by child classes
  35529. */
  35530. get isBlocked(): boolean;
  35531. /**
  35532. * Returns the mesh itself by default. Implemented by child classes
  35533. * @param camera defines the camera to use to pick the right LOD level
  35534. * @returns the currentAbstractMesh
  35535. */
  35536. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35537. /**
  35538. * Returns 0 by default. Implemented by child classes
  35539. * @returns an integer
  35540. */
  35541. getTotalVertices(): number;
  35542. /**
  35543. * Returns a positive integer : the total number of indices in this mesh geometry.
  35544. * @returns the numner of indices or zero if the mesh has no geometry.
  35545. */
  35546. getTotalIndices(): number;
  35547. /**
  35548. * Returns null by default. Implemented by child classes
  35549. * @returns null
  35550. */
  35551. getIndices(): Nullable<IndicesArray>;
  35552. /**
  35553. * Returns the array of the requested vertex data kind. Implemented by child classes
  35554. * @param kind defines the vertex data kind to use
  35555. * @returns null
  35556. */
  35557. getVerticesData(kind: string): Nullable<FloatArray>;
  35558. /**
  35559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35561. * Note that a new underlying VertexBuffer object is created each call.
  35562. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35563. * @param kind defines vertex data kind:
  35564. * * VertexBuffer.PositionKind
  35565. * * VertexBuffer.UVKind
  35566. * * VertexBuffer.UV2Kind
  35567. * * VertexBuffer.UV3Kind
  35568. * * VertexBuffer.UV4Kind
  35569. * * VertexBuffer.UV5Kind
  35570. * * VertexBuffer.UV6Kind
  35571. * * VertexBuffer.ColorKind
  35572. * * VertexBuffer.MatricesIndicesKind
  35573. * * VertexBuffer.MatricesIndicesExtraKind
  35574. * * VertexBuffer.MatricesWeightsKind
  35575. * * VertexBuffer.MatricesWeightsExtraKind
  35576. * @param data defines the data source
  35577. * @param updatable defines if the data must be flagged as updatable (or static)
  35578. * @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
  35579. * @returns the current mesh
  35580. */
  35581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35582. /**
  35583. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35584. * If the mesh has no geometry, it is simply returned as it is.
  35585. * @param kind defines vertex data kind:
  35586. * * VertexBuffer.PositionKind
  35587. * * VertexBuffer.UVKind
  35588. * * VertexBuffer.UV2Kind
  35589. * * VertexBuffer.UV3Kind
  35590. * * VertexBuffer.UV4Kind
  35591. * * VertexBuffer.UV5Kind
  35592. * * VertexBuffer.UV6Kind
  35593. * * VertexBuffer.ColorKind
  35594. * * VertexBuffer.MatricesIndicesKind
  35595. * * VertexBuffer.MatricesIndicesExtraKind
  35596. * * VertexBuffer.MatricesWeightsKind
  35597. * * VertexBuffer.MatricesWeightsExtraKind
  35598. * @param data defines the data source
  35599. * @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
  35600. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35601. * @returns the current mesh
  35602. */
  35603. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35604. /**
  35605. * Sets the mesh indices,
  35606. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35607. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35608. * @param totalVertices Defines the total number of vertices
  35609. * @returns the current mesh
  35610. */
  35611. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35612. /**
  35613. * Gets a boolean indicating if specific vertex data is present
  35614. * @param kind defines the vertex data kind to use
  35615. * @returns true is data kind is present
  35616. */
  35617. isVerticesDataPresent(kind: string): boolean;
  35618. /**
  35619. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35620. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35621. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35622. * @returns a BoundingInfo
  35623. */
  35624. getBoundingInfo(): BoundingInfo;
  35625. /**
  35626. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35627. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35628. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35629. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35630. * @returns the current mesh
  35631. */
  35632. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35633. /**
  35634. * Overwrite the current bounding info
  35635. * @param boundingInfo defines the new bounding info
  35636. * @returns the current mesh
  35637. */
  35638. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35639. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35640. get useBones(): boolean;
  35641. /** @hidden */
  35642. _preActivate(): void;
  35643. /** @hidden */
  35644. _preActivateForIntermediateRendering(renderId: number): void;
  35645. /** @hidden */
  35646. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35647. /** @hidden */
  35648. _postActivate(): void;
  35649. /** @hidden */
  35650. _freeze(): void;
  35651. /** @hidden */
  35652. _unFreeze(): void;
  35653. /**
  35654. * Gets the current world matrix
  35655. * @returns a Matrix
  35656. */
  35657. getWorldMatrix(): Matrix;
  35658. /** @hidden */
  35659. _getWorldMatrixDeterminant(): number;
  35660. /**
  35661. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35662. */
  35663. get isAnInstance(): boolean;
  35664. /**
  35665. * Gets a boolean indicating if this mesh has instances
  35666. */
  35667. get hasInstances(): boolean;
  35668. /**
  35669. * Gets a boolean indicating if this mesh has thin instances
  35670. */
  35671. get hasThinInstances(): boolean;
  35672. /**
  35673. * Perform relative position change from the point of view of behind the front of the mesh.
  35674. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35675. * Supports definition of mesh facing forward or backward
  35676. * @param amountRight defines the distance on the right axis
  35677. * @param amountUp defines the distance on the up axis
  35678. * @param amountForward defines the distance on the forward axis
  35679. * @returns the current mesh
  35680. */
  35681. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35682. /**
  35683. * Calculate relative position change from the point of view of behind the front of the mesh.
  35684. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35685. * Supports definition of mesh facing forward or backward
  35686. * @param amountRight defines the distance on the right axis
  35687. * @param amountUp defines the distance on the up axis
  35688. * @param amountForward defines the distance on the forward axis
  35689. * @returns the new displacement vector
  35690. */
  35691. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35692. /**
  35693. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35694. * Supports definition of mesh facing forward or backward
  35695. * @param flipBack defines the flip
  35696. * @param twirlClockwise defines the twirl
  35697. * @param tiltRight defines the tilt
  35698. * @returns the current mesh
  35699. */
  35700. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35701. /**
  35702. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35703. * Supports definition of mesh facing forward or backward.
  35704. * @param flipBack defines the flip
  35705. * @param twirlClockwise defines the twirl
  35706. * @param tiltRight defines the tilt
  35707. * @returns the new rotation vector
  35708. */
  35709. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35710. /**
  35711. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35712. * This means the mesh underlying bounding box and sphere are recomputed.
  35713. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35714. * @returns the current mesh
  35715. */
  35716. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35717. /** @hidden */
  35718. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35719. /** @hidden */
  35720. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35721. /** @hidden */
  35722. _updateBoundingInfo(): AbstractMesh;
  35723. /** @hidden */
  35724. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35725. /** @hidden */
  35726. protected _afterComputeWorldMatrix(): void;
  35727. /** @hidden */
  35728. get _effectiveMesh(): AbstractMesh;
  35729. /**
  35730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35731. * A mesh is in the frustum if its bounding box intersects the frustum
  35732. * @param frustumPlanes defines the frustum to test
  35733. * @returns true if the mesh is in the frustum planes
  35734. */
  35735. isInFrustum(frustumPlanes: Plane[]): boolean;
  35736. /**
  35737. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35738. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35739. * @param frustumPlanes defines the frustum to test
  35740. * @returns true if the mesh is completely in the frustum planes
  35741. */
  35742. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35743. /**
  35744. * True if the mesh intersects another mesh or a SolidParticle object
  35745. * @param mesh defines a target mesh or SolidParticle to test
  35746. * @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)
  35747. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35748. * @returns true if there is an intersection
  35749. */
  35750. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35751. /**
  35752. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35753. * @param point defines the point to test
  35754. * @returns true if there is an intersection
  35755. */
  35756. intersectsPoint(point: Vector3): boolean;
  35757. /**
  35758. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35760. */
  35761. get checkCollisions(): boolean;
  35762. set checkCollisions(collisionEnabled: boolean);
  35763. /**
  35764. * Gets Collider object used to compute collisions (not physics)
  35765. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35766. */
  35767. get collider(): Nullable<Collider>;
  35768. /**
  35769. * Move the mesh using collision engine
  35770. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35771. * @param displacement defines the requested displacement vector
  35772. * @returns the current mesh
  35773. */
  35774. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35775. private _onCollisionPositionChange;
  35776. /** @hidden */
  35777. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35778. /** @hidden */
  35779. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35780. /** @hidden */
  35781. _checkCollision(collider: Collider): AbstractMesh;
  35782. /** @hidden */
  35783. _generatePointsArray(): boolean;
  35784. /**
  35785. * Checks if the passed Ray intersects with the mesh
  35786. * @param ray defines the ray to use
  35787. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35788. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35789. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35790. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35791. * @returns the picking info
  35792. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35793. */
  35794. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35795. /**
  35796. * Clones the current mesh
  35797. * @param name defines the mesh name
  35798. * @param newParent defines the new mesh parent
  35799. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35800. * @returns the new mesh
  35801. */
  35802. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35803. /**
  35804. * Disposes all the submeshes of the current meshnp
  35805. * @returns the current mesh
  35806. */
  35807. releaseSubMeshes(): AbstractMesh;
  35808. /**
  35809. * Releases resources associated with this abstract mesh.
  35810. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35811. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35812. */
  35813. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35814. /**
  35815. * Adds the passed mesh as a child to the current mesh
  35816. * @param mesh defines the child mesh
  35817. * @returns the current mesh
  35818. */
  35819. addChild(mesh: AbstractMesh): AbstractMesh;
  35820. /**
  35821. * Removes the passed mesh from the current mesh children list
  35822. * @param mesh defines the child mesh
  35823. * @returns the current mesh
  35824. */
  35825. removeChild(mesh: AbstractMesh): AbstractMesh;
  35826. /** @hidden */
  35827. private _initFacetData;
  35828. /**
  35829. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35830. * This method can be called within the render loop.
  35831. * 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
  35832. * @returns the current mesh
  35833. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35834. */
  35835. updateFacetData(): AbstractMesh;
  35836. /**
  35837. * Returns the facetLocalNormals array.
  35838. * The normals are expressed in the mesh local spac
  35839. * @returns an array of Vector3
  35840. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35841. */
  35842. getFacetLocalNormals(): Vector3[];
  35843. /**
  35844. * Returns the facetLocalPositions array.
  35845. * The facet positions are expressed in the mesh local space
  35846. * @returns an array of Vector3
  35847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35848. */
  35849. getFacetLocalPositions(): Vector3[];
  35850. /**
  35851. * Returns the facetLocalPartioning array
  35852. * @returns an array of array of numbers
  35853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35854. */
  35855. getFacetLocalPartitioning(): number[][];
  35856. /**
  35857. * Returns the i-th facet position in the world system.
  35858. * This method allocates a new Vector3 per call
  35859. * @param i defines the facet index
  35860. * @returns a new Vector3
  35861. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35862. */
  35863. getFacetPosition(i: number): Vector3;
  35864. /**
  35865. * Sets the reference Vector3 with the i-th facet position in the world system
  35866. * @param i defines the facet index
  35867. * @param ref defines the target vector
  35868. * @returns the current mesh
  35869. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35870. */
  35871. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35872. /**
  35873. * Returns the i-th facet normal in the world system.
  35874. * This method allocates a new Vector3 per call
  35875. * @param i defines the facet index
  35876. * @returns a new Vector3
  35877. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35878. */
  35879. getFacetNormal(i: number): Vector3;
  35880. /**
  35881. * Sets the reference Vector3 with the i-th facet normal in the world system
  35882. * @param i defines the facet index
  35883. * @param ref defines the target vector
  35884. * @returns the current mesh
  35885. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35886. */
  35887. getFacetNormalToRef(i: number, ref: Vector3): this;
  35888. /**
  35889. * 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)
  35890. * @param x defines x coordinate
  35891. * @param y defines y coordinate
  35892. * @param z defines z coordinate
  35893. * @returns the array of facet indexes
  35894. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35895. */
  35896. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35897. /**
  35898. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35899. * @param projected sets as the (x,y,z) world projection on the facet
  35900. * @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
  35901. * @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
  35902. * @param x defines x coordinate
  35903. * @param y defines y coordinate
  35904. * @param z defines z coordinate
  35905. * @returns the face index if found (or null instead)
  35906. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35907. */
  35908. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35909. /**
  35910. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35911. * @param projected sets as the (x,y,z) local projection on the facet
  35912. * @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
  35913. * @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
  35914. * @param x defines x coordinate
  35915. * @param y defines y coordinate
  35916. * @param z defines z coordinate
  35917. * @returns the face index if found (or null instead)
  35918. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35919. */
  35920. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35921. /**
  35922. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35923. * @returns the parameters
  35924. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35925. */
  35926. getFacetDataParameters(): any;
  35927. /**
  35928. * Disables the feature FacetData and frees the related memory
  35929. * @returns the current mesh
  35930. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35931. */
  35932. disableFacetData(): AbstractMesh;
  35933. /**
  35934. * Updates the AbstractMesh indices array
  35935. * @param indices defines the data source
  35936. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35937. * @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)
  35938. * @returns the current mesh
  35939. */
  35940. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35941. /**
  35942. * Creates new normals data for the mesh
  35943. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35944. * @returns the current mesh
  35945. */
  35946. createNormals(updatable: boolean): AbstractMesh;
  35947. /**
  35948. * Align the mesh with a normal
  35949. * @param normal defines the normal to use
  35950. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35951. * @returns the current mesh
  35952. */
  35953. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35954. /** @hidden */
  35955. _checkOcclusionQuery(): boolean;
  35956. /**
  35957. * Disables the mesh edge rendering mode
  35958. * @returns the currentAbstractMesh
  35959. */
  35960. disableEdgesRendering(): AbstractMesh;
  35961. /**
  35962. * Enables the edge rendering mode on the mesh.
  35963. * This mode makes the mesh edges visible
  35964. * @param epsilon defines the maximal distance between two angles to detect a face
  35965. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35966. * @returns the currentAbstractMesh
  35967. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35968. */
  35969. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35970. /**
  35971. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35972. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35973. */
  35974. getConnectedParticleSystems(): IParticleSystem[];
  35975. }
  35976. }
  35977. declare module BABYLON {
  35978. /**
  35979. * Interface used to define ActionEvent
  35980. */
  35981. export interface IActionEvent {
  35982. /** The mesh or sprite that triggered the action */
  35983. source: any;
  35984. /** The X mouse cursor position at the time of the event */
  35985. pointerX: number;
  35986. /** The Y mouse cursor position at the time of the event */
  35987. pointerY: number;
  35988. /** The mesh that is currently pointed at (can be null) */
  35989. meshUnderPointer: Nullable<AbstractMesh>;
  35990. /** the original (browser) event that triggered the ActionEvent */
  35991. sourceEvent?: any;
  35992. /** additional data for the event */
  35993. additionalData?: any;
  35994. }
  35995. /**
  35996. * ActionEvent is the event being sent when an action is triggered.
  35997. */
  35998. export class ActionEvent implements IActionEvent {
  35999. /** The mesh or sprite that triggered the action */
  36000. source: any;
  36001. /** The X mouse cursor position at the time of the event */
  36002. pointerX: number;
  36003. /** The Y mouse cursor position at the time of the event */
  36004. pointerY: number;
  36005. /** The mesh that is currently pointed at (can be null) */
  36006. meshUnderPointer: Nullable<AbstractMesh>;
  36007. /** the original (browser) event that triggered the ActionEvent */
  36008. sourceEvent?: any;
  36009. /** additional data for the event */
  36010. additionalData?: any;
  36011. /**
  36012. * Creates a new ActionEvent
  36013. * @param source The mesh or sprite that triggered the action
  36014. * @param pointerX The X mouse cursor position at the time of the event
  36015. * @param pointerY The Y mouse cursor position at the time of the event
  36016. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36017. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36018. * @param additionalData additional data for the event
  36019. */
  36020. constructor(
  36021. /** The mesh or sprite that triggered the action */
  36022. source: any,
  36023. /** The X mouse cursor position at the time of the event */
  36024. pointerX: number,
  36025. /** The Y mouse cursor position at the time of the event */
  36026. pointerY: number,
  36027. /** The mesh that is currently pointed at (can be null) */
  36028. meshUnderPointer: Nullable<AbstractMesh>,
  36029. /** the original (browser) event that triggered the ActionEvent */
  36030. sourceEvent?: any,
  36031. /** additional data for the event */
  36032. additionalData?: any);
  36033. /**
  36034. * Helper function to auto-create an ActionEvent from a source mesh.
  36035. * @param source The source mesh that triggered the event
  36036. * @param evt The original (browser) event
  36037. * @param additionalData additional data for the event
  36038. * @returns the new ActionEvent
  36039. */
  36040. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36041. /**
  36042. * Helper function to auto-create an ActionEvent from a source sprite
  36043. * @param source The source sprite that triggered the event
  36044. * @param scene Scene associated with the sprite
  36045. * @param evt The original (browser) event
  36046. * @param additionalData additional data for the event
  36047. * @returns the new ActionEvent
  36048. */
  36049. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36050. /**
  36051. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36052. * @param scene the scene where the event occurred
  36053. * @param evt The original (browser) event
  36054. * @returns the new ActionEvent
  36055. */
  36056. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36057. /**
  36058. * Helper function to auto-create an ActionEvent from a primitive
  36059. * @param prim defines the target primitive
  36060. * @param pointerPos defines the pointer position
  36061. * @param evt The original (browser) event
  36062. * @param additionalData additional data for the event
  36063. * @returns the new ActionEvent
  36064. */
  36065. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36066. }
  36067. }
  36068. declare module BABYLON {
  36069. /**
  36070. * Abstract class used to decouple action Manager from scene and meshes.
  36071. * Do not instantiate.
  36072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36073. */
  36074. export abstract class AbstractActionManager implements IDisposable {
  36075. /** Gets the list of active triggers */
  36076. static Triggers: {
  36077. [key: string]: number;
  36078. };
  36079. /** Gets the cursor to use when hovering items */
  36080. hoverCursor: string;
  36081. /** Gets the list of actions */
  36082. actions: IAction[];
  36083. /**
  36084. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36085. */
  36086. isRecursive: boolean;
  36087. /**
  36088. * Releases all associated resources
  36089. */
  36090. abstract dispose(): void;
  36091. /**
  36092. * Does this action manager has pointer triggers
  36093. */
  36094. abstract get hasPointerTriggers(): boolean;
  36095. /**
  36096. * Does this action manager has pick triggers
  36097. */
  36098. abstract get hasPickTriggers(): boolean;
  36099. /**
  36100. * Process a specific trigger
  36101. * @param trigger defines the trigger to process
  36102. * @param evt defines the event details to be processed
  36103. */
  36104. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36105. /**
  36106. * Does this action manager handles actions of any of the given triggers
  36107. * @param triggers defines the triggers to be tested
  36108. * @return a boolean indicating whether one (or more) of the triggers is handled
  36109. */
  36110. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36111. /**
  36112. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36113. * speed.
  36114. * @param triggerA defines the trigger to be tested
  36115. * @param triggerB defines the trigger to be tested
  36116. * @return a boolean indicating whether one (or more) of the triggers is handled
  36117. */
  36118. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36119. /**
  36120. * Does this action manager handles actions of a given trigger
  36121. * @param trigger defines the trigger to be tested
  36122. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36123. * @return whether the trigger is handled
  36124. */
  36125. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36126. /**
  36127. * Serialize this manager to a JSON object
  36128. * @param name defines the property name to store this manager
  36129. * @returns a JSON representation of this manager
  36130. */
  36131. abstract serialize(name: string): any;
  36132. /**
  36133. * Registers an action to this action manager
  36134. * @param action defines the action to be registered
  36135. * @return the action amended (prepared) after registration
  36136. */
  36137. abstract registerAction(action: IAction): Nullable<IAction>;
  36138. /**
  36139. * Unregisters an action to this action manager
  36140. * @param action defines the action to be unregistered
  36141. * @return a boolean indicating whether the action has been unregistered
  36142. */
  36143. abstract unregisterAction(action: IAction): Boolean;
  36144. /**
  36145. * Does exist one action manager with at least one trigger
  36146. **/
  36147. static get HasTriggers(): boolean;
  36148. /**
  36149. * Does exist one action manager with at least one pick trigger
  36150. **/
  36151. static get HasPickTriggers(): boolean;
  36152. /**
  36153. * Does exist one action manager that handles actions of a given trigger
  36154. * @param trigger defines the trigger to be tested
  36155. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36156. **/
  36157. static HasSpecificTrigger(trigger: number): boolean;
  36158. }
  36159. }
  36160. declare module BABYLON {
  36161. /**
  36162. * Defines how a node can be built from a string name.
  36163. */
  36164. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36165. /**
  36166. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36167. */
  36168. export class Node implements IBehaviorAware<Node> {
  36169. /** @hidden */
  36170. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36171. private static _NodeConstructors;
  36172. /**
  36173. * Add a new node constructor
  36174. * @param type defines the type name of the node to construct
  36175. * @param constructorFunc defines the constructor function
  36176. */
  36177. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36178. /**
  36179. * Returns a node constructor based on type name
  36180. * @param type defines the type name
  36181. * @param name defines the new node name
  36182. * @param scene defines the hosting scene
  36183. * @param options defines optional options to transmit to constructors
  36184. * @returns the new constructor or null
  36185. */
  36186. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36187. /**
  36188. * Gets or sets the name of the node
  36189. */
  36190. name: string;
  36191. /**
  36192. * Gets or sets the id of the node
  36193. */
  36194. id: string;
  36195. /**
  36196. * Gets or sets the unique id of the node
  36197. */
  36198. uniqueId: number;
  36199. /**
  36200. * Gets or sets a string used to store user defined state for the node
  36201. */
  36202. state: string;
  36203. /**
  36204. * Gets or sets an object used to store user defined information for the node
  36205. */
  36206. metadata: any;
  36207. /**
  36208. * For internal use only. Please do not use.
  36209. */
  36210. reservedDataStore: any;
  36211. /**
  36212. * List of inspectable custom properties (used by the Inspector)
  36213. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36214. */
  36215. inspectableCustomProperties: IInspectable[];
  36216. private _doNotSerialize;
  36217. /**
  36218. * Gets or sets a boolean used to define if the node must be serialized
  36219. */
  36220. get doNotSerialize(): boolean;
  36221. set doNotSerialize(value: boolean);
  36222. /** @hidden */
  36223. _isDisposed: boolean;
  36224. /**
  36225. * Gets a list of Animations associated with the node
  36226. */
  36227. animations: Animation[];
  36228. protected _ranges: {
  36229. [name: string]: Nullable<AnimationRange>;
  36230. };
  36231. /**
  36232. * Callback raised when the node is ready to be used
  36233. */
  36234. onReady: Nullable<(node: Node) => void>;
  36235. private _isEnabled;
  36236. private _isParentEnabled;
  36237. private _isReady;
  36238. /** @hidden */
  36239. _currentRenderId: number;
  36240. private _parentUpdateId;
  36241. /** @hidden */
  36242. _childUpdateId: number;
  36243. /** @hidden */
  36244. _waitingParentId: Nullable<string>;
  36245. /** @hidden */
  36246. _scene: Scene;
  36247. /** @hidden */
  36248. _cache: any;
  36249. private _parentNode;
  36250. private _children;
  36251. /** @hidden */
  36252. _worldMatrix: Matrix;
  36253. /** @hidden */
  36254. _worldMatrixDeterminant: number;
  36255. /** @hidden */
  36256. _worldMatrixDeterminantIsDirty: boolean;
  36257. /** @hidden */
  36258. private _sceneRootNodesIndex;
  36259. /**
  36260. * Gets a boolean indicating if the node has been disposed
  36261. * @returns true if the node was disposed
  36262. */
  36263. isDisposed(): boolean;
  36264. /**
  36265. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36266. * @see https://doc.babylonjs.com/how_to/parenting
  36267. */
  36268. set parent(parent: Nullable<Node>);
  36269. get parent(): Nullable<Node>;
  36270. /** @hidden */
  36271. _addToSceneRootNodes(): void;
  36272. /** @hidden */
  36273. _removeFromSceneRootNodes(): void;
  36274. private _animationPropertiesOverride;
  36275. /**
  36276. * Gets or sets the animation properties override
  36277. */
  36278. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36279. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36280. /**
  36281. * Gets a string identifying the name of the class
  36282. * @returns "Node" string
  36283. */
  36284. getClassName(): string;
  36285. /** @hidden */
  36286. readonly _isNode: boolean;
  36287. /**
  36288. * An event triggered when the mesh is disposed
  36289. */
  36290. onDisposeObservable: Observable<Node>;
  36291. private _onDisposeObserver;
  36292. /**
  36293. * Sets a callback that will be raised when the node will be disposed
  36294. */
  36295. set onDispose(callback: () => void);
  36296. /**
  36297. * Creates a new Node
  36298. * @param name the name and id to be given to this node
  36299. * @param scene the scene this node will be added to
  36300. */
  36301. constructor(name: string, scene?: Nullable<Scene>);
  36302. /**
  36303. * Gets the scene of the node
  36304. * @returns a scene
  36305. */
  36306. getScene(): Scene;
  36307. /**
  36308. * Gets the engine of the node
  36309. * @returns a Engine
  36310. */
  36311. getEngine(): Engine;
  36312. private _behaviors;
  36313. /**
  36314. * Attach a behavior to the node
  36315. * @see https://doc.babylonjs.com/features/behaviour
  36316. * @param behavior defines the behavior to attach
  36317. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36318. * @returns the current Node
  36319. */
  36320. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36321. /**
  36322. * Remove an attached behavior
  36323. * @see https://doc.babylonjs.com/features/behaviour
  36324. * @param behavior defines the behavior to attach
  36325. * @returns the current Node
  36326. */
  36327. removeBehavior(behavior: Behavior<Node>): Node;
  36328. /**
  36329. * Gets the list of attached behaviors
  36330. * @see https://doc.babylonjs.com/features/behaviour
  36331. */
  36332. get behaviors(): Behavior<Node>[];
  36333. /**
  36334. * Gets an attached behavior by name
  36335. * @param name defines the name of the behavior to look for
  36336. * @see https://doc.babylonjs.com/features/behaviour
  36337. * @returns null if behavior was not found else the requested behavior
  36338. */
  36339. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36340. /**
  36341. * Returns the latest update of the World matrix
  36342. * @returns a Matrix
  36343. */
  36344. getWorldMatrix(): Matrix;
  36345. /** @hidden */
  36346. _getWorldMatrixDeterminant(): number;
  36347. /**
  36348. * Returns directly the latest state of the mesh World matrix.
  36349. * A Matrix is returned.
  36350. */
  36351. get worldMatrixFromCache(): Matrix;
  36352. /** @hidden */
  36353. _initCache(): void;
  36354. /** @hidden */
  36355. updateCache(force?: boolean): void;
  36356. /** @hidden */
  36357. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36358. /** @hidden */
  36359. _updateCache(ignoreParentClass?: boolean): void;
  36360. /** @hidden */
  36361. _isSynchronized(): boolean;
  36362. /** @hidden */
  36363. _markSyncedWithParent(): void;
  36364. /** @hidden */
  36365. isSynchronizedWithParent(): boolean;
  36366. /** @hidden */
  36367. isSynchronized(): boolean;
  36368. /**
  36369. * Is this node ready to be used/rendered
  36370. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36371. * @return true if the node is ready
  36372. */
  36373. isReady(completeCheck?: boolean): boolean;
  36374. /**
  36375. * Is this node enabled?
  36376. * 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
  36377. * @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
  36378. * @return whether this node (and its parent) is enabled
  36379. */
  36380. isEnabled(checkAncestors?: boolean): boolean;
  36381. /** @hidden */
  36382. protected _syncParentEnabledState(): void;
  36383. /**
  36384. * Set the enabled state of this node
  36385. * @param value defines the new enabled state
  36386. */
  36387. setEnabled(value: boolean): void;
  36388. /**
  36389. * Is this node a descendant of the given node?
  36390. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36391. * @param ancestor defines the parent node to inspect
  36392. * @returns a boolean indicating if this node is a descendant of the given node
  36393. */
  36394. isDescendantOf(ancestor: Node): boolean;
  36395. /** @hidden */
  36396. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36397. /**
  36398. * Will return all nodes that have this node as ascendant
  36399. * @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
  36400. * @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
  36401. * @return all children nodes of all types
  36402. */
  36403. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36404. /**
  36405. * Get all child-meshes of this node
  36406. * @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)
  36407. * @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
  36408. * @returns an array of AbstractMesh
  36409. */
  36410. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36411. /**
  36412. * Get all direct children of this node
  36413. * @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
  36414. * @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)
  36415. * @returns an array of Node
  36416. */
  36417. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36418. /** @hidden */
  36419. _setReady(state: boolean): void;
  36420. /**
  36421. * Get an animation by name
  36422. * @param name defines the name of the animation to look for
  36423. * @returns null if not found else the requested animation
  36424. */
  36425. getAnimationByName(name: string): Nullable<Animation>;
  36426. /**
  36427. * Creates an animation range for this node
  36428. * @param name defines the name of the range
  36429. * @param from defines the starting key
  36430. * @param to defines the end key
  36431. */
  36432. createAnimationRange(name: string, from: number, to: number): void;
  36433. /**
  36434. * Delete a specific animation range
  36435. * @param name defines the name of the range to delete
  36436. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36437. */
  36438. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36439. /**
  36440. * Get an animation range by name
  36441. * @param name defines the name of the animation range to look for
  36442. * @returns null if not found else the requested animation range
  36443. */
  36444. getAnimationRange(name: string): Nullable<AnimationRange>;
  36445. /**
  36446. * Gets the list of all animation ranges defined on this node
  36447. * @returns an array
  36448. */
  36449. getAnimationRanges(): Nullable<AnimationRange>[];
  36450. /**
  36451. * Will start the animation sequence
  36452. * @param name defines the range frames for animation sequence
  36453. * @param loop defines if the animation should loop (false by default)
  36454. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36455. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36456. * @returns the object created for this animation. If range does not exist, it will return null
  36457. */
  36458. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36459. /**
  36460. * Serialize animation ranges into a JSON compatible object
  36461. * @returns serialization object
  36462. */
  36463. serializeAnimationRanges(): any;
  36464. /**
  36465. * Computes the world matrix of the node
  36466. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36467. * @returns the world matrix
  36468. */
  36469. computeWorldMatrix(force?: boolean): Matrix;
  36470. /**
  36471. * Releases resources associated with this node.
  36472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36474. */
  36475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36476. /**
  36477. * Parse animation range data from a serialization object and store them into a given node
  36478. * @param node defines where to store the animation ranges
  36479. * @param parsedNode defines the serialization object to read data from
  36480. * @param scene defines the hosting scene
  36481. */
  36482. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36483. /**
  36484. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36485. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36486. * @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
  36487. * @returns the new bounding vectors
  36488. */
  36489. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36490. min: Vector3;
  36491. max: Vector3;
  36492. };
  36493. }
  36494. }
  36495. declare module BABYLON {
  36496. /**
  36497. * @hidden
  36498. */
  36499. export class _IAnimationState {
  36500. key: number;
  36501. repeatCount: number;
  36502. workValue?: any;
  36503. loopMode?: number;
  36504. offsetValue?: any;
  36505. highLimitValue?: any;
  36506. }
  36507. /**
  36508. * Class used to store any kind of animation
  36509. */
  36510. export class Animation {
  36511. /**Name of the animation */
  36512. name: string;
  36513. /**Property to animate */
  36514. targetProperty: string;
  36515. /**The frames per second of the animation */
  36516. framePerSecond: number;
  36517. /**The data type of the animation */
  36518. dataType: number;
  36519. /**The loop mode of the animation */
  36520. loopMode?: number | undefined;
  36521. /**Specifies if blending should be enabled */
  36522. enableBlending?: boolean | undefined;
  36523. /**
  36524. * Use matrix interpolation instead of using direct key value when animating matrices
  36525. */
  36526. static AllowMatricesInterpolation: boolean;
  36527. /**
  36528. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36529. */
  36530. static AllowMatrixDecomposeForInterpolation: boolean;
  36531. /** Define the Url to load snippets */
  36532. static SnippetUrl: string;
  36533. /** Snippet ID if the animation was created from the snippet server */
  36534. snippetId: string;
  36535. /**
  36536. * Stores the key frames of the animation
  36537. */
  36538. private _keys;
  36539. /**
  36540. * Stores the easing function of the animation
  36541. */
  36542. private _easingFunction;
  36543. /**
  36544. * @hidden Internal use only
  36545. */
  36546. _runtimeAnimations: RuntimeAnimation[];
  36547. /**
  36548. * The set of event that will be linked to this animation
  36549. */
  36550. private _events;
  36551. /**
  36552. * Stores an array of target property paths
  36553. */
  36554. targetPropertyPath: string[];
  36555. /**
  36556. * Stores the blending speed of the animation
  36557. */
  36558. blendingSpeed: number;
  36559. /**
  36560. * Stores the animation ranges for the animation
  36561. */
  36562. private _ranges;
  36563. /**
  36564. * @hidden Internal use
  36565. */
  36566. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36567. /**
  36568. * Sets up an animation
  36569. * @param property The property to animate
  36570. * @param animationType The animation type to apply
  36571. * @param framePerSecond The frames per second of the animation
  36572. * @param easingFunction The easing function used in the animation
  36573. * @returns The created animation
  36574. */
  36575. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36576. /**
  36577. * Create and start an animation on a node
  36578. * @param name defines the name of the global animation that will be run on all nodes
  36579. * @param node defines the root node where the animation will take place
  36580. * @param targetProperty defines property to animate
  36581. * @param framePerSecond defines the number of frame per second yo use
  36582. * @param totalFrame defines the number of frames in total
  36583. * @param from defines the initial value
  36584. * @param to defines the final value
  36585. * @param loopMode defines which loop mode you want to use (off by default)
  36586. * @param easingFunction defines the easing function to use (linear by default)
  36587. * @param onAnimationEnd defines the callback to call when animation end
  36588. * @returns the animatable created for this animation
  36589. */
  36590. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36591. /**
  36592. * Create and start an animation on a node and its descendants
  36593. * @param name defines the name of the global animation that will be run on all nodes
  36594. * @param node defines the root node where the animation will take place
  36595. * @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
  36596. * @param targetProperty defines property to animate
  36597. * @param framePerSecond defines the number of frame per second to use
  36598. * @param totalFrame defines the number of frames in total
  36599. * @param from defines the initial value
  36600. * @param to defines the final value
  36601. * @param loopMode defines which loop mode you want to use (off by default)
  36602. * @param easingFunction defines the easing function to use (linear by default)
  36603. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36604. * @returns the list of animatables created for all nodes
  36605. * @example https://www.babylonjs-playground.com/#MH0VLI
  36606. */
  36607. 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[]>;
  36608. /**
  36609. * Creates a new animation, merges it with the existing animations and starts it
  36610. * @param name Name of the animation
  36611. * @param node Node which contains the scene that begins the animations
  36612. * @param targetProperty Specifies which property to animate
  36613. * @param framePerSecond The frames per second of the animation
  36614. * @param totalFrame The total number of frames
  36615. * @param from The frame at the beginning of the animation
  36616. * @param to The frame at the end of the animation
  36617. * @param loopMode Specifies the loop mode of the animation
  36618. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36619. * @param onAnimationEnd Callback to run once the animation is complete
  36620. * @returns Nullable animation
  36621. */
  36622. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36623. /**
  36624. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36625. * @param sourceAnimation defines the Animation containing keyframes to convert
  36626. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36627. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36628. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36629. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36630. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36631. */
  36632. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36633. /**
  36634. * Transition property of an host to the target Value
  36635. * @param property The property to transition
  36636. * @param targetValue The target Value of the property
  36637. * @param host The object where the property to animate belongs
  36638. * @param scene Scene used to run the animation
  36639. * @param frameRate Framerate (in frame/s) to use
  36640. * @param transition The transition type we want to use
  36641. * @param duration The duration of the animation, in milliseconds
  36642. * @param onAnimationEnd Callback trigger at the end of the animation
  36643. * @returns Nullable animation
  36644. */
  36645. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36646. /**
  36647. * Return the array of runtime animations currently using this animation
  36648. */
  36649. get runtimeAnimations(): RuntimeAnimation[];
  36650. /**
  36651. * Specifies if any of the runtime animations are currently running
  36652. */
  36653. get hasRunningRuntimeAnimations(): boolean;
  36654. /**
  36655. * Initializes the animation
  36656. * @param name Name of the animation
  36657. * @param targetProperty Property to animate
  36658. * @param framePerSecond The frames per second of the animation
  36659. * @param dataType The data type of the animation
  36660. * @param loopMode The loop mode of the animation
  36661. * @param enableBlending Specifies if blending should be enabled
  36662. */
  36663. constructor(
  36664. /**Name of the animation */
  36665. name: string,
  36666. /**Property to animate */
  36667. targetProperty: string,
  36668. /**The frames per second of the animation */
  36669. framePerSecond: number,
  36670. /**The data type of the animation */
  36671. dataType: number,
  36672. /**The loop mode of the animation */
  36673. loopMode?: number | undefined,
  36674. /**Specifies if blending should be enabled */
  36675. enableBlending?: boolean | undefined);
  36676. /**
  36677. * Converts the animation to a string
  36678. * @param fullDetails support for multiple levels of logging within scene loading
  36679. * @returns String form of the animation
  36680. */
  36681. toString(fullDetails?: boolean): string;
  36682. /**
  36683. * Add an event to this animation
  36684. * @param event Event to add
  36685. */
  36686. addEvent(event: AnimationEvent): void;
  36687. /**
  36688. * Remove all events found at the given frame
  36689. * @param frame The frame to remove events from
  36690. */
  36691. removeEvents(frame: number): void;
  36692. /**
  36693. * Retrieves all the events from the animation
  36694. * @returns Events from the animation
  36695. */
  36696. getEvents(): AnimationEvent[];
  36697. /**
  36698. * Creates an animation range
  36699. * @param name Name of the animation range
  36700. * @param from Starting frame of the animation range
  36701. * @param to Ending frame of the animation
  36702. */
  36703. createRange(name: string, from: number, to: number): void;
  36704. /**
  36705. * Deletes an animation range by name
  36706. * @param name Name of the animation range to delete
  36707. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36708. */
  36709. deleteRange(name: string, deleteFrames?: boolean): void;
  36710. /**
  36711. * Gets the animation range by name, or null if not defined
  36712. * @param name Name of the animation range
  36713. * @returns Nullable animation range
  36714. */
  36715. getRange(name: string): Nullable<AnimationRange>;
  36716. /**
  36717. * Gets the key frames from the animation
  36718. * @returns The key frames of the animation
  36719. */
  36720. getKeys(): Array<IAnimationKey>;
  36721. /**
  36722. * Gets the highest frame rate of the animation
  36723. * @returns Highest frame rate of the animation
  36724. */
  36725. getHighestFrame(): number;
  36726. /**
  36727. * Gets the easing function of the animation
  36728. * @returns Easing function of the animation
  36729. */
  36730. getEasingFunction(): IEasingFunction;
  36731. /**
  36732. * Sets the easing function of the animation
  36733. * @param easingFunction A custom mathematical formula for animation
  36734. */
  36735. setEasingFunction(easingFunction: EasingFunction): void;
  36736. /**
  36737. * Interpolates a scalar linearly
  36738. * @param startValue Start value of the animation curve
  36739. * @param endValue End value of the animation curve
  36740. * @param gradient Scalar amount to interpolate
  36741. * @returns Interpolated scalar value
  36742. */
  36743. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36744. /**
  36745. * Interpolates a scalar cubically
  36746. * @param startValue Start value of the animation curve
  36747. * @param outTangent End tangent of the animation
  36748. * @param endValue End value of the animation curve
  36749. * @param inTangent Start tangent of the animation curve
  36750. * @param gradient Scalar amount to interpolate
  36751. * @returns Interpolated scalar value
  36752. */
  36753. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36754. /**
  36755. * Interpolates a quaternion using a spherical linear interpolation
  36756. * @param startValue Start value of the animation curve
  36757. * @param endValue End value of the animation curve
  36758. * @param gradient Scalar amount to interpolate
  36759. * @returns Interpolated quaternion value
  36760. */
  36761. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36762. /**
  36763. * Interpolates a quaternion cubically
  36764. * @param startValue Start value of the animation curve
  36765. * @param outTangent End tangent of the animation curve
  36766. * @param endValue End value of the animation curve
  36767. * @param inTangent Start tangent of the animation curve
  36768. * @param gradient Scalar amount to interpolate
  36769. * @returns Interpolated quaternion value
  36770. */
  36771. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36772. /**
  36773. * Interpolates a Vector3 linearl
  36774. * @param startValue Start value of the animation curve
  36775. * @param endValue End value of the animation curve
  36776. * @param gradient Scalar amount to interpolate
  36777. * @returns Interpolated scalar value
  36778. */
  36779. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36780. /**
  36781. * Interpolates a Vector3 cubically
  36782. * @param startValue Start value of the animation curve
  36783. * @param outTangent End tangent of the animation
  36784. * @param endValue End value of the animation curve
  36785. * @param inTangent Start tangent of the animation curve
  36786. * @param gradient Scalar amount to interpolate
  36787. * @returns InterpolatedVector3 value
  36788. */
  36789. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36790. /**
  36791. * Interpolates a Vector2 linearly
  36792. * @param startValue Start value of the animation curve
  36793. * @param endValue End value of the animation curve
  36794. * @param gradient Scalar amount to interpolate
  36795. * @returns Interpolated Vector2 value
  36796. */
  36797. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36798. /**
  36799. * Interpolates a Vector2 cubically
  36800. * @param startValue Start value of the animation curve
  36801. * @param outTangent End tangent of the animation
  36802. * @param endValue End value of the animation curve
  36803. * @param inTangent Start tangent of the animation curve
  36804. * @param gradient Scalar amount to interpolate
  36805. * @returns Interpolated Vector2 value
  36806. */
  36807. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36808. /**
  36809. * Interpolates a size linearly
  36810. * @param startValue Start value of the animation curve
  36811. * @param endValue End value of the animation curve
  36812. * @param gradient Scalar amount to interpolate
  36813. * @returns Interpolated Size value
  36814. */
  36815. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36816. /**
  36817. * Interpolates a Color3 linearly
  36818. * @param startValue Start value of the animation curve
  36819. * @param endValue End value of the animation curve
  36820. * @param gradient Scalar amount to interpolate
  36821. * @returns Interpolated Color3 value
  36822. */
  36823. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36824. /**
  36825. * Interpolates a Color4 linearly
  36826. * @param startValue Start value of the animation curve
  36827. * @param endValue End value of the animation curve
  36828. * @param gradient Scalar amount to interpolate
  36829. * @returns Interpolated Color3 value
  36830. */
  36831. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36832. /**
  36833. * @hidden Internal use only
  36834. */
  36835. _getKeyValue(value: any): any;
  36836. /**
  36837. * @hidden Internal use only
  36838. */
  36839. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36840. /**
  36841. * Defines the function to use to interpolate matrices
  36842. * @param startValue defines the start matrix
  36843. * @param endValue defines the end matrix
  36844. * @param gradient defines the gradient between both matrices
  36845. * @param result defines an optional target matrix where to store the interpolation
  36846. * @returns the interpolated matrix
  36847. */
  36848. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36849. /**
  36850. * Makes a copy of the animation
  36851. * @returns Cloned animation
  36852. */
  36853. clone(): Animation;
  36854. /**
  36855. * Sets the key frames of the animation
  36856. * @param values The animation key frames to set
  36857. */
  36858. setKeys(values: Array<IAnimationKey>): void;
  36859. /**
  36860. * Serializes the animation to an object
  36861. * @returns Serialized object
  36862. */
  36863. serialize(): any;
  36864. /**
  36865. * Float animation type
  36866. */
  36867. static readonly ANIMATIONTYPE_FLOAT: number;
  36868. /**
  36869. * Vector3 animation type
  36870. */
  36871. static readonly ANIMATIONTYPE_VECTOR3: number;
  36872. /**
  36873. * Quaternion animation type
  36874. */
  36875. static readonly ANIMATIONTYPE_QUATERNION: number;
  36876. /**
  36877. * Matrix animation type
  36878. */
  36879. static readonly ANIMATIONTYPE_MATRIX: number;
  36880. /**
  36881. * Color3 animation type
  36882. */
  36883. static readonly ANIMATIONTYPE_COLOR3: number;
  36884. /**
  36885. * Color3 animation type
  36886. */
  36887. static readonly ANIMATIONTYPE_COLOR4: number;
  36888. /**
  36889. * Vector2 animation type
  36890. */
  36891. static readonly ANIMATIONTYPE_VECTOR2: number;
  36892. /**
  36893. * Size animation type
  36894. */
  36895. static readonly ANIMATIONTYPE_SIZE: number;
  36896. /**
  36897. * Relative Loop Mode
  36898. */
  36899. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36900. /**
  36901. * Cycle Loop Mode
  36902. */
  36903. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36904. /**
  36905. * Constant Loop Mode
  36906. */
  36907. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36908. /** @hidden */
  36909. static _UniversalLerp(left: any, right: any, amount: number): any;
  36910. /**
  36911. * Parses an animation object and creates an animation
  36912. * @param parsedAnimation Parsed animation object
  36913. * @returns Animation object
  36914. */
  36915. static Parse(parsedAnimation: any): Animation;
  36916. /**
  36917. * Appends the serialized animations from the source animations
  36918. * @param source Source containing the animations
  36919. * @param destination Target to store the animations
  36920. */
  36921. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36922. /**
  36923. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36924. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36925. * @param url defines the url to load from
  36926. * @returns a promise that will resolve to the new animation or an array of animations
  36927. */
  36928. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36929. /**
  36930. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36931. * @param snippetId defines the snippet to load
  36932. * @returns a promise that will resolve to the new animation or a new array of animations
  36933. */
  36934. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36935. }
  36936. }
  36937. declare module BABYLON {
  36938. /**
  36939. * Interface containing an array of animations
  36940. */
  36941. export interface IAnimatable {
  36942. /**
  36943. * Array of animations
  36944. */
  36945. animations: Nullable<Array<Animation>>;
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36950. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36951. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36952. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36953. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36954. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36955. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. /**
  36963. * Decorator used to define property that can be serialized as reference to a camera
  36964. * @param sourceName defines the name of the property to decorate
  36965. */
  36966. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36967. /**
  36968. * Class used to help serialization objects
  36969. */
  36970. export class SerializationHelper {
  36971. /** @hidden */
  36972. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36973. /** @hidden */
  36974. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36975. /** @hidden */
  36976. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36977. /** @hidden */
  36978. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36979. /**
  36980. * Appends the serialized animations from the source animations
  36981. * @param source Source containing the animations
  36982. * @param destination Target to store the animations
  36983. */
  36984. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36985. /**
  36986. * Static function used to serialized a specific entity
  36987. * @param entity defines the entity to serialize
  36988. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36989. * @returns a JSON compatible object representing the serialization of the entity
  36990. */
  36991. static Serialize<T>(entity: T, serializationObject?: any): any;
  36992. /**
  36993. * Creates a new entity from a serialization data object
  36994. * @param creationFunction defines a function used to instanciated the new entity
  36995. * @param source defines the source serialization data
  36996. * @param scene defines the hosting scene
  36997. * @param rootUrl defines the root url for resources
  36998. * @returns a new entity
  36999. */
  37000. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37001. /**
  37002. * Clones an object
  37003. * @param creationFunction defines the function used to instanciate the new object
  37004. * @param source defines the source object
  37005. * @returns the cloned object
  37006. */
  37007. static Clone<T>(creationFunction: () => T, source: T): T;
  37008. /**
  37009. * Instanciates a new object based on a source one (some data will be shared between both object)
  37010. * @param creationFunction defines the function used to instanciate the new object
  37011. * @param source defines the source object
  37012. * @returns the new object
  37013. */
  37014. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37015. }
  37016. }
  37017. declare module BABYLON {
  37018. /**
  37019. * Base class of all the textures in babylon.
  37020. * It groups all the common properties the materials, post process, lights... might need
  37021. * in order to make a correct use of the texture.
  37022. */
  37023. export class BaseTexture implements IAnimatable {
  37024. /**
  37025. * Default anisotropic filtering level for the application.
  37026. * It is set to 4 as a good tradeoff between perf and quality.
  37027. */
  37028. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37029. /**
  37030. * Gets or sets the unique id of the texture
  37031. */
  37032. uniqueId: number;
  37033. /**
  37034. * Define the name of the texture.
  37035. */
  37036. name: string;
  37037. /**
  37038. * Gets or sets an object used to store user defined information.
  37039. */
  37040. metadata: any;
  37041. /**
  37042. * For internal use only. Please do not use.
  37043. */
  37044. reservedDataStore: any;
  37045. private _hasAlpha;
  37046. /**
  37047. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37048. */
  37049. set hasAlpha(value: boolean);
  37050. get hasAlpha(): boolean;
  37051. /**
  37052. * Defines if the alpha value should be determined via the rgb values.
  37053. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37054. */
  37055. getAlphaFromRGB: boolean;
  37056. /**
  37057. * Intensity or strength of the texture.
  37058. * It is commonly used by materials to fine tune the intensity of the texture
  37059. */
  37060. level: number;
  37061. /**
  37062. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37063. * This is part of the texture as textures usually maps to one uv set.
  37064. */
  37065. coordinatesIndex: number;
  37066. protected _coordinatesMode: number;
  37067. /**
  37068. * How a texture is mapped.
  37069. *
  37070. * | Value | Type | Description |
  37071. * | ----- | ----------------------------------- | ----------- |
  37072. * | 0 | EXPLICIT_MODE | |
  37073. * | 1 | SPHERICAL_MODE | |
  37074. * | 2 | PLANAR_MODE | |
  37075. * | 3 | CUBIC_MODE | |
  37076. * | 4 | PROJECTION_MODE | |
  37077. * | 5 | SKYBOX_MODE | |
  37078. * | 6 | INVCUBIC_MODE | |
  37079. * | 7 | EQUIRECTANGULAR_MODE | |
  37080. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37081. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37082. */
  37083. set coordinatesMode(value: number);
  37084. get coordinatesMode(): number;
  37085. private _wrapU;
  37086. /**
  37087. * | Value | Type | Description |
  37088. * | ----- | ------------------ | ----------- |
  37089. * | 0 | CLAMP_ADDRESSMODE | |
  37090. * | 1 | WRAP_ADDRESSMODE | |
  37091. * | 2 | MIRROR_ADDRESSMODE | |
  37092. */
  37093. get wrapU(): number;
  37094. set wrapU(value: number);
  37095. private _wrapV;
  37096. /**
  37097. * | Value | Type | Description |
  37098. * | ----- | ------------------ | ----------- |
  37099. * | 0 | CLAMP_ADDRESSMODE | |
  37100. * | 1 | WRAP_ADDRESSMODE | |
  37101. * | 2 | MIRROR_ADDRESSMODE | |
  37102. */
  37103. get wrapV(): number;
  37104. set wrapV(value: number);
  37105. /**
  37106. * | Value | Type | Description |
  37107. * | ----- | ------------------ | ----------- |
  37108. * | 0 | CLAMP_ADDRESSMODE | |
  37109. * | 1 | WRAP_ADDRESSMODE | |
  37110. * | 2 | MIRROR_ADDRESSMODE | |
  37111. */
  37112. wrapR: number;
  37113. /**
  37114. * With compliant hardware and browser (supporting anisotropic filtering)
  37115. * this defines the level of anisotropic filtering in the texture.
  37116. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37117. */
  37118. anisotropicFilteringLevel: number;
  37119. /**
  37120. * Define if the texture is a cube texture or if false a 2d texture.
  37121. */
  37122. get isCube(): boolean;
  37123. set isCube(value: boolean);
  37124. /**
  37125. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37126. */
  37127. get is3D(): boolean;
  37128. set is3D(value: boolean);
  37129. /**
  37130. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37131. */
  37132. get is2DArray(): boolean;
  37133. set is2DArray(value: boolean);
  37134. private _gammaSpace;
  37135. /**
  37136. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37137. * HDR texture are usually stored in linear space.
  37138. * This only impacts the PBR and Background materials
  37139. */
  37140. get gammaSpace(): boolean;
  37141. set gammaSpace(gamma: boolean);
  37142. /**
  37143. * Gets or sets whether or not the texture contains RGBD data.
  37144. */
  37145. get isRGBD(): boolean;
  37146. set isRGBD(value: boolean);
  37147. /**
  37148. * Is Z inverted in the texture (useful in a cube texture).
  37149. */
  37150. invertZ: boolean;
  37151. /**
  37152. * Are mip maps generated for this texture or not.
  37153. */
  37154. get noMipmap(): boolean;
  37155. /**
  37156. * @hidden
  37157. */
  37158. lodLevelInAlpha: boolean;
  37159. /**
  37160. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37161. */
  37162. get lodGenerationOffset(): number;
  37163. set lodGenerationOffset(value: number);
  37164. /**
  37165. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37166. */
  37167. get lodGenerationScale(): number;
  37168. set lodGenerationScale(value: number);
  37169. /**
  37170. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37171. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37172. * average roughness values.
  37173. */
  37174. get linearSpecularLOD(): boolean;
  37175. set linearSpecularLOD(value: boolean);
  37176. /**
  37177. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37178. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37179. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37180. */
  37181. get irradianceTexture(): Nullable<BaseTexture>;
  37182. set irradianceTexture(value: Nullable<BaseTexture>);
  37183. /**
  37184. * Define if the texture is a render target.
  37185. */
  37186. isRenderTarget: boolean;
  37187. /**
  37188. * Define the unique id of the texture in the scene.
  37189. */
  37190. get uid(): string;
  37191. /** @hidden */
  37192. _prefiltered: boolean;
  37193. /**
  37194. * Return a string representation of the texture.
  37195. * @returns the texture as a string
  37196. */
  37197. toString(): string;
  37198. /**
  37199. * Get the class name of the texture.
  37200. * @returns "BaseTexture"
  37201. */
  37202. getClassName(): string;
  37203. /**
  37204. * Define the list of animation attached to the texture.
  37205. */
  37206. animations: Animation[];
  37207. /**
  37208. * An event triggered when the texture is disposed.
  37209. */
  37210. onDisposeObservable: Observable<BaseTexture>;
  37211. private _onDisposeObserver;
  37212. /**
  37213. * Callback triggered when the texture has been disposed.
  37214. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37215. */
  37216. set onDispose(callback: () => void);
  37217. /**
  37218. * Define the current state of the loading sequence when in delayed load mode.
  37219. */
  37220. delayLoadState: number;
  37221. protected _scene: Nullable<Scene>;
  37222. protected _engine: Nullable<ThinEngine>;
  37223. /** @hidden */
  37224. _texture: Nullable<InternalTexture>;
  37225. private _uid;
  37226. /**
  37227. * Define if the texture is preventinga material to render or not.
  37228. * If not and the texture is not ready, the engine will use a default black texture instead.
  37229. */
  37230. get isBlocking(): boolean;
  37231. /**
  37232. * Instantiates a new BaseTexture.
  37233. * Base class of all the textures in babylon.
  37234. * It groups all the common properties the materials, post process, lights... might need
  37235. * in order to make a correct use of the texture.
  37236. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37237. */
  37238. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37239. /**
  37240. * Get the scene the texture belongs to.
  37241. * @returns the scene or null if undefined
  37242. */
  37243. getScene(): Nullable<Scene>;
  37244. /** @hidden */
  37245. protected _getEngine(): Nullable<ThinEngine>;
  37246. /**
  37247. * Checks if the texture has the same transform matrix than another texture
  37248. * @param texture texture to check against
  37249. * @returns true if the transforms are the same, else false
  37250. */
  37251. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37252. /**
  37253. * Get the texture transform matrix used to offset tile the texture for istance.
  37254. * @returns the transformation matrix
  37255. */
  37256. getTextureMatrix(): Matrix;
  37257. /**
  37258. * Get the texture reflection matrix used to rotate/transform the reflection.
  37259. * @returns the reflection matrix
  37260. */
  37261. getReflectionTextureMatrix(): Matrix;
  37262. /**
  37263. * Get the underlying lower level texture from Babylon.
  37264. * @returns the insternal texture
  37265. */
  37266. getInternalTexture(): Nullable<InternalTexture>;
  37267. /**
  37268. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37269. * @returns true if ready or not blocking
  37270. */
  37271. isReadyOrNotBlocking(): boolean;
  37272. /**
  37273. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37274. * @returns true if fully ready
  37275. */
  37276. isReady(): boolean;
  37277. private _cachedSize;
  37278. /**
  37279. * Get the size of the texture.
  37280. * @returns the texture size.
  37281. */
  37282. getSize(): ISize;
  37283. /**
  37284. * Get the base size of the texture.
  37285. * It can be different from the size if the texture has been resized for POT for instance
  37286. * @returns the base size
  37287. */
  37288. getBaseSize(): ISize;
  37289. /**
  37290. * Update the sampling mode of the texture.
  37291. * Default is Trilinear mode.
  37292. *
  37293. * | Value | Type | Description |
  37294. * | ----- | ------------------ | ----------- |
  37295. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37296. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37297. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37298. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37299. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37300. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37301. * | 7 | NEAREST_LINEAR | |
  37302. * | 8 | NEAREST_NEAREST | |
  37303. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37304. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37305. * | 11 | LINEAR_LINEAR | |
  37306. * | 12 | LINEAR_NEAREST | |
  37307. *
  37308. * > _mag_: magnification filter (close to the viewer)
  37309. * > _min_: minification filter (far from the viewer)
  37310. * > _mip_: filter used between mip map levels
  37311. *@param samplingMode Define the new sampling mode of the texture
  37312. */
  37313. updateSamplingMode(samplingMode: number): void;
  37314. /**
  37315. * Scales the texture if is `canRescale()`
  37316. * @param ratio the resize factor we want to use to rescale
  37317. */
  37318. scale(ratio: number): void;
  37319. /**
  37320. * Get if the texture can rescale.
  37321. */
  37322. get canRescale(): boolean;
  37323. /** @hidden */
  37324. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37325. /** @hidden */
  37326. _rebuild(): void;
  37327. /**
  37328. * Triggers the load sequence in delayed load mode.
  37329. */
  37330. delayLoad(): void;
  37331. /**
  37332. * Clones the texture.
  37333. * @returns the cloned texture
  37334. */
  37335. clone(): Nullable<BaseTexture>;
  37336. /**
  37337. * Get the texture underlying type (INT, FLOAT...)
  37338. */
  37339. get textureType(): number;
  37340. /**
  37341. * Get the texture underlying format (RGB, RGBA...)
  37342. */
  37343. get textureFormat(): number;
  37344. /**
  37345. * Indicates that textures need to be re-calculated for all materials
  37346. */
  37347. protected _markAllSubMeshesAsTexturesDirty(): void;
  37348. /**
  37349. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37350. * This will returns an RGBA array buffer containing either in values (0-255) or
  37351. * float values (0-1) depending of the underlying buffer type.
  37352. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37353. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37354. * @param buffer defines a user defined buffer to fill with data (can be null)
  37355. * @returns The Array buffer containing the pixels data.
  37356. */
  37357. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37358. /**
  37359. * Release and destroy the underlying lower level texture aka internalTexture.
  37360. */
  37361. releaseInternalTexture(): void;
  37362. /** @hidden */
  37363. get _lodTextureHigh(): Nullable<BaseTexture>;
  37364. /** @hidden */
  37365. get _lodTextureMid(): Nullable<BaseTexture>;
  37366. /** @hidden */
  37367. get _lodTextureLow(): Nullable<BaseTexture>;
  37368. /**
  37369. * Dispose the texture and release its associated resources.
  37370. */
  37371. dispose(): void;
  37372. /**
  37373. * Serialize the texture into a JSON representation that can be parsed later on.
  37374. * @returns the JSON representation of the texture
  37375. */
  37376. serialize(): any;
  37377. /**
  37378. * Helper function to be called back once a list of texture contains only ready textures.
  37379. * @param textures Define the list of textures to wait for
  37380. * @param callback Define the callback triggered once the entire list will be ready
  37381. */
  37382. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37383. private static _isScene;
  37384. }
  37385. }
  37386. declare module BABYLON {
  37387. /**
  37388. * Options to be used when creating an effect.
  37389. */
  37390. export interface IEffectCreationOptions {
  37391. /**
  37392. * Atrributes that will be used in the shader.
  37393. */
  37394. attributes: string[];
  37395. /**
  37396. * Uniform varible names that will be set in the shader.
  37397. */
  37398. uniformsNames: string[];
  37399. /**
  37400. * Uniform buffer variable names that will be set in the shader.
  37401. */
  37402. uniformBuffersNames: string[];
  37403. /**
  37404. * Sampler texture variable names that will be set in the shader.
  37405. */
  37406. samplers: string[];
  37407. /**
  37408. * Define statements that will be set in the shader.
  37409. */
  37410. defines: any;
  37411. /**
  37412. * Possible fallbacks for this effect to improve performance when needed.
  37413. */
  37414. fallbacks: Nullable<IEffectFallbacks>;
  37415. /**
  37416. * Callback that will be called when the shader is compiled.
  37417. */
  37418. onCompiled: Nullable<(effect: Effect) => void>;
  37419. /**
  37420. * Callback that will be called if an error occurs during shader compilation.
  37421. */
  37422. onError: Nullable<(effect: Effect, errors: string) => void>;
  37423. /**
  37424. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37425. */
  37426. indexParameters?: any;
  37427. /**
  37428. * Max number of lights that can be used in the shader.
  37429. */
  37430. maxSimultaneousLights?: number;
  37431. /**
  37432. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37433. */
  37434. transformFeedbackVaryings?: Nullable<string[]>;
  37435. /**
  37436. * 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
  37437. */
  37438. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37439. /**
  37440. * Is this effect rendering to several color attachments ?
  37441. */
  37442. multiTarget?: boolean;
  37443. }
  37444. /**
  37445. * Effect containing vertex and fragment shader that can be executed on an object.
  37446. */
  37447. export class Effect implements IDisposable {
  37448. /**
  37449. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37450. */
  37451. static ShadersRepository: string;
  37452. /**
  37453. * Enable logging of the shader code when a compilation error occurs
  37454. */
  37455. static LogShaderCodeOnCompilationError: boolean;
  37456. /**
  37457. * Name of the effect.
  37458. */
  37459. name: any;
  37460. /**
  37461. * String container all the define statements that should be set on the shader.
  37462. */
  37463. defines: string;
  37464. /**
  37465. * Callback that will be called when the shader is compiled.
  37466. */
  37467. onCompiled: Nullable<(effect: Effect) => void>;
  37468. /**
  37469. * Callback that will be called if an error occurs during shader compilation.
  37470. */
  37471. onError: Nullable<(effect: Effect, errors: string) => void>;
  37472. /**
  37473. * Callback that will be called when effect is bound.
  37474. */
  37475. onBind: Nullable<(effect: Effect) => void>;
  37476. /**
  37477. * Unique ID of the effect.
  37478. */
  37479. uniqueId: number;
  37480. /**
  37481. * Observable that will be called when the shader is compiled.
  37482. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37483. */
  37484. onCompileObservable: Observable<Effect>;
  37485. /**
  37486. * Observable that will be called if an error occurs during shader compilation.
  37487. */
  37488. onErrorObservable: Observable<Effect>;
  37489. /** @hidden */
  37490. _onBindObservable: Nullable<Observable<Effect>>;
  37491. /**
  37492. * @hidden
  37493. * Specifies if the effect was previously ready
  37494. */
  37495. _wasPreviouslyReady: boolean;
  37496. /**
  37497. * Observable that will be called when effect is bound.
  37498. */
  37499. get onBindObservable(): Observable<Effect>;
  37500. /** @hidden */
  37501. _bonesComputationForcedToCPU: boolean;
  37502. /** @hidden */
  37503. _multiTarget: boolean;
  37504. private static _uniqueIdSeed;
  37505. private _engine;
  37506. private _uniformBuffersNames;
  37507. private _uniformBuffersNamesList;
  37508. private _uniformsNames;
  37509. private _samplerList;
  37510. private _samplers;
  37511. private _isReady;
  37512. private _compilationError;
  37513. private _allFallbacksProcessed;
  37514. private _attributesNames;
  37515. private _attributes;
  37516. private _attributeLocationByName;
  37517. private _uniforms;
  37518. /**
  37519. * Key for the effect.
  37520. * @hidden
  37521. */
  37522. _key: string;
  37523. private _indexParameters;
  37524. private _fallbacks;
  37525. private _vertexSourceCode;
  37526. private _fragmentSourceCode;
  37527. private _vertexSourceCodeOverride;
  37528. private _fragmentSourceCodeOverride;
  37529. private _transformFeedbackVaryings;
  37530. /**
  37531. * Compiled shader to webGL program.
  37532. * @hidden
  37533. */
  37534. _pipelineContext: Nullable<IPipelineContext>;
  37535. private _valueCache;
  37536. private static _baseCache;
  37537. /**
  37538. * Instantiates an effect.
  37539. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37540. * @param baseName Name of the effect.
  37541. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37542. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37543. * @param samplers List of sampler variables that will be passed to the shader.
  37544. * @param engine Engine to be used to render the effect
  37545. * @param defines Define statements to be added to the shader.
  37546. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37547. * @param onCompiled Callback that will be called when the shader is compiled.
  37548. * @param onError Callback that will be called if an error occurs during shader compilation.
  37549. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37550. */
  37551. 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);
  37552. private _useFinalCode;
  37553. /**
  37554. * Unique key for this effect
  37555. */
  37556. get key(): string;
  37557. /**
  37558. * If the effect has been compiled and prepared.
  37559. * @returns if the effect is compiled and prepared.
  37560. */
  37561. isReady(): boolean;
  37562. private _isReadyInternal;
  37563. /**
  37564. * The engine the effect was initialized with.
  37565. * @returns the engine.
  37566. */
  37567. getEngine(): Engine;
  37568. /**
  37569. * The pipeline context for this effect
  37570. * @returns the associated pipeline context
  37571. */
  37572. getPipelineContext(): Nullable<IPipelineContext>;
  37573. /**
  37574. * The set of names of attribute variables for the shader.
  37575. * @returns An array of attribute names.
  37576. */
  37577. getAttributesNames(): string[];
  37578. /**
  37579. * Returns the attribute at the given index.
  37580. * @param index The index of the attribute.
  37581. * @returns The location of the attribute.
  37582. */
  37583. getAttributeLocation(index: number): number;
  37584. /**
  37585. * Returns the attribute based on the name of the variable.
  37586. * @param name of the attribute to look up.
  37587. * @returns the attribute location.
  37588. */
  37589. getAttributeLocationByName(name: string): number;
  37590. /**
  37591. * The number of attributes.
  37592. * @returns the numnber of attributes.
  37593. */
  37594. getAttributesCount(): number;
  37595. /**
  37596. * Gets the index of a uniform variable.
  37597. * @param uniformName of the uniform to look up.
  37598. * @returns the index.
  37599. */
  37600. getUniformIndex(uniformName: string): number;
  37601. /**
  37602. * Returns the attribute based on the name of the variable.
  37603. * @param uniformName of the uniform to look up.
  37604. * @returns the location of the uniform.
  37605. */
  37606. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37607. /**
  37608. * Returns an array of sampler variable names
  37609. * @returns The array of sampler variable names.
  37610. */
  37611. getSamplers(): string[];
  37612. /**
  37613. * Returns an array of uniform variable names
  37614. * @returns The array of uniform variable names.
  37615. */
  37616. getUniformNames(): string[];
  37617. /**
  37618. * Returns an array of uniform buffer variable names
  37619. * @returns The array of uniform buffer variable names.
  37620. */
  37621. getUniformBuffersNames(): string[];
  37622. /**
  37623. * Returns the index parameters used to create the effect
  37624. * @returns The index parameters object
  37625. */
  37626. getIndexParameters(): any;
  37627. /**
  37628. * The error from the last compilation.
  37629. * @returns the error string.
  37630. */
  37631. getCompilationError(): string;
  37632. /**
  37633. * Gets a boolean indicating that all fallbacks were used during compilation
  37634. * @returns true if all fallbacks were used
  37635. */
  37636. allFallbacksProcessed(): boolean;
  37637. /**
  37638. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37639. * @param func The callback to be used.
  37640. */
  37641. executeWhenCompiled(func: (effect: Effect) => void): void;
  37642. private _checkIsReady;
  37643. private _loadShader;
  37644. /**
  37645. * Gets the vertex shader source code of this effect
  37646. */
  37647. get vertexSourceCode(): string;
  37648. /**
  37649. * Gets the fragment shader source code of this effect
  37650. */
  37651. get fragmentSourceCode(): string;
  37652. /**
  37653. * Recompiles the webGL program
  37654. * @param vertexSourceCode The source code for the vertex shader.
  37655. * @param fragmentSourceCode The source code for the fragment shader.
  37656. * @param onCompiled Callback called when completed.
  37657. * @param onError Callback called on error.
  37658. * @hidden
  37659. */
  37660. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37661. /**
  37662. * Prepares the effect
  37663. * @hidden
  37664. */
  37665. _prepareEffect(): void;
  37666. private _getShaderCodeAndErrorLine;
  37667. private _processCompilationErrors;
  37668. /**
  37669. * Checks if the effect is supported. (Must be called after compilation)
  37670. */
  37671. get isSupported(): boolean;
  37672. /**
  37673. * Binds a texture to the engine to be used as output of the shader.
  37674. * @param channel Name of the output variable.
  37675. * @param texture Texture to bind.
  37676. * @hidden
  37677. */
  37678. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37679. /**
  37680. * Sets a texture on the engine to be used in the shader.
  37681. * @param channel Name of the sampler variable.
  37682. * @param texture Texture to set.
  37683. */
  37684. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37685. /**
  37686. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37687. * @param channel Name of the sampler variable.
  37688. * @param texture Texture to set.
  37689. */
  37690. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37691. /**
  37692. * Sets an array of textures on the engine to be used in the shader.
  37693. * @param channel Name of the variable.
  37694. * @param textures Textures to set.
  37695. */
  37696. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37697. /**
  37698. * 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)
  37699. * @param channel Name of the sampler variable.
  37700. * @param postProcess Post process to get the input texture from.
  37701. */
  37702. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37703. /**
  37704. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37705. * 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)
  37706. * @param channel Name of the sampler variable.
  37707. * @param postProcess Post process to get the output texture from.
  37708. */
  37709. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37710. /** @hidden */
  37711. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37712. /** @hidden */
  37713. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37714. /** @hidden */
  37715. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37716. /** @hidden */
  37717. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37718. /**
  37719. * Binds a buffer to a uniform.
  37720. * @param buffer Buffer to bind.
  37721. * @param name Name of the uniform variable to bind to.
  37722. */
  37723. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37724. /**
  37725. * Binds block to a uniform.
  37726. * @param blockName Name of the block to bind.
  37727. * @param index Index to bind.
  37728. */
  37729. bindUniformBlock(blockName: string, index: number): void;
  37730. /**
  37731. * Sets an interger value on a uniform variable.
  37732. * @param uniformName Name of the variable.
  37733. * @param value Value to be set.
  37734. * @returns this effect.
  37735. */
  37736. setInt(uniformName: string, value: number): Effect;
  37737. /**
  37738. * Sets an int array on a uniform variable.
  37739. * @param uniformName Name of the variable.
  37740. * @param array array to be set.
  37741. * @returns this effect.
  37742. */
  37743. setIntArray(uniformName: string, array: Int32Array): Effect;
  37744. /**
  37745. * 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)
  37746. * @param uniformName Name of the variable.
  37747. * @param array array to be set.
  37748. * @returns this effect.
  37749. */
  37750. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37751. /**
  37752. * 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)
  37753. * @param uniformName Name of the variable.
  37754. * @param array array to be set.
  37755. * @returns this effect.
  37756. */
  37757. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37758. /**
  37759. * 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)
  37760. * @param uniformName Name of the variable.
  37761. * @param array array to be set.
  37762. * @returns this effect.
  37763. */
  37764. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37765. /**
  37766. * Sets an float array on a uniform variable.
  37767. * @param uniformName Name of the variable.
  37768. * @param array array to be set.
  37769. * @returns this effect.
  37770. */
  37771. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37772. /**
  37773. * 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)
  37774. * @param uniformName Name of the variable.
  37775. * @param array array to be set.
  37776. * @returns this effect.
  37777. */
  37778. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37779. /**
  37780. * 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)
  37781. * @param uniformName Name of the variable.
  37782. * @param array array to be set.
  37783. * @returns this effect.
  37784. */
  37785. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37786. /**
  37787. * 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)
  37788. * @param uniformName Name of the variable.
  37789. * @param array array to be set.
  37790. * @returns this effect.
  37791. */
  37792. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37793. /**
  37794. * Sets an array on a uniform variable.
  37795. * @param uniformName Name of the variable.
  37796. * @param array array to be set.
  37797. * @returns this effect.
  37798. */
  37799. setArray(uniformName: string, array: number[]): Effect;
  37800. /**
  37801. * 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)
  37802. * @param uniformName Name of the variable.
  37803. * @param array array to be set.
  37804. * @returns this effect.
  37805. */
  37806. setArray2(uniformName: string, array: number[]): Effect;
  37807. /**
  37808. * 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)
  37809. * @param uniformName Name of the variable.
  37810. * @param array array to be set.
  37811. * @returns this effect.
  37812. */
  37813. setArray3(uniformName: string, array: number[]): Effect;
  37814. /**
  37815. * 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)
  37816. * @param uniformName Name of the variable.
  37817. * @param array array to be set.
  37818. * @returns this effect.
  37819. */
  37820. setArray4(uniformName: string, array: number[]): Effect;
  37821. /**
  37822. * Sets matrices on a uniform variable.
  37823. * @param uniformName Name of the variable.
  37824. * @param matrices matrices to be set.
  37825. * @returns this effect.
  37826. */
  37827. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37828. /**
  37829. * Sets matrix on a uniform variable.
  37830. * @param uniformName Name of the variable.
  37831. * @param matrix matrix to be set.
  37832. * @returns this effect.
  37833. */
  37834. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37835. /**
  37836. * 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)
  37837. * @param uniformName Name of the variable.
  37838. * @param matrix matrix to be set.
  37839. * @returns this effect.
  37840. */
  37841. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37842. /**
  37843. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37844. * @param uniformName Name of the variable.
  37845. * @param matrix matrix to be set.
  37846. * @returns this effect.
  37847. */
  37848. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37849. /**
  37850. * Sets a float on a uniform variable.
  37851. * @param uniformName Name of the variable.
  37852. * @param value value to be set.
  37853. * @returns this effect.
  37854. */
  37855. setFloat(uniformName: string, value: number): Effect;
  37856. /**
  37857. * Sets a boolean on a uniform variable.
  37858. * @param uniformName Name of the variable.
  37859. * @param bool value to be set.
  37860. * @returns this effect.
  37861. */
  37862. setBool(uniformName: string, bool: boolean): Effect;
  37863. /**
  37864. * Sets a Vector2 on a uniform variable.
  37865. * @param uniformName Name of the variable.
  37866. * @param vector2 vector2 to be set.
  37867. * @returns this effect.
  37868. */
  37869. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37870. /**
  37871. * Sets a float2 on a uniform variable.
  37872. * @param uniformName Name of the variable.
  37873. * @param x First float in float2.
  37874. * @param y Second float in float2.
  37875. * @returns this effect.
  37876. */
  37877. setFloat2(uniformName: string, x: number, y: number): Effect;
  37878. /**
  37879. * Sets a Vector3 on a uniform variable.
  37880. * @param uniformName Name of the variable.
  37881. * @param vector3 Value to be set.
  37882. * @returns this effect.
  37883. */
  37884. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37885. /**
  37886. * Sets a float3 on a uniform variable.
  37887. * @param uniformName Name of the variable.
  37888. * @param x First float in float3.
  37889. * @param y Second float in float3.
  37890. * @param z Third float in float3.
  37891. * @returns this effect.
  37892. */
  37893. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37894. /**
  37895. * Sets a Vector4 on a uniform variable.
  37896. * @param uniformName Name of the variable.
  37897. * @param vector4 Value to be set.
  37898. * @returns this effect.
  37899. */
  37900. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37901. /**
  37902. * Sets a float4 on a uniform variable.
  37903. * @param uniformName Name of the variable.
  37904. * @param x First float in float4.
  37905. * @param y Second float in float4.
  37906. * @param z Third float in float4.
  37907. * @param w Fourth float in float4.
  37908. * @returns this effect.
  37909. */
  37910. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37911. /**
  37912. * Sets a Color3 on a uniform variable.
  37913. * @param uniformName Name of the variable.
  37914. * @param color3 Value to be set.
  37915. * @returns this effect.
  37916. */
  37917. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37918. /**
  37919. * Sets a Color4 on a uniform variable.
  37920. * @param uniformName Name of the variable.
  37921. * @param color3 Value to be set.
  37922. * @param alpha Alpha value to be set.
  37923. * @returns this effect.
  37924. */
  37925. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37926. /**
  37927. * Sets a Color4 on a uniform variable
  37928. * @param uniformName defines the name of the variable
  37929. * @param color4 defines the value to be set
  37930. * @returns this effect.
  37931. */
  37932. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37933. /** Release all associated resources */
  37934. dispose(): void;
  37935. /**
  37936. * This function will add a new shader to the shader store
  37937. * @param name the name of the shader
  37938. * @param pixelShader optional pixel shader content
  37939. * @param vertexShader optional vertex shader content
  37940. */
  37941. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37942. /**
  37943. * Store of each shader (The can be looked up using effect.key)
  37944. */
  37945. static ShadersStore: {
  37946. [key: string]: string;
  37947. };
  37948. /**
  37949. * Store of each included file for a shader (The can be looked up using effect.key)
  37950. */
  37951. static IncludesShadersStore: {
  37952. [key: string]: string;
  37953. };
  37954. /**
  37955. * Resets the cache of effects.
  37956. */
  37957. static ResetCache(): void;
  37958. }
  37959. }
  37960. declare module BABYLON {
  37961. /**
  37962. * Interface used to describe the capabilities of the engine relatively to the current browser
  37963. */
  37964. export interface EngineCapabilities {
  37965. /** Maximum textures units per fragment shader */
  37966. maxTexturesImageUnits: number;
  37967. /** Maximum texture units per vertex shader */
  37968. maxVertexTextureImageUnits: number;
  37969. /** Maximum textures units in the entire pipeline */
  37970. maxCombinedTexturesImageUnits: number;
  37971. /** Maximum texture size */
  37972. maxTextureSize: number;
  37973. /** Maximum texture samples */
  37974. maxSamples?: number;
  37975. /** Maximum cube texture size */
  37976. maxCubemapTextureSize: number;
  37977. /** Maximum render texture size */
  37978. maxRenderTextureSize: number;
  37979. /** Maximum number of vertex attributes */
  37980. maxVertexAttribs: number;
  37981. /** Maximum number of varyings */
  37982. maxVaryingVectors: number;
  37983. /** Maximum number of uniforms per vertex shader */
  37984. maxVertexUniformVectors: number;
  37985. /** Maximum number of uniforms per fragment shader */
  37986. maxFragmentUniformVectors: number;
  37987. /** Defines if standard derivates (dx/dy) are supported */
  37988. standardDerivatives: boolean;
  37989. /** Defines if s3tc texture compression is supported */
  37990. s3tc?: WEBGL_compressed_texture_s3tc;
  37991. /** Defines if pvrtc texture compression is supported */
  37992. pvrtc: any;
  37993. /** Defines if etc1 texture compression is supported */
  37994. etc1: any;
  37995. /** Defines if etc2 texture compression is supported */
  37996. etc2: any;
  37997. /** Defines if astc texture compression is supported */
  37998. astc: any;
  37999. /** Defines if bptc texture compression is supported */
  38000. bptc: any;
  38001. /** Defines if float textures are supported */
  38002. textureFloat: boolean;
  38003. /** Defines if vertex array objects are supported */
  38004. vertexArrayObject: boolean;
  38005. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38006. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38007. /** Gets the maximum level of anisotropy supported */
  38008. maxAnisotropy: number;
  38009. /** Defines if instancing is supported */
  38010. instancedArrays: boolean;
  38011. /** Defines if 32 bits indices are supported */
  38012. uintIndices: boolean;
  38013. /** Defines if high precision shaders are supported */
  38014. highPrecisionShaderSupported: boolean;
  38015. /** Defines if depth reading in the fragment shader is supported */
  38016. fragmentDepthSupported: boolean;
  38017. /** Defines if float texture linear filtering is supported*/
  38018. textureFloatLinearFiltering: boolean;
  38019. /** Defines if rendering to float textures is supported */
  38020. textureFloatRender: boolean;
  38021. /** Defines if half float textures are supported*/
  38022. textureHalfFloat: boolean;
  38023. /** Defines if half float texture linear filtering is supported*/
  38024. textureHalfFloatLinearFiltering: boolean;
  38025. /** Defines if rendering to half float textures is supported */
  38026. textureHalfFloatRender: boolean;
  38027. /** Defines if textureLOD shader command is supported */
  38028. textureLOD: boolean;
  38029. /** Defines if draw buffers extension is supported */
  38030. drawBuffersExtension: boolean;
  38031. /** Defines if depth textures are supported */
  38032. depthTextureExtension: boolean;
  38033. /** Defines if float color buffer are supported */
  38034. colorBufferFloat: boolean;
  38035. /** Gets disjoint timer query extension (null if not supported) */
  38036. timerQuery?: EXT_disjoint_timer_query;
  38037. /** Defines if timestamp can be used with timer query */
  38038. canUseTimestampForTimerQuery: boolean;
  38039. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38040. multiview?: any;
  38041. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38042. oculusMultiview?: any;
  38043. /** Function used to let the system compiles shaders in background */
  38044. parallelShaderCompile?: {
  38045. COMPLETION_STATUS_KHR: number;
  38046. };
  38047. /** Max number of texture samples for MSAA */
  38048. maxMSAASamples: number;
  38049. /** Defines if the blend min max extension is supported */
  38050. blendMinMax: boolean;
  38051. }
  38052. }
  38053. declare module BABYLON {
  38054. /**
  38055. * @hidden
  38056. **/
  38057. export class DepthCullingState {
  38058. private _isDepthTestDirty;
  38059. private _isDepthMaskDirty;
  38060. private _isDepthFuncDirty;
  38061. private _isCullFaceDirty;
  38062. private _isCullDirty;
  38063. private _isZOffsetDirty;
  38064. private _isFrontFaceDirty;
  38065. private _depthTest;
  38066. private _depthMask;
  38067. private _depthFunc;
  38068. private _cull;
  38069. private _cullFace;
  38070. private _zOffset;
  38071. private _frontFace;
  38072. /**
  38073. * Initializes the state.
  38074. */
  38075. constructor();
  38076. get isDirty(): boolean;
  38077. get zOffset(): number;
  38078. set zOffset(value: number);
  38079. get cullFace(): Nullable<number>;
  38080. set cullFace(value: Nullable<number>);
  38081. get cull(): Nullable<boolean>;
  38082. set cull(value: Nullable<boolean>);
  38083. get depthFunc(): Nullable<number>;
  38084. set depthFunc(value: Nullable<number>);
  38085. get depthMask(): boolean;
  38086. set depthMask(value: boolean);
  38087. get depthTest(): boolean;
  38088. set depthTest(value: boolean);
  38089. get frontFace(): Nullable<number>;
  38090. set frontFace(value: Nullable<number>);
  38091. reset(): void;
  38092. apply(gl: WebGLRenderingContext): void;
  38093. }
  38094. }
  38095. declare module BABYLON {
  38096. /**
  38097. * @hidden
  38098. **/
  38099. export class StencilState {
  38100. /** 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 */
  38101. static readonly ALWAYS: number;
  38102. /** Passed to stencilOperation to specify that stencil value must be kept */
  38103. static readonly KEEP: number;
  38104. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38105. static readonly REPLACE: number;
  38106. private _isStencilTestDirty;
  38107. private _isStencilMaskDirty;
  38108. private _isStencilFuncDirty;
  38109. private _isStencilOpDirty;
  38110. private _stencilTest;
  38111. private _stencilMask;
  38112. private _stencilFunc;
  38113. private _stencilFuncRef;
  38114. private _stencilFuncMask;
  38115. private _stencilOpStencilFail;
  38116. private _stencilOpDepthFail;
  38117. private _stencilOpStencilDepthPass;
  38118. get isDirty(): boolean;
  38119. get stencilFunc(): number;
  38120. set stencilFunc(value: number);
  38121. get stencilFuncRef(): number;
  38122. set stencilFuncRef(value: number);
  38123. get stencilFuncMask(): number;
  38124. set stencilFuncMask(value: number);
  38125. get stencilOpStencilFail(): number;
  38126. set stencilOpStencilFail(value: number);
  38127. get stencilOpDepthFail(): number;
  38128. set stencilOpDepthFail(value: number);
  38129. get stencilOpStencilDepthPass(): number;
  38130. set stencilOpStencilDepthPass(value: number);
  38131. get stencilMask(): number;
  38132. set stencilMask(value: number);
  38133. get stencilTest(): boolean;
  38134. set stencilTest(value: boolean);
  38135. constructor();
  38136. reset(): void;
  38137. apply(gl: WebGLRenderingContext): void;
  38138. }
  38139. }
  38140. declare module BABYLON {
  38141. /**
  38142. * @hidden
  38143. **/
  38144. export class AlphaState {
  38145. private _isAlphaBlendDirty;
  38146. private _isBlendFunctionParametersDirty;
  38147. private _isBlendEquationParametersDirty;
  38148. private _isBlendConstantsDirty;
  38149. private _alphaBlend;
  38150. private _blendFunctionParameters;
  38151. private _blendEquationParameters;
  38152. private _blendConstants;
  38153. /**
  38154. * Initializes the state.
  38155. */
  38156. constructor();
  38157. get isDirty(): boolean;
  38158. get alphaBlend(): boolean;
  38159. set alphaBlend(value: boolean);
  38160. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38161. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38162. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38163. reset(): void;
  38164. apply(gl: WebGLRenderingContext): void;
  38165. }
  38166. }
  38167. declare module BABYLON {
  38168. /** @hidden */
  38169. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38170. attributeProcessor(attribute: string): string;
  38171. varyingProcessor(varying: string, isFragment: boolean): string;
  38172. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * Interface for attribute information associated with buffer instanciation
  38178. */
  38179. export interface InstancingAttributeInfo {
  38180. /**
  38181. * Name of the GLSL attribute
  38182. * if attribute index is not specified, this is used to retrieve the index from the effect
  38183. */
  38184. attributeName: string;
  38185. /**
  38186. * Index/offset of the attribute in the vertex shader
  38187. * if not specified, this will be computes from the name.
  38188. */
  38189. index?: number;
  38190. /**
  38191. * size of the attribute, 1, 2, 3 or 4
  38192. */
  38193. attributeSize: number;
  38194. /**
  38195. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38196. */
  38197. offset: number;
  38198. /**
  38199. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38200. * default to 1
  38201. */
  38202. divisor?: number;
  38203. /**
  38204. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38205. * default is FLOAT
  38206. */
  38207. attributeType?: number;
  38208. /**
  38209. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38210. */
  38211. normalized?: boolean;
  38212. }
  38213. }
  38214. declare module BABYLON {
  38215. interface ThinEngine {
  38216. /**
  38217. * Update a video texture
  38218. * @param texture defines the texture to update
  38219. * @param video defines the video element to use
  38220. * @param invertY defines if data must be stored with Y axis inverted
  38221. */
  38222. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. interface ThinEngine {
  38227. /**
  38228. * Creates a dynamic texture
  38229. * @param width defines the width of the texture
  38230. * @param height defines the height of the texture
  38231. * @param generateMipMaps defines if the engine should generate the mip levels
  38232. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38233. * @returns the dynamic texture inside an InternalTexture
  38234. */
  38235. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38236. /**
  38237. * Update the content of a dynamic texture
  38238. * @param texture defines the texture to update
  38239. * @param canvas defines the canvas containing the source
  38240. * @param invertY defines if data must be stored with Y axis inverted
  38241. * @param premulAlpha defines if alpha is stored as premultiplied
  38242. * @param format defines the format of the data
  38243. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38244. */
  38245. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38246. }
  38247. }
  38248. declare module BABYLON {
  38249. /**
  38250. * Settings for finer control over video usage
  38251. */
  38252. export interface VideoTextureSettings {
  38253. /**
  38254. * Applies `autoplay` to video, if specified
  38255. */
  38256. autoPlay?: boolean;
  38257. /**
  38258. * Applies `muted` to video, if specified
  38259. */
  38260. muted?: boolean;
  38261. /**
  38262. * Applies `loop` to video, if specified
  38263. */
  38264. loop?: boolean;
  38265. /**
  38266. * Automatically updates internal texture from video at every frame in the render loop
  38267. */
  38268. autoUpdateTexture: boolean;
  38269. /**
  38270. * Image src displayed during the video loading or until the user interacts with the video.
  38271. */
  38272. poster?: string;
  38273. }
  38274. /**
  38275. * If you want to display a video in your scene, this is the special texture for that.
  38276. * This special texture works similar to other textures, with the exception of a few parameters.
  38277. * @see https://doc.babylonjs.com/how_to/video_texture
  38278. */
  38279. export class VideoTexture extends Texture {
  38280. /**
  38281. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38282. */
  38283. readonly autoUpdateTexture: boolean;
  38284. /**
  38285. * The video instance used by the texture internally
  38286. */
  38287. readonly video: HTMLVideoElement;
  38288. private _onUserActionRequestedObservable;
  38289. /**
  38290. * Event triggerd when a dom action is required by the user to play the video.
  38291. * This happens due to recent changes in browser policies preventing video to auto start.
  38292. */
  38293. get onUserActionRequestedObservable(): Observable<Texture>;
  38294. private _generateMipMaps;
  38295. private _stillImageCaptured;
  38296. private _displayingPosterTexture;
  38297. private _settings;
  38298. private _createInternalTextureOnEvent;
  38299. private _frameId;
  38300. private _currentSrc;
  38301. /**
  38302. * Creates a video texture.
  38303. * If you want to display a video in your scene, this is the special texture for that.
  38304. * This special texture works similar to other textures, with the exception of a few parameters.
  38305. * @see https://doc.babylonjs.com/how_to/video_texture
  38306. * @param name optional name, will detect from video source, if not defined
  38307. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38308. * @param scene is obviously the current scene.
  38309. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38310. * @param invertY is false by default but can be used to invert video on Y axis
  38311. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38312. * @param settings allows finer control over video usage
  38313. */
  38314. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38315. private _getName;
  38316. private _getVideo;
  38317. private _createInternalTexture;
  38318. private reset;
  38319. /**
  38320. * @hidden Internal method to initiate `update`.
  38321. */
  38322. _rebuild(): void;
  38323. /**
  38324. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38325. */
  38326. update(): void;
  38327. /**
  38328. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38329. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38330. */
  38331. updateTexture(isVisible: boolean): void;
  38332. protected _updateInternalTexture: () => void;
  38333. /**
  38334. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38335. * @param url New url.
  38336. */
  38337. updateURL(url: string): void;
  38338. /**
  38339. * Clones the texture.
  38340. * @returns the cloned texture
  38341. */
  38342. clone(): VideoTexture;
  38343. /**
  38344. * Dispose the texture and release its associated resources.
  38345. */
  38346. dispose(): void;
  38347. /**
  38348. * Creates a video texture straight from a stream.
  38349. * @param scene Define the scene the texture should be created in
  38350. * @param stream Define the stream the texture should be created from
  38351. * @returns The created video texture as a promise
  38352. */
  38353. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38354. /**
  38355. * Creates a video texture straight from your WebCam video feed.
  38356. * @param scene Define the scene the texture should be created in
  38357. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38358. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38359. * @returns The created video texture as a promise
  38360. */
  38361. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38362. minWidth: number;
  38363. maxWidth: number;
  38364. minHeight: number;
  38365. maxHeight: number;
  38366. deviceId: string;
  38367. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38368. /**
  38369. * Creates a video texture straight from your WebCam video feed.
  38370. * @param scene Define the scene the texture should be created in
  38371. * @param onReady Define a callback to triggered once the texture will be ready
  38372. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38373. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38374. */
  38375. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38376. minWidth: number;
  38377. maxWidth: number;
  38378. minHeight: number;
  38379. maxHeight: number;
  38380. deviceId: string;
  38381. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38382. }
  38383. }
  38384. declare module BABYLON {
  38385. /**
  38386. * Defines the interface used by objects working like Scene
  38387. * @hidden
  38388. */
  38389. export interface ISceneLike {
  38390. _addPendingData(data: any): void;
  38391. _removePendingData(data: any): void;
  38392. offlineProvider: IOfflineProvider;
  38393. }
  38394. /**
  38395. * Information about the current host
  38396. */
  38397. export interface HostInformation {
  38398. /**
  38399. * Defines if the current host is a mobile
  38400. */
  38401. isMobile: boolean;
  38402. }
  38403. /** Interface defining initialization parameters for Engine class */
  38404. export interface EngineOptions extends WebGLContextAttributes {
  38405. /**
  38406. * Defines if the engine should no exceed a specified device ratio
  38407. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38408. */
  38409. limitDeviceRatio?: number;
  38410. /**
  38411. * Defines if webvr should be enabled automatically
  38412. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38413. */
  38414. autoEnableWebVR?: boolean;
  38415. /**
  38416. * Defines if webgl2 should be turned off even if supported
  38417. * @see https://doc.babylonjs.com/features/webgl2
  38418. */
  38419. disableWebGL2Support?: boolean;
  38420. /**
  38421. * Defines if webaudio should be initialized as well
  38422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38423. */
  38424. audioEngine?: boolean;
  38425. /**
  38426. * Defines if animations should run using a deterministic lock step
  38427. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38428. */
  38429. deterministicLockstep?: boolean;
  38430. /** Defines the maximum steps to use with deterministic lock step mode */
  38431. lockstepMaxSteps?: number;
  38432. /** Defines the seconds between each deterministic lock step */
  38433. timeStep?: number;
  38434. /**
  38435. * Defines that engine should ignore context lost events
  38436. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38437. */
  38438. doNotHandleContextLost?: boolean;
  38439. /**
  38440. * Defines that engine should ignore modifying touch action attribute and style
  38441. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38442. */
  38443. doNotHandleTouchAction?: boolean;
  38444. /**
  38445. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38446. */
  38447. useHighPrecisionFloats?: boolean;
  38448. /**
  38449. * Make the canvas XR Compatible for XR sessions
  38450. */
  38451. xrCompatible?: boolean;
  38452. /**
  38453. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38454. */
  38455. useHighPrecisionMatrix?: boolean;
  38456. /**
  38457. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38458. */
  38459. failIfMajorPerformanceCaveat?: boolean;
  38460. }
  38461. /**
  38462. * The base engine class (root of all engines)
  38463. */
  38464. export class ThinEngine {
  38465. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38466. static ExceptionList: ({
  38467. key: string;
  38468. capture: string;
  38469. captureConstraint: number;
  38470. targets: string[];
  38471. } | {
  38472. key: string;
  38473. capture: null;
  38474. captureConstraint: null;
  38475. targets: string[];
  38476. })[];
  38477. /** @hidden */
  38478. static _TextureLoaders: IInternalTextureLoader[];
  38479. /**
  38480. * Returns the current npm package of the sdk
  38481. */
  38482. static get NpmPackage(): string;
  38483. /**
  38484. * Returns the current version of the framework
  38485. */
  38486. static get Version(): string;
  38487. /**
  38488. * Returns a string describing the current engine
  38489. */
  38490. get description(): string;
  38491. /**
  38492. * Gets or sets the epsilon value used by collision engine
  38493. */
  38494. static CollisionsEpsilon: number;
  38495. /**
  38496. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38497. */
  38498. static get ShadersRepository(): string;
  38499. static set ShadersRepository(value: string);
  38500. /** @hidden */
  38501. _shaderProcessor: IShaderProcessor;
  38502. /**
  38503. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38504. */
  38505. forcePOTTextures: boolean;
  38506. /**
  38507. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38508. */
  38509. isFullscreen: boolean;
  38510. /**
  38511. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38512. */
  38513. cullBackFaces: boolean;
  38514. /**
  38515. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38516. */
  38517. renderEvenInBackground: boolean;
  38518. /**
  38519. * Gets or sets a boolean indicating that cache can be kept between frames
  38520. */
  38521. preventCacheWipeBetweenFrames: boolean;
  38522. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38523. validateShaderPrograms: boolean;
  38524. /**
  38525. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38526. * This can provide greater z depth for distant objects.
  38527. */
  38528. useReverseDepthBuffer: boolean;
  38529. /**
  38530. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38531. */
  38532. disableUniformBuffers: boolean;
  38533. /** @hidden */
  38534. _uniformBuffers: UniformBuffer[];
  38535. /**
  38536. * Gets a boolean indicating that the engine supports uniform buffers
  38537. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38538. */
  38539. get supportsUniformBuffers(): boolean;
  38540. /** @hidden */
  38541. _gl: WebGLRenderingContext;
  38542. /** @hidden */
  38543. _webGLVersion: number;
  38544. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38545. protected _windowIsBackground: boolean;
  38546. protected _creationOptions: EngineOptions;
  38547. protected _highPrecisionShadersAllowed: boolean;
  38548. /** @hidden */
  38549. get _shouldUseHighPrecisionShader(): boolean;
  38550. /**
  38551. * Gets a boolean indicating that only power of 2 textures are supported
  38552. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38553. */
  38554. get needPOTTextures(): boolean;
  38555. /** @hidden */
  38556. _badOS: boolean;
  38557. /** @hidden */
  38558. _badDesktopOS: boolean;
  38559. private _hardwareScalingLevel;
  38560. /** @hidden */
  38561. _caps: EngineCapabilities;
  38562. private _isStencilEnable;
  38563. private _glVersion;
  38564. private _glRenderer;
  38565. private _glVendor;
  38566. /** @hidden */
  38567. _videoTextureSupported: boolean;
  38568. protected _renderingQueueLaunched: boolean;
  38569. protected _activeRenderLoops: (() => void)[];
  38570. /**
  38571. * Observable signaled when a context lost event is raised
  38572. */
  38573. onContextLostObservable: Observable<ThinEngine>;
  38574. /**
  38575. * Observable signaled when a context restored event is raised
  38576. */
  38577. onContextRestoredObservable: Observable<ThinEngine>;
  38578. private _onContextLost;
  38579. private _onContextRestored;
  38580. protected _contextWasLost: boolean;
  38581. /** @hidden */
  38582. _doNotHandleContextLost: boolean;
  38583. /**
  38584. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38585. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38586. */
  38587. get doNotHandleContextLost(): boolean;
  38588. set doNotHandleContextLost(value: boolean);
  38589. /**
  38590. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38591. */
  38592. disableVertexArrayObjects: boolean;
  38593. /** @hidden */
  38594. protected _colorWrite: boolean;
  38595. /** @hidden */
  38596. protected _colorWriteChanged: boolean;
  38597. /** @hidden */
  38598. protected _depthCullingState: DepthCullingState;
  38599. /** @hidden */
  38600. protected _stencilState: StencilState;
  38601. /** @hidden */
  38602. _alphaState: AlphaState;
  38603. /** @hidden */
  38604. _alphaMode: number;
  38605. /** @hidden */
  38606. _alphaEquation: number;
  38607. /** @hidden */
  38608. _internalTexturesCache: InternalTexture[];
  38609. /** @hidden */
  38610. protected _activeChannel: number;
  38611. private _currentTextureChannel;
  38612. /** @hidden */
  38613. protected _boundTexturesCache: {
  38614. [key: string]: Nullable<InternalTexture>;
  38615. };
  38616. /** @hidden */
  38617. protected _currentEffect: Nullable<Effect>;
  38618. /** @hidden */
  38619. protected _currentProgram: Nullable<WebGLProgram>;
  38620. private _compiledEffects;
  38621. private _vertexAttribArraysEnabled;
  38622. /** @hidden */
  38623. protected _cachedViewport: Nullable<IViewportLike>;
  38624. private _cachedVertexArrayObject;
  38625. /** @hidden */
  38626. protected _cachedVertexBuffers: any;
  38627. /** @hidden */
  38628. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38629. /** @hidden */
  38630. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38631. /** @hidden */
  38632. _currentRenderTarget: Nullable<InternalTexture>;
  38633. private _uintIndicesCurrentlySet;
  38634. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38635. /** @hidden */
  38636. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38637. /** @hidden */
  38638. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38639. private _currentBufferPointers;
  38640. private _currentInstanceLocations;
  38641. private _currentInstanceBuffers;
  38642. private _textureUnits;
  38643. /** @hidden */
  38644. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38645. /** @hidden */
  38646. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38647. /** @hidden */
  38648. _boundRenderFunction: any;
  38649. private _vaoRecordInProgress;
  38650. private _mustWipeVertexAttributes;
  38651. private _emptyTexture;
  38652. private _emptyCubeTexture;
  38653. private _emptyTexture3D;
  38654. private _emptyTexture2DArray;
  38655. /** @hidden */
  38656. _frameHandler: number;
  38657. private _nextFreeTextureSlots;
  38658. private _maxSimultaneousTextures;
  38659. private _activeRequests;
  38660. /** @hidden */
  38661. _transformTextureUrl: Nullable<(url: string) => string>;
  38662. /**
  38663. * Gets information about the current host
  38664. */
  38665. hostInformation: HostInformation;
  38666. protected get _supportsHardwareTextureRescaling(): boolean;
  38667. private _framebufferDimensionsObject;
  38668. /**
  38669. * sets the object from which width and height will be taken from when getting render width and height
  38670. * Will fallback to the gl object
  38671. * @param dimensions the framebuffer width and height that will be used.
  38672. */
  38673. set framebufferDimensionsObject(dimensions: Nullable<{
  38674. framebufferWidth: number;
  38675. framebufferHeight: number;
  38676. }>);
  38677. /**
  38678. * Gets the current viewport
  38679. */
  38680. get currentViewport(): Nullable<IViewportLike>;
  38681. /**
  38682. * Gets the default empty texture
  38683. */
  38684. get emptyTexture(): InternalTexture;
  38685. /**
  38686. * Gets the default empty 3D texture
  38687. */
  38688. get emptyTexture3D(): InternalTexture;
  38689. /**
  38690. * Gets the default empty 2D array texture
  38691. */
  38692. get emptyTexture2DArray(): InternalTexture;
  38693. /**
  38694. * Gets the default empty cube texture
  38695. */
  38696. get emptyCubeTexture(): InternalTexture;
  38697. /**
  38698. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38699. */
  38700. readonly premultipliedAlpha: boolean;
  38701. /**
  38702. * Observable event triggered before each texture is initialized
  38703. */
  38704. onBeforeTextureInitObservable: Observable<Texture>;
  38705. /**
  38706. * Creates a new engine
  38707. * @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
  38708. * @param antialias defines enable antialiasing (default: false)
  38709. * @param options defines further options to be sent to the getContext() function
  38710. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38711. */
  38712. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38713. private _rebuildInternalTextures;
  38714. private _rebuildEffects;
  38715. /**
  38716. * Gets a boolean indicating if all created effects are ready
  38717. * @returns true if all effects are ready
  38718. */
  38719. areAllEffectsReady(): boolean;
  38720. protected _rebuildBuffers(): void;
  38721. protected _initGLContext(): void;
  38722. /**
  38723. * Gets version of the current webGL context
  38724. */
  38725. get webGLVersion(): number;
  38726. /**
  38727. * Gets a string identifying the name of the class
  38728. * @returns "Engine" string
  38729. */
  38730. getClassName(): string;
  38731. /**
  38732. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38733. */
  38734. get isStencilEnable(): boolean;
  38735. /** @hidden */
  38736. _prepareWorkingCanvas(): void;
  38737. /**
  38738. * Reset the texture cache to empty state
  38739. */
  38740. resetTextureCache(): void;
  38741. /**
  38742. * Gets an object containing information about the current webGL context
  38743. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38744. */
  38745. getGlInfo(): {
  38746. vendor: string;
  38747. renderer: string;
  38748. version: string;
  38749. };
  38750. /**
  38751. * Defines the hardware scaling level.
  38752. * By default the hardware scaling level is computed from the window device ratio.
  38753. * 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.
  38754. * @param level defines the level to use
  38755. */
  38756. setHardwareScalingLevel(level: number): void;
  38757. /**
  38758. * Gets the current hardware scaling level.
  38759. * By default the hardware scaling level is computed from the window device ratio.
  38760. * 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.
  38761. * @returns a number indicating the current hardware scaling level
  38762. */
  38763. getHardwareScalingLevel(): number;
  38764. /**
  38765. * Gets the list of loaded textures
  38766. * @returns an array containing all loaded textures
  38767. */
  38768. getLoadedTexturesCache(): InternalTexture[];
  38769. /**
  38770. * Gets the object containing all engine capabilities
  38771. * @returns the EngineCapabilities object
  38772. */
  38773. getCaps(): EngineCapabilities;
  38774. /**
  38775. * stop executing a render loop function and remove it from the execution array
  38776. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38777. */
  38778. stopRenderLoop(renderFunction?: () => void): void;
  38779. /** @hidden */
  38780. _renderLoop(): void;
  38781. /**
  38782. * Gets the HTML canvas attached with the current webGL context
  38783. * @returns a HTML canvas
  38784. */
  38785. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38786. /**
  38787. * Gets host window
  38788. * @returns the host window object
  38789. */
  38790. getHostWindow(): Nullable<Window>;
  38791. /**
  38792. * Gets the current render width
  38793. * @param useScreen defines if screen size must be used (or the current render target if any)
  38794. * @returns a number defining the current render width
  38795. */
  38796. getRenderWidth(useScreen?: boolean): number;
  38797. /**
  38798. * Gets the current render height
  38799. * @param useScreen defines if screen size must be used (or the current render target if any)
  38800. * @returns a number defining the current render height
  38801. */
  38802. getRenderHeight(useScreen?: boolean): number;
  38803. /**
  38804. * Can be used to override the current requestAnimationFrame requester.
  38805. * @hidden
  38806. */
  38807. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38808. /**
  38809. * Register and execute a render loop. The engine can have more than one render function
  38810. * @param renderFunction defines the function to continuously execute
  38811. */
  38812. runRenderLoop(renderFunction: () => void): void;
  38813. /**
  38814. * Clear the current render buffer or the current render target (if any is set up)
  38815. * @param color defines the color to use
  38816. * @param backBuffer defines if the back buffer must be cleared
  38817. * @param depth defines if the depth buffer must be cleared
  38818. * @param stencil defines if the stencil buffer must be cleared
  38819. */
  38820. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38821. private _viewportCached;
  38822. /** @hidden */
  38823. _viewport(x: number, y: number, width: number, height: number): void;
  38824. /**
  38825. * Set the WebGL's viewport
  38826. * @param viewport defines the viewport element to be used
  38827. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38828. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38829. */
  38830. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38831. /**
  38832. * Begin a new frame
  38833. */
  38834. beginFrame(): void;
  38835. /**
  38836. * Enf the current frame
  38837. */
  38838. endFrame(): void;
  38839. /**
  38840. * Resize the view according to the canvas' size
  38841. */
  38842. resize(): void;
  38843. /**
  38844. * Force a specific size of the canvas
  38845. * @param width defines the new canvas' width
  38846. * @param height defines the new canvas' height
  38847. * @returns true if the size was changed
  38848. */
  38849. setSize(width: number, height: number): boolean;
  38850. /**
  38851. * Binds the frame buffer to the specified texture.
  38852. * @param texture The texture to render to or null for the default canvas
  38853. * @param faceIndex The face of the texture to render to in case of cube texture
  38854. * @param requiredWidth The width of the target to render to
  38855. * @param requiredHeight The height of the target to render to
  38856. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38857. * @param lodLevel defines the lod level to bind to the frame buffer
  38858. * @param layer defines the 2d array index to bind to frame buffer to
  38859. */
  38860. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38861. /** @hidden */
  38862. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38863. /**
  38864. * Unbind the current render target texture from the webGL context
  38865. * @param texture defines the render target texture to unbind
  38866. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38867. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38868. */
  38869. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38870. /**
  38871. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38872. */
  38873. flushFramebuffer(): void;
  38874. /**
  38875. * Unbind the current render target and bind the default framebuffer
  38876. */
  38877. restoreDefaultFramebuffer(): void;
  38878. /** @hidden */
  38879. protected _resetVertexBufferBinding(): void;
  38880. /**
  38881. * Creates a vertex buffer
  38882. * @param data the data for the vertex buffer
  38883. * @returns the new WebGL static buffer
  38884. */
  38885. createVertexBuffer(data: DataArray): DataBuffer;
  38886. private _createVertexBuffer;
  38887. /**
  38888. * Creates a dynamic vertex buffer
  38889. * @param data the data for the dynamic vertex buffer
  38890. * @returns the new WebGL dynamic buffer
  38891. */
  38892. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38893. protected _resetIndexBufferBinding(): void;
  38894. /**
  38895. * Creates a new index buffer
  38896. * @param indices defines the content of the index buffer
  38897. * @param updatable defines if the index buffer must be updatable
  38898. * @returns a new webGL buffer
  38899. */
  38900. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38901. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38902. /**
  38903. * Bind a webGL buffer to the webGL context
  38904. * @param buffer defines the buffer to bind
  38905. */
  38906. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38907. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38908. private bindBuffer;
  38909. /**
  38910. * update the bound buffer with the given data
  38911. * @param data defines the data to update
  38912. */
  38913. updateArrayBuffer(data: Float32Array): void;
  38914. private _vertexAttribPointer;
  38915. /** @hidden */
  38916. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38917. private _bindVertexBuffersAttributes;
  38918. /**
  38919. * Records a vertex array object
  38920. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38921. * @param vertexBuffers defines the list of vertex buffers to store
  38922. * @param indexBuffer defines the index buffer to store
  38923. * @param effect defines the effect to store
  38924. * @returns the new vertex array object
  38925. */
  38926. recordVertexArrayObject(vertexBuffers: {
  38927. [key: string]: VertexBuffer;
  38928. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38929. /**
  38930. * Bind a specific vertex array object
  38931. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38932. * @param vertexArrayObject defines the vertex array object to bind
  38933. * @param indexBuffer defines the index buffer to bind
  38934. */
  38935. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38936. /**
  38937. * Bind webGl buffers directly to the webGL context
  38938. * @param vertexBuffer defines the vertex buffer to bind
  38939. * @param indexBuffer defines the index buffer to bind
  38940. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38941. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38942. * @param effect defines the effect associated with the vertex buffer
  38943. */
  38944. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38945. private _unbindVertexArrayObject;
  38946. /**
  38947. * Bind a list of vertex buffers to the webGL context
  38948. * @param vertexBuffers defines the list of vertex buffers to bind
  38949. * @param indexBuffer defines the index buffer to bind
  38950. * @param effect defines the effect associated with the vertex buffers
  38951. */
  38952. bindBuffers(vertexBuffers: {
  38953. [key: string]: Nullable<VertexBuffer>;
  38954. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38955. /**
  38956. * Unbind all instance attributes
  38957. */
  38958. unbindInstanceAttributes(): void;
  38959. /**
  38960. * Release and free the memory of a vertex array object
  38961. * @param vao defines the vertex array object to delete
  38962. */
  38963. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38964. /** @hidden */
  38965. _releaseBuffer(buffer: DataBuffer): boolean;
  38966. protected _deleteBuffer(buffer: DataBuffer): void;
  38967. /**
  38968. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38969. * @param instancesBuffer defines the webGL buffer to update and bind
  38970. * @param data defines the data to store in the buffer
  38971. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38972. */
  38973. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38974. /**
  38975. * Bind the content of a webGL buffer used with instantiation
  38976. * @param instancesBuffer defines the webGL buffer to bind
  38977. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38978. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38979. */
  38980. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38981. /**
  38982. * Disable the instance attribute corresponding to the name in parameter
  38983. * @param name defines the name of the attribute to disable
  38984. */
  38985. disableInstanceAttributeByName(name: string): void;
  38986. /**
  38987. * Disable the instance attribute corresponding to the location in parameter
  38988. * @param attributeLocation defines the attribute location of the attribute to disable
  38989. */
  38990. disableInstanceAttribute(attributeLocation: number): void;
  38991. /**
  38992. * Disable the attribute corresponding to the location in parameter
  38993. * @param attributeLocation defines the attribute location of the attribute to disable
  38994. */
  38995. disableAttributeByIndex(attributeLocation: number): void;
  38996. /**
  38997. * Send a draw order
  38998. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38999. * @param indexStart defines the starting index
  39000. * @param indexCount defines the number of index to draw
  39001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39002. */
  39003. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39004. /**
  39005. * Draw a list of points
  39006. * @param verticesStart defines the index of first vertex to draw
  39007. * @param verticesCount defines the count of vertices to draw
  39008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39009. */
  39010. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39011. /**
  39012. * Draw a list of unindexed primitives
  39013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39014. * @param verticesStart defines the index of first vertex to draw
  39015. * @param verticesCount defines the count of vertices to draw
  39016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39017. */
  39018. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39019. /**
  39020. * Draw a list of indexed primitives
  39021. * @param fillMode defines the primitive to use
  39022. * @param indexStart defines the starting index
  39023. * @param indexCount defines the number of index to draw
  39024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39025. */
  39026. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39027. /**
  39028. * Draw a list of unindexed primitives
  39029. * @param fillMode defines the primitive to use
  39030. * @param verticesStart defines the index of first vertex to draw
  39031. * @param verticesCount defines the count of vertices to draw
  39032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39033. */
  39034. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39035. private _drawMode;
  39036. /** @hidden */
  39037. protected _reportDrawCall(): void;
  39038. /** @hidden */
  39039. _releaseEffect(effect: Effect): void;
  39040. /** @hidden */
  39041. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39042. /**
  39043. * Create a new effect (used to store vertex/fragment shaders)
  39044. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39045. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39046. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39047. * @param samplers defines an array of string used to represent textures
  39048. * @param defines defines the string containing the defines to use to compile the shaders
  39049. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39050. * @param onCompiled defines a function to call when the effect creation is successful
  39051. * @param onError defines a function to call when the effect creation has failed
  39052. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39053. * @returns the new Effect
  39054. */
  39055. 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;
  39056. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39057. private _compileShader;
  39058. private _compileRawShader;
  39059. /** @hidden */
  39060. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39061. /**
  39062. * Directly creates a webGL program
  39063. * @param pipelineContext defines the pipeline context to attach to
  39064. * @param vertexCode defines the vertex shader code to use
  39065. * @param fragmentCode defines the fragment shader code to use
  39066. * @param context defines the webGL context to use (if not set, the current one will be used)
  39067. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39068. * @returns the new webGL program
  39069. */
  39070. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39071. /**
  39072. * Creates a webGL program
  39073. * @param pipelineContext defines the pipeline context to attach to
  39074. * @param vertexCode defines the vertex shader code to use
  39075. * @param fragmentCode defines the fragment shader code to use
  39076. * @param defines defines the string containing the defines to use to compile the shaders
  39077. * @param context defines the webGL context to use (if not set, the current one will be used)
  39078. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39079. * @returns the new webGL program
  39080. */
  39081. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39082. /**
  39083. * Creates a new pipeline context
  39084. * @returns the new pipeline
  39085. */
  39086. createPipelineContext(): IPipelineContext;
  39087. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39088. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39089. /** @hidden */
  39090. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39091. /** @hidden */
  39092. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39093. /** @hidden */
  39094. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39095. /**
  39096. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39097. * @param pipelineContext defines the pipeline context to use
  39098. * @param uniformsNames defines the list of uniform names
  39099. * @returns an array of webGL uniform locations
  39100. */
  39101. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39102. /**
  39103. * Gets the lsit of active attributes for a given webGL program
  39104. * @param pipelineContext defines the pipeline context to use
  39105. * @param attributesNames defines the list of attribute names to get
  39106. * @returns an array of indices indicating the offset of each attribute
  39107. */
  39108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39109. /**
  39110. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39111. * @param effect defines the effect to activate
  39112. */
  39113. enableEffect(effect: Nullable<Effect>): void;
  39114. /**
  39115. * Set the value of an uniform to a number (int)
  39116. * @param uniform defines the webGL uniform location where to store the value
  39117. * @param value defines the int number to store
  39118. * @returns true if the value was set
  39119. */
  39120. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39121. /**
  39122. * Set the value of an uniform to an array of int32
  39123. * @param uniform defines the webGL uniform location where to store the value
  39124. * @param array defines the array of int32 to store
  39125. * @returns true if the value was set
  39126. */
  39127. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39128. /**
  39129. * Set the value of an uniform to an array of int32 (stored as vec2)
  39130. * @param uniform defines the webGL uniform location where to store the value
  39131. * @param array defines the array of int32 to store
  39132. * @returns true if the value was set
  39133. */
  39134. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39135. /**
  39136. * Set the value of an uniform to an array of int32 (stored as vec3)
  39137. * @param uniform defines the webGL uniform location where to store the value
  39138. * @param array defines the array of int32 to store
  39139. * @returns true if the value was set
  39140. */
  39141. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39142. /**
  39143. * Set the value of an uniform to an array of int32 (stored as vec4)
  39144. * @param uniform defines the webGL uniform location where to store the value
  39145. * @param array defines the array of int32 to store
  39146. * @returns true if the value was set
  39147. */
  39148. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39149. /**
  39150. * Set the value of an uniform to an array of number
  39151. * @param uniform defines the webGL uniform location where to store the value
  39152. * @param array defines the array of number to store
  39153. * @returns true if the value was set
  39154. */
  39155. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39156. /**
  39157. * Set the value of an uniform to an array of number (stored as vec2)
  39158. * @param uniform defines the webGL uniform location where to store the value
  39159. * @param array defines the array of number to store
  39160. * @returns true if the value was set
  39161. */
  39162. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39163. /**
  39164. * Set the value of an uniform to an array of number (stored as vec3)
  39165. * @param uniform defines the webGL uniform location where to store the value
  39166. * @param array defines the array of number to store
  39167. * @returns true if the value was set
  39168. */
  39169. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39170. /**
  39171. * Set the value of an uniform to an array of number (stored as vec4)
  39172. * @param uniform defines the webGL uniform location where to store the value
  39173. * @param array defines the array of number to store
  39174. * @returns true if the value was set
  39175. */
  39176. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39177. /**
  39178. * Set the value of an uniform to an array of float32 (stored as matrices)
  39179. * @param uniform defines the webGL uniform location where to store the value
  39180. * @param matrices defines the array of float32 to store
  39181. * @returns true if the value was set
  39182. */
  39183. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39184. /**
  39185. * Set the value of an uniform to a matrix (3x3)
  39186. * @param uniform defines the webGL uniform location where to store the value
  39187. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39188. * @returns true if the value was set
  39189. */
  39190. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39191. /**
  39192. * Set the value of an uniform to a matrix (2x2)
  39193. * @param uniform defines the webGL uniform location where to store the value
  39194. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39195. * @returns true if the value was set
  39196. */
  39197. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39198. /**
  39199. * Set the value of an uniform to a number (float)
  39200. * @param uniform defines the webGL uniform location where to store the value
  39201. * @param value defines the float number to store
  39202. * @returns true if the value was transfered
  39203. */
  39204. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39205. /**
  39206. * Set the value of an uniform to a vec2
  39207. * @param uniform defines the webGL uniform location where to store the value
  39208. * @param x defines the 1st component of the value
  39209. * @param y defines the 2nd component of the value
  39210. * @returns true if the value was set
  39211. */
  39212. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39213. /**
  39214. * Set the value of an uniform to a vec3
  39215. * @param uniform defines the webGL uniform location where to store the value
  39216. * @param x defines the 1st component of the value
  39217. * @param y defines the 2nd component of the value
  39218. * @param z defines the 3rd component of the value
  39219. * @returns true if the value was set
  39220. */
  39221. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39222. /**
  39223. * Set the value of an uniform to a vec4
  39224. * @param uniform defines the webGL uniform location where to store the value
  39225. * @param x defines the 1st component of the value
  39226. * @param y defines the 2nd component of the value
  39227. * @param z defines the 3rd component of the value
  39228. * @param w defines the 4th component of the value
  39229. * @returns true if the value was set
  39230. */
  39231. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39232. /**
  39233. * Apply all cached states (depth, culling, stencil and alpha)
  39234. */
  39235. applyStates(): void;
  39236. /**
  39237. * Enable or disable color writing
  39238. * @param enable defines the state to set
  39239. */
  39240. setColorWrite(enable: boolean): void;
  39241. /**
  39242. * Gets a boolean indicating if color writing is enabled
  39243. * @returns the current color writing state
  39244. */
  39245. getColorWrite(): boolean;
  39246. /**
  39247. * Gets the depth culling state manager
  39248. */
  39249. get depthCullingState(): DepthCullingState;
  39250. /**
  39251. * Gets the alpha state manager
  39252. */
  39253. get alphaState(): AlphaState;
  39254. /**
  39255. * Gets the stencil state manager
  39256. */
  39257. get stencilState(): StencilState;
  39258. /**
  39259. * Clears the list of texture accessible through engine.
  39260. * This can help preventing texture load conflict due to name collision.
  39261. */
  39262. clearInternalTexturesCache(): void;
  39263. /**
  39264. * Force the entire cache to be cleared
  39265. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39266. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39267. */
  39268. wipeCaches(bruteForce?: boolean): void;
  39269. /** @hidden */
  39270. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39271. min: number;
  39272. mag: number;
  39273. };
  39274. /** @hidden */
  39275. _createTexture(): WebGLTexture;
  39276. /**
  39277. * Usually called from Texture.ts.
  39278. * Passed information to create a WebGLTexture
  39279. * @param url defines a value which contains one of the following:
  39280. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39281. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39282. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39284. * @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)
  39285. * @param scene needed for loading to the correct scene
  39286. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39287. * @param onLoad optional callback to be called upon successful completion
  39288. * @param onError optional callback to be called upon failure
  39289. * @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
  39290. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39291. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39292. * @param forcedExtension defines the extension to use to pick the right loader
  39293. * @param mimeType defines an optional mime type
  39294. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39295. */
  39296. 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): InternalTexture;
  39297. /**
  39298. * Loads an image as an HTMLImageElement.
  39299. * @param input url string, ArrayBuffer, or Blob to load
  39300. * @param onLoad callback called when the image successfully loads
  39301. * @param onError callback called when the image fails to load
  39302. * @param offlineProvider offline provider for caching
  39303. * @param mimeType optional mime type
  39304. * @returns the HTMLImageElement of the loaded image
  39305. * @hidden
  39306. */
  39307. 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>;
  39308. /**
  39309. * @hidden
  39310. */
  39311. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39312. private _unpackFlipYCached;
  39313. /**
  39314. * In case you are sharing the context with other applications, it might
  39315. * be interested to not cache the unpack flip y state to ensure a consistent
  39316. * value would be set.
  39317. */
  39318. enableUnpackFlipYCached: boolean;
  39319. /** @hidden */
  39320. _unpackFlipY(value: boolean): void;
  39321. /** @hidden */
  39322. _getUnpackAlignement(): number;
  39323. private _getTextureTarget;
  39324. /**
  39325. * Update the sampling mode of a given texture
  39326. * @param samplingMode defines the required sampling mode
  39327. * @param texture defines the texture to update
  39328. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39329. */
  39330. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39331. /**
  39332. * Update the sampling mode of a given texture
  39333. * @param texture defines the texture to update
  39334. * @param wrapU defines the texture wrap mode of the u coordinates
  39335. * @param wrapV defines the texture wrap mode of the v coordinates
  39336. * @param wrapR defines the texture wrap mode of the r coordinates
  39337. */
  39338. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39339. /** @hidden */
  39340. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39341. width: number;
  39342. height: number;
  39343. layers?: number;
  39344. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39345. /** @hidden */
  39346. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39347. /** @hidden */
  39348. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39349. /**
  39350. * Update a portion of an internal texture
  39351. * @param texture defines the texture to update
  39352. * @param imageData defines the data to store into the texture
  39353. * @param xOffset defines the x coordinates of the update rectangle
  39354. * @param yOffset defines the y coordinates of the update rectangle
  39355. * @param width defines the width of the update rectangle
  39356. * @param height defines the height of the update rectangle
  39357. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39358. * @param lod defines the lod level to update (0 by default)
  39359. */
  39360. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39361. /** @hidden */
  39362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39363. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39364. private _prepareWebGLTexture;
  39365. /** @hidden */
  39366. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39367. private _getDepthStencilBuffer;
  39368. /** @hidden */
  39369. _releaseFramebufferObjects(texture: InternalTexture): void;
  39370. /** @hidden */
  39371. _releaseTexture(texture: InternalTexture): void;
  39372. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39373. protected _setProgram(program: WebGLProgram): void;
  39374. protected _boundUniforms: {
  39375. [key: number]: WebGLUniformLocation;
  39376. };
  39377. /**
  39378. * Binds an effect to the webGL context
  39379. * @param effect defines the effect to bind
  39380. */
  39381. bindSamplers(effect: Effect): void;
  39382. private _activateCurrentTexture;
  39383. /** @hidden */
  39384. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39385. /** @hidden */
  39386. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39387. /**
  39388. * Unbind all textures from the webGL context
  39389. */
  39390. unbindAllTextures(): void;
  39391. /**
  39392. * Sets a texture to the according uniform.
  39393. * @param channel The texture channel
  39394. * @param uniform The uniform to set
  39395. * @param texture The texture to apply
  39396. */
  39397. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39398. private _bindSamplerUniformToChannel;
  39399. private _getTextureWrapMode;
  39400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39401. /**
  39402. * Sets an array of texture to the webGL context
  39403. * @param channel defines the channel where the texture array must be set
  39404. * @param uniform defines the associated uniform location
  39405. * @param textures defines the array of textures to bind
  39406. */
  39407. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39408. /** @hidden */
  39409. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39410. private _setTextureParameterFloat;
  39411. private _setTextureParameterInteger;
  39412. /**
  39413. * Unbind all vertex attributes from the webGL context
  39414. */
  39415. unbindAllAttributes(): void;
  39416. /**
  39417. * 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
  39418. */
  39419. releaseEffects(): void;
  39420. /**
  39421. * Dispose and release all associated resources
  39422. */
  39423. dispose(): void;
  39424. /**
  39425. * Attach a new callback raised when context lost event is fired
  39426. * @param callback defines the callback to call
  39427. */
  39428. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39429. /**
  39430. * Attach a new callback raised when context restored event is fired
  39431. * @param callback defines the callback to call
  39432. */
  39433. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39434. /**
  39435. * Get the current error code of the webGL context
  39436. * @returns the error code
  39437. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39438. */
  39439. getError(): number;
  39440. private _canRenderToFloatFramebuffer;
  39441. private _canRenderToHalfFloatFramebuffer;
  39442. private _canRenderToFramebuffer;
  39443. /** @hidden */
  39444. _getWebGLTextureType(type: number): number;
  39445. /** @hidden */
  39446. _getInternalFormat(format: number): number;
  39447. /** @hidden */
  39448. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39449. /** @hidden */
  39450. _getRGBAMultiSampleBufferFormat(type: number): number;
  39451. /** @hidden */
  39452. _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;
  39453. /**
  39454. * Loads a file from a url
  39455. * @param url url to load
  39456. * @param onSuccess callback called when the file successfully loads
  39457. * @param onProgress callback called while file is loading (if the server supports this mode)
  39458. * @param offlineProvider defines the offline provider for caching
  39459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39460. * @param onError callback called when the file fails to load
  39461. * @returns a file request object
  39462. * @hidden
  39463. */
  39464. 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;
  39465. /**
  39466. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39467. * @param x defines the x coordinate of the rectangle where pixels must be read
  39468. * @param y defines the y coordinate of the rectangle where pixels must be read
  39469. * @param width defines the width of the rectangle where pixels must be read
  39470. * @param height defines the height of the rectangle where pixels must be read
  39471. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39472. * @returns a Uint8Array containing RGBA colors
  39473. */
  39474. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39475. private static _IsSupported;
  39476. private static _HasMajorPerformanceCaveat;
  39477. /**
  39478. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39479. */
  39480. static get IsSupported(): boolean;
  39481. /**
  39482. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39483. * @returns true if the engine can be created
  39484. * @ignorenaming
  39485. */
  39486. static isSupported(): boolean;
  39487. /**
  39488. * 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)
  39489. */
  39490. static get HasMajorPerformanceCaveat(): boolean;
  39491. /**
  39492. * Find the next highest power of two.
  39493. * @param x Number to start search from.
  39494. * @return Next highest power of two.
  39495. */
  39496. static CeilingPOT(x: number): number;
  39497. /**
  39498. * Find the next lowest power of two.
  39499. * @param x Number to start search from.
  39500. * @return Next lowest power of two.
  39501. */
  39502. static FloorPOT(x: number): number;
  39503. /**
  39504. * Find the nearest power of two.
  39505. * @param x Number to start search from.
  39506. * @return Next nearest power of two.
  39507. */
  39508. static NearestPOT(x: number): number;
  39509. /**
  39510. * Get the closest exponent of two
  39511. * @param value defines the value to approximate
  39512. * @param max defines the maximum value to return
  39513. * @param mode defines how to define the closest value
  39514. * @returns closest exponent of two of the given value
  39515. */
  39516. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39517. /**
  39518. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39519. * @param func - the function to be called
  39520. * @param requester - the object that will request the next frame. Falls back to window.
  39521. * @returns frame number
  39522. */
  39523. static QueueNewFrame(func: () => void, requester?: any): number;
  39524. /**
  39525. * Gets host document
  39526. * @returns the host document object
  39527. */
  39528. getHostDocument(): Nullable<Document>;
  39529. }
  39530. }
  39531. declare module BABYLON {
  39532. /**
  39533. * Defines the source of the internal texture
  39534. */
  39535. export enum InternalTextureSource {
  39536. /**
  39537. * The source of the texture data is unknown
  39538. */
  39539. Unknown = 0,
  39540. /**
  39541. * Texture data comes from an URL
  39542. */
  39543. Url = 1,
  39544. /**
  39545. * Texture data is only used for temporary storage
  39546. */
  39547. Temp = 2,
  39548. /**
  39549. * Texture data comes from raw data (ArrayBuffer)
  39550. */
  39551. Raw = 3,
  39552. /**
  39553. * Texture content is dynamic (video or dynamic texture)
  39554. */
  39555. Dynamic = 4,
  39556. /**
  39557. * Texture content is generated by rendering to it
  39558. */
  39559. RenderTarget = 5,
  39560. /**
  39561. * Texture content is part of a multi render target process
  39562. */
  39563. MultiRenderTarget = 6,
  39564. /**
  39565. * Texture data comes from a cube data file
  39566. */
  39567. Cube = 7,
  39568. /**
  39569. * Texture data comes from a raw cube data
  39570. */
  39571. CubeRaw = 8,
  39572. /**
  39573. * Texture data come from a prefiltered cube data file
  39574. */
  39575. CubePrefiltered = 9,
  39576. /**
  39577. * Texture content is raw 3D data
  39578. */
  39579. Raw3D = 10,
  39580. /**
  39581. * Texture content is raw 2D array data
  39582. */
  39583. Raw2DArray = 11,
  39584. /**
  39585. * Texture content is a depth texture
  39586. */
  39587. Depth = 12,
  39588. /**
  39589. * Texture data comes from a raw cube data encoded with RGBD
  39590. */
  39591. CubeRawRGBD = 13
  39592. }
  39593. /**
  39594. * Class used to store data associated with WebGL texture data for the engine
  39595. * This class should not be used directly
  39596. */
  39597. export class InternalTexture {
  39598. /** @hidden */
  39599. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39600. /**
  39601. * Defines if the texture is ready
  39602. */
  39603. isReady: boolean;
  39604. /**
  39605. * Defines if the texture is a cube texture
  39606. */
  39607. isCube: boolean;
  39608. /**
  39609. * Defines if the texture contains 3D data
  39610. */
  39611. is3D: boolean;
  39612. /**
  39613. * Defines if the texture contains 2D array data
  39614. */
  39615. is2DArray: boolean;
  39616. /**
  39617. * Defines if the texture contains multiview data
  39618. */
  39619. isMultiview: boolean;
  39620. /**
  39621. * Gets the URL used to load this texture
  39622. */
  39623. url: string;
  39624. /**
  39625. * Gets the sampling mode of the texture
  39626. */
  39627. samplingMode: number;
  39628. /**
  39629. * Gets a boolean indicating if the texture needs mipmaps generation
  39630. */
  39631. generateMipMaps: boolean;
  39632. /**
  39633. * Gets the number of samples used by the texture (WebGL2+ only)
  39634. */
  39635. samples: number;
  39636. /**
  39637. * Gets the type of the texture (int, float...)
  39638. */
  39639. type: number;
  39640. /**
  39641. * Gets the format of the texture (RGB, RGBA...)
  39642. */
  39643. format: number;
  39644. /**
  39645. * Observable called when the texture is loaded
  39646. */
  39647. onLoadedObservable: Observable<InternalTexture>;
  39648. /**
  39649. * Gets the width of the texture
  39650. */
  39651. width: number;
  39652. /**
  39653. * Gets the height of the texture
  39654. */
  39655. height: number;
  39656. /**
  39657. * Gets the depth of the texture
  39658. */
  39659. depth: number;
  39660. /**
  39661. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39662. */
  39663. baseWidth: number;
  39664. /**
  39665. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39666. */
  39667. baseHeight: number;
  39668. /**
  39669. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39670. */
  39671. baseDepth: number;
  39672. /**
  39673. * Gets a boolean indicating if the texture is inverted on Y axis
  39674. */
  39675. invertY: boolean;
  39676. /** @hidden */
  39677. _invertVScale: boolean;
  39678. /** @hidden */
  39679. _associatedChannel: number;
  39680. /** @hidden */
  39681. _source: InternalTextureSource;
  39682. /** @hidden */
  39683. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39684. /** @hidden */
  39685. _bufferView: Nullable<ArrayBufferView>;
  39686. /** @hidden */
  39687. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39688. /** @hidden */
  39689. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39690. /** @hidden */
  39691. _size: number;
  39692. /** @hidden */
  39693. _extension: string;
  39694. /** @hidden */
  39695. _files: Nullable<string[]>;
  39696. /** @hidden */
  39697. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39698. /** @hidden */
  39699. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39700. /** @hidden */
  39701. _framebuffer: Nullable<WebGLFramebuffer>;
  39702. /** @hidden */
  39703. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39704. /** @hidden */
  39705. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39706. /** @hidden */
  39707. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39708. /** @hidden */
  39709. _attachments: Nullable<number[]>;
  39710. /** @hidden */
  39711. _textureArray: Nullable<InternalTexture[]>;
  39712. /** @hidden */
  39713. _cachedCoordinatesMode: Nullable<number>;
  39714. /** @hidden */
  39715. _cachedWrapU: Nullable<number>;
  39716. /** @hidden */
  39717. _cachedWrapV: Nullable<number>;
  39718. /** @hidden */
  39719. _cachedWrapR: Nullable<number>;
  39720. /** @hidden */
  39721. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39722. /** @hidden */
  39723. _isDisabled: boolean;
  39724. /** @hidden */
  39725. _compression: Nullable<string>;
  39726. /** @hidden */
  39727. _generateStencilBuffer: boolean;
  39728. /** @hidden */
  39729. _generateDepthBuffer: boolean;
  39730. /** @hidden */
  39731. _comparisonFunction: number;
  39732. /** @hidden */
  39733. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39734. /** @hidden */
  39735. _lodGenerationScale: number;
  39736. /** @hidden */
  39737. _lodGenerationOffset: number;
  39738. /** @hidden */
  39739. _depthStencilTexture: Nullable<InternalTexture>;
  39740. /** @hidden */
  39741. _colorTextureArray: Nullable<WebGLTexture>;
  39742. /** @hidden */
  39743. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39744. /** @hidden */
  39745. _lodTextureHigh: Nullable<BaseTexture>;
  39746. /** @hidden */
  39747. _lodTextureMid: Nullable<BaseTexture>;
  39748. /** @hidden */
  39749. _lodTextureLow: Nullable<BaseTexture>;
  39750. /** @hidden */
  39751. _isRGBD: boolean;
  39752. /** @hidden */
  39753. _linearSpecularLOD: boolean;
  39754. /** @hidden */
  39755. _irradianceTexture: Nullable<BaseTexture>;
  39756. /** @hidden */
  39757. _webGLTexture: Nullable<WebGLTexture>;
  39758. /** @hidden */
  39759. _references: number;
  39760. /** @hidden */
  39761. _gammaSpace: Nullable<boolean>;
  39762. private _engine;
  39763. /**
  39764. * Gets the Engine the texture belongs to.
  39765. * @returns The babylon engine
  39766. */
  39767. getEngine(): ThinEngine;
  39768. /**
  39769. * Gets the data source type of the texture
  39770. */
  39771. get source(): InternalTextureSource;
  39772. /**
  39773. * Creates a new InternalTexture
  39774. * @param engine defines the engine to use
  39775. * @param source defines the type of data that will be used
  39776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39777. */
  39778. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39779. /**
  39780. * Increments the number of references (ie. the number of Texture that point to it)
  39781. */
  39782. incrementReferences(): void;
  39783. /**
  39784. * Change the size of the texture (not the size of the content)
  39785. * @param width defines the new width
  39786. * @param height defines the new height
  39787. * @param depth defines the new depth (1 by default)
  39788. */
  39789. updateSize(width: int, height: int, depth?: int): void;
  39790. /** @hidden */
  39791. _rebuild(): void;
  39792. /** @hidden */
  39793. _swapAndDie(target: InternalTexture): void;
  39794. /**
  39795. * Dispose the current allocated resources
  39796. */
  39797. dispose(): void;
  39798. }
  39799. }
  39800. declare module BABYLON {
  39801. /**
  39802. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39804. */
  39805. export class Analyser {
  39806. /**
  39807. * Gets or sets the smoothing
  39808. * @ignorenaming
  39809. */
  39810. SMOOTHING: number;
  39811. /**
  39812. * Gets or sets the FFT table size
  39813. * @ignorenaming
  39814. */
  39815. FFT_SIZE: number;
  39816. /**
  39817. * Gets or sets the bar graph amplitude
  39818. * @ignorenaming
  39819. */
  39820. BARGRAPHAMPLITUDE: number;
  39821. /**
  39822. * Gets or sets the position of the debug canvas
  39823. * @ignorenaming
  39824. */
  39825. DEBUGCANVASPOS: {
  39826. x: number;
  39827. y: number;
  39828. };
  39829. /**
  39830. * Gets or sets the debug canvas size
  39831. * @ignorenaming
  39832. */
  39833. DEBUGCANVASSIZE: {
  39834. width: number;
  39835. height: number;
  39836. };
  39837. private _byteFreqs;
  39838. private _byteTime;
  39839. private _floatFreqs;
  39840. private _webAudioAnalyser;
  39841. private _debugCanvas;
  39842. private _debugCanvasContext;
  39843. private _scene;
  39844. private _registerFunc;
  39845. private _audioEngine;
  39846. /**
  39847. * Creates a new analyser
  39848. * @param scene defines hosting scene
  39849. */
  39850. constructor(scene: Scene);
  39851. /**
  39852. * Get the number of data values you will have to play with for the visualization
  39853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39854. * @returns a number
  39855. */
  39856. getFrequencyBinCount(): number;
  39857. /**
  39858. * Gets the current frequency data as a byte array
  39859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39860. * @returns a Uint8Array
  39861. */
  39862. getByteFrequencyData(): Uint8Array;
  39863. /**
  39864. * Gets the current waveform as a byte array
  39865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39866. * @returns a Uint8Array
  39867. */
  39868. getByteTimeDomainData(): Uint8Array;
  39869. /**
  39870. * Gets the current frequency data as a float array
  39871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39872. * @returns a Float32Array
  39873. */
  39874. getFloatFrequencyData(): Float32Array;
  39875. /**
  39876. * Renders the debug canvas
  39877. */
  39878. drawDebugCanvas(): void;
  39879. /**
  39880. * Stops rendering the debug canvas and removes it
  39881. */
  39882. stopDebugCanvas(): void;
  39883. /**
  39884. * Connects two audio nodes
  39885. * @param inputAudioNode defines first node to connect
  39886. * @param outputAudioNode defines second node to connect
  39887. */
  39888. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39889. /**
  39890. * Releases all associated resources
  39891. */
  39892. dispose(): void;
  39893. }
  39894. }
  39895. declare module BABYLON {
  39896. /**
  39897. * This represents an audio engine and it is responsible
  39898. * to play, synchronize and analyse sounds throughout the application.
  39899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39900. */
  39901. export interface IAudioEngine extends IDisposable {
  39902. /**
  39903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39904. */
  39905. readonly canUseWebAudio: boolean;
  39906. /**
  39907. * Gets the current AudioContext if available.
  39908. */
  39909. readonly audioContext: Nullable<AudioContext>;
  39910. /**
  39911. * The master gain node defines the global audio volume of your audio engine.
  39912. */
  39913. readonly masterGain: GainNode;
  39914. /**
  39915. * Gets whether or not mp3 are supported by your browser.
  39916. */
  39917. readonly isMP3supported: boolean;
  39918. /**
  39919. * Gets whether or not ogg are supported by your browser.
  39920. */
  39921. readonly isOGGsupported: boolean;
  39922. /**
  39923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39924. * @ignoreNaming
  39925. */
  39926. WarnedWebAudioUnsupported: boolean;
  39927. /**
  39928. * Defines if the audio engine relies on a custom unlocked button.
  39929. * In this case, the embedded button will not be displayed.
  39930. */
  39931. useCustomUnlockedButton: boolean;
  39932. /**
  39933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39934. */
  39935. readonly unlocked: boolean;
  39936. /**
  39937. * Event raised when audio has been unlocked on the browser.
  39938. */
  39939. onAudioUnlockedObservable: Observable<AudioEngine>;
  39940. /**
  39941. * Event raised when audio has been locked on the browser.
  39942. */
  39943. onAudioLockedObservable: Observable<AudioEngine>;
  39944. /**
  39945. * Flags the audio engine in Locked state.
  39946. * This happens due to new browser policies preventing audio to autoplay.
  39947. */
  39948. lock(): void;
  39949. /**
  39950. * Unlocks the audio engine once a user action has been done on the dom.
  39951. * This is helpful to resume play once browser policies have been satisfied.
  39952. */
  39953. unlock(): void;
  39954. /**
  39955. * Gets the global volume sets on the master gain.
  39956. * @returns the global volume if set or -1 otherwise
  39957. */
  39958. getGlobalVolume(): number;
  39959. /**
  39960. * Sets the global volume of your experience (sets on the master gain).
  39961. * @param newVolume Defines the new global volume of the application
  39962. */
  39963. setGlobalVolume(newVolume: number): void;
  39964. /**
  39965. * Connect the audio engine to an audio analyser allowing some amazing
  39966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39968. * @param analyser The analyser to connect to the engine
  39969. */
  39970. connectToAnalyser(analyser: Analyser): void;
  39971. }
  39972. /**
  39973. * This represents the default audio engine used in babylon.
  39974. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39976. */
  39977. export class AudioEngine implements IAudioEngine {
  39978. private _audioContext;
  39979. private _audioContextInitialized;
  39980. private _muteButton;
  39981. private _hostElement;
  39982. /**
  39983. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39984. */
  39985. canUseWebAudio: boolean;
  39986. /**
  39987. * The master gain node defines the global audio volume of your audio engine.
  39988. */
  39989. masterGain: GainNode;
  39990. /**
  39991. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39992. * @ignoreNaming
  39993. */
  39994. WarnedWebAudioUnsupported: boolean;
  39995. /**
  39996. * Gets whether or not mp3 are supported by your browser.
  39997. */
  39998. isMP3supported: boolean;
  39999. /**
  40000. * Gets whether or not ogg are supported by your browser.
  40001. */
  40002. isOGGsupported: boolean;
  40003. /**
  40004. * Gets whether audio has been unlocked on the device.
  40005. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40006. * a user interaction has happened.
  40007. */
  40008. unlocked: boolean;
  40009. /**
  40010. * Defines if the audio engine relies on a custom unlocked button.
  40011. * In this case, the embedded button will not be displayed.
  40012. */
  40013. useCustomUnlockedButton: boolean;
  40014. /**
  40015. * Event raised when audio has been unlocked on the browser.
  40016. */
  40017. onAudioUnlockedObservable: Observable<AudioEngine>;
  40018. /**
  40019. * Event raised when audio has been locked on the browser.
  40020. */
  40021. onAudioLockedObservable: Observable<AudioEngine>;
  40022. /**
  40023. * Gets the current AudioContext if available.
  40024. */
  40025. get audioContext(): Nullable<AudioContext>;
  40026. private _connectedAnalyser;
  40027. /**
  40028. * Instantiates a new audio engine.
  40029. *
  40030. * There should be only one per page as some browsers restrict the number
  40031. * of audio contexts you can create.
  40032. * @param hostElement defines the host element where to display the mute icon if necessary
  40033. */
  40034. constructor(hostElement?: Nullable<HTMLElement>);
  40035. /**
  40036. * Flags the audio engine in Locked state.
  40037. * This happens due to new browser policies preventing audio to autoplay.
  40038. */
  40039. lock(): void;
  40040. /**
  40041. * Unlocks the audio engine once a user action has been done on the dom.
  40042. * This is helpful to resume play once browser policies have been satisfied.
  40043. */
  40044. unlock(): void;
  40045. private _resumeAudioContext;
  40046. private _initializeAudioContext;
  40047. private _tryToRun;
  40048. private _triggerRunningState;
  40049. private _triggerSuspendedState;
  40050. private _displayMuteButton;
  40051. private _moveButtonToTopLeft;
  40052. private _onResize;
  40053. private _hideMuteButton;
  40054. /**
  40055. * Destroy and release the resources associated with the audio ccontext.
  40056. */
  40057. dispose(): void;
  40058. /**
  40059. * Gets the global volume sets on the master gain.
  40060. * @returns the global volume if set or -1 otherwise
  40061. */
  40062. getGlobalVolume(): number;
  40063. /**
  40064. * Sets the global volume of your experience (sets on the master gain).
  40065. * @param newVolume Defines the new global volume of the application
  40066. */
  40067. setGlobalVolume(newVolume: number): void;
  40068. /**
  40069. * Connect the audio engine to an audio analyser allowing some amazing
  40070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40072. * @param analyser The analyser to connect to the engine
  40073. */
  40074. connectToAnalyser(analyser: Analyser): void;
  40075. }
  40076. }
  40077. declare module BABYLON {
  40078. /**
  40079. * Interface used to present a loading screen while loading a scene
  40080. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40081. */
  40082. export interface ILoadingScreen {
  40083. /**
  40084. * Function called to display the loading screen
  40085. */
  40086. displayLoadingUI: () => void;
  40087. /**
  40088. * Function called to hide the loading screen
  40089. */
  40090. hideLoadingUI: () => void;
  40091. /**
  40092. * Gets or sets the color to use for the background
  40093. */
  40094. loadingUIBackgroundColor: string;
  40095. /**
  40096. * Gets or sets the text to display while loading
  40097. */
  40098. loadingUIText: string;
  40099. }
  40100. /**
  40101. * Class used for the default loading screen
  40102. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40103. */
  40104. export class DefaultLoadingScreen implements ILoadingScreen {
  40105. private _renderingCanvas;
  40106. private _loadingText;
  40107. private _loadingDivBackgroundColor;
  40108. private _loadingDiv;
  40109. private _loadingTextDiv;
  40110. /** Gets or sets the logo url to use for the default loading screen */
  40111. static DefaultLogoUrl: string;
  40112. /** Gets or sets the spinner url to use for the default loading screen */
  40113. static DefaultSpinnerUrl: string;
  40114. /**
  40115. * Creates a new default loading screen
  40116. * @param _renderingCanvas defines the canvas used to render the scene
  40117. * @param _loadingText defines the default text to display
  40118. * @param _loadingDivBackgroundColor defines the default background color
  40119. */
  40120. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40121. /**
  40122. * Function called to display the loading screen
  40123. */
  40124. displayLoadingUI(): void;
  40125. /**
  40126. * Function called to hide the loading screen
  40127. */
  40128. hideLoadingUI(): void;
  40129. /**
  40130. * Gets or sets the text to display while loading
  40131. */
  40132. set loadingUIText(text: string);
  40133. get loadingUIText(): string;
  40134. /**
  40135. * Gets or sets the color to use for the background
  40136. */
  40137. get loadingUIBackgroundColor(): string;
  40138. set loadingUIBackgroundColor(color: string);
  40139. private _resizeLoadingUI;
  40140. }
  40141. }
  40142. declare module BABYLON {
  40143. /**
  40144. * Interface for any object that can request an animation frame
  40145. */
  40146. export interface ICustomAnimationFrameRequester {
  40147. /**
  40148. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40149. */
  40150. renderFunction?: Function;
  40151. /**
  40152. * Called to request the next frame to render to
  40153. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40154. */
  40155. requestAnimationFrame: Function;
  40156. /**
  40157. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40159. */
  40160. requestID?: number;
  40161. }
  40162. }
  40163. declare module BABYLON {
  40164. /**
  40165. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40166. */
  40167. export class PerformanceMonitor {
  40168. private _enabled;
  40169. private _rollingFrameTime;
  40170. private _lastFrameTimeMs;
  40171. /**
  40172. * constructor
  40173. * @param frameSampleSize The number of samples required to saturate the sliding window
  40174. */
  40175. constructor(frameSampleSize?: number);
  40176. /**
  40177. * Samples current frame
  40178. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40179. */
  40180. sampleFrame(timeMs?: number): void;
  40181. /**
  40182. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40183. */
  40184. get averageFrameTime(): number;
  40185. /**
  40186. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40187. */
  40188. get averageFrameTimeVariance(): number;
  40189. /**
  40190. * Returns the frame time of the most recent frame
  40191. */
  40192. get instantaneousFrameTime(): number;
  40193. /**
  40194. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40195. */
  40196. get averageFPS(): number;
  40197. /**
  40198. * Returns the average framerate in frames per second using the most recent frame time
  40199. */
  40200. get instantaneousFPS(): number;
  40201. /**
  40202. * Returns true if enough samples have been taken to completely fill the sliding window
  40203. */
  40204. get isSaturated(): boolean;
  40205. /**
  40206. * Enables contributions to the sliding window sample set
  40207. */
  40208. enable(): void;
  40209. /**
  40210. * Disables contributions to the sliding window sample set
  40211. * Samples will not be interpolated over the disabled period
  40212. */
  40213. disable(): void;
  40214. /**
  40215. * Returns true if sampling is enabled
  40216. */
  40217. get isEnabled(): boolean;
  40218. /**
  40219. * Resets performance monitor
  40220. */
  40221. reset(): void;
  40222. }
  40223. /**
  40224. * RollingAverage
  40225. *
  40226. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40227. */
  40228. export class RollingAverage {
  40229. /**
  40230. * Current average
  40231. */
  40232. average: number;
  40233. /**
  40234. * Current variance
  40235. */
  40236. variance: number;
  40237. protected _samples: Array<number>;
  40238. protected _sampleCount: number;
  40239. protected _pos: number;
  40240. protected _m2: number;
  40241. /**
  40242. * constructor
  40243. * @param length The number of samples required to saturate the sliding window
  40244. */
  40245. constructor(length: number);
  40246. /**
  40247. * Adds a sample to the sample set
  40248. * @param v The sample value
  40249. */
  40250. add(v: number): void;
  40251. /**
  40252. * Returns previously added values or null if outside of history or outside the sliding window domain
  40253. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40254. * @return Value previously recorded with add() or null if outside of range
  40255. */
  40256. history(i: number): number;
  40257. /**
  40258. * Returns true if enough samples have been taken to completely fill the sliding window
  40259. * @return true if sample-set saturated
  40260. */
  40261. isSaturated(): boolean;
  40262. /**
  40263. * Resets the rolling average (equivalent to 0 samples taken so far)
  40264. */
  40265. reset(): void;
  40266. /**
  40267. * Wraps a value around the sample range boundaries
  40268. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40269. * @return Wrapped position in sample range
  40270. */
  40271. protected _wrapPosition(i: number): number;
  40272. }
  40273. }
  40274. declare module BABYLON {
  40275. /**
  40276. * This class is used to track a performance counter which is number based.
  40277. * The user has access to many properties which give statistics of different nature.
  40278. *
  40279. * The implementer can track two kinds of Performance Counter: time and count.
  40280. * 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.
  40281. * 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.
  40282. */
  40283. export class PerfCounter {
  40284. /**
  40285. * Gets or sets a global boolean to turn on and off all the counters
  40286. */
  40287. static Enabled: boolean;
  40288. /**
  40289. * Returns the smallest value ever
  40290. */
  40291. get min(): number;
  40292. /**
  40293. * Returns the biggest value ever
  40294. */
  40295. get max(): number;
  40296. /**
  40297. * Returns the average value since the performance counter is running
  40298. */
  40299. get average(): number;
  40300. /**
  40301. * Returns the average value of the last second the counter was monitored
  40302. */
  40303. get lastSecAverage(): number;
  40304. /**
  40305. * Returns the current value
  40306. */
  40307. get current(): number;
  40308. /**
  40309. * Gets the accumulated total
  40310. */
  40311. get total(): number;
  40312. /**
  40313. * Gets the total value count
  40314. */
  40315. get count(): number;
  40316. /**
  40317. * Creates a new counter
  40318. */
  40319. constructor();
  40320. /**
  40321. * Call this method to start monitoring a new frame.
  40322. * 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.
  40323. */
  40324. fetchNewFrame(): void;
  40325. /**
  40326. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40327. * @param newCount the count value to add to the monitored count
  40328. * @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.
  40329. */
  40330. addCount(newCount: number, fetchResult: boolean): void;
  40331. /**
  40332. * Start monitoring this performance counter
  40333. */
  40334. beginMonitoring(): void;
  40335. /**
  40336. * Compute the time lapsed since the previous beginMonitoring() call.
  40337. * @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
  40338. */
  40339. endMonitoring(newFrame?: boolean): void;
  40340. private _fetchResult;
  40341. private _startMonitoringTime;
  40342. private _min;
  40343. private _max;
  40344. private _average;
  40345. private _current;
  40346. private _totalValueCount;
  40347. private _totalAccumulated;
  40348. private _lastSecAverage;
  40349. private _lastSecAccumulated;
  40350. private _lastSecTime;
  40351. private _lastSecValueCount;
  40352. }
  40353. }
  40354. declare module BABYLON {
  40355. interface ThinEngine {
  40356. /** @hidden */
  40357. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * Defines the interface used by display changed events
  40363. */
  40364. export interface IDisplayChangedEventArgs {
  40365. /** Gets the vrDisplay object (if any) */
  40366. vrDisplay: Nullable<any>;
  40367. /** Gets a boolean indicating if webVR is supported */
  40368. vrSupported: boolean;
  40369. }
  40370. /**
  40371. * Defines the interface used by objects containing a viewport (like a camera)
  40372. */
  40373. interface IViewportOwnerLike {
  40374. /**
  40375. * Gets or sets the viewport
  40376. */
  40377. viewport: IViewportLike;
  40378. }
  40379. /**
  40380. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40381. */
  40382. export class Engine extends ThinEngine {
  40383. /** Defines that alpha blending is disabled */
  40384. static readonly ALPHA_DISABLE: number;
  40385. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40386. static readonly ALPHA_ADD: number;
  40387. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40388. static readonly ALPHA_COMBINE: number;
  40389. /** Defines that alpha blending to DEST - SRC * DEST */
  40390. static readonly ALPHA_SUBTRACT: number;
  40391. /** Defines that alpha blending to SRC * DEST */
  40392. static readonly ALPHA_MULTIPLY: number;
  40393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40394. static readonly ALPHA_MAXIMIZED: number;
  40395. /** Defines that alpha blending to SRC + DEST */
  40396. static readonly ALPHA_ONEONE: number;
  40397. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40398. static readonly ALPHA_PREMULTIPLIED: number;
  40399. /**
  40400. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40401. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40402. */
  40403. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40404. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40405. static readonly ALPHA_INTERPOLATE: number;
  40406. /**
  40407. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40408. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40409. */
  40410. static readonly ALPHA_SCREENMODE: number;
  40411. /** Defines that the ressource is not delayed*/
  40412. static readonly DELAYLOADSTATE_NONE: number;
  40413. /** Defines that the ressource was successfully delay loaded */
  40414. static readonly DELAYLOADSTATE_LOADED: number;
  40415. /** Defines that the ressource is currently delay loading */
  40416. static readonly DELAYLOADSTATE_LOADING: number;
  40417. /** Defines that the ressource is delayed and has not started loading */
  40418. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40420. static readonly NEVER: number;
  40421. /** 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 */
  40422. static readonly ALWAYS: number;
  40423. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40424. static readonly LESS: number;
  40425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40426. static readonly EQUAL: number;
  40427. /** 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 */
  40428. static readonly LEQUAL: number;
  40429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40430. static readonly GREATER: number;
  40431. /** 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 */
  40432. static readonly GEQUAL: number;
  40433. /** 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 */
  40434. static readonly NOTEQUAL: number;
  40435. /** Passed to stencilOperation to specify that stencil value must be kept */
  40436. static readonly KEEP: number;
  40437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40438. static readonly REPLACE: number;
  40439. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40440. static readonly INCR: number;
  40441. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40442. static readonly DECR: number;
  40443. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40444. static readonly INVERT: number;
  40445. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40446. static readonly INCR_WRAP: number;
  40447. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40448. static readonly DECR_WRAP: number;
  40449. /** Texture is not repeating outside of 0..1 UVs */
  40450. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40451. /** Texture is repeating outside of 0..1 UVs */
  40452. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40453. /** Texture is repeating and mirrored */
  40454. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40455. /** ALPHA */
  40456. static readonly TEXTUREFORMAT_ALPHA: number;
  40457. /** LUMINANCE */
  40458. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40459. /** LUMINANCE_ALPHA */
  40460. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40461. /** RGB */
  40462. static readonly TEXTUREFORMAT_RGB: number;
  40463. /** RGBA */
  40464. static readonly TEXTUREFORMAT_RGBA: number;
  40465. /** RED */
  40466. static readonly TEXTUREFORMAT_RED: number;
  40467. /** RED (2nd reference) */
  40468. static readonly TEXTUREFORMAT_R: number;
  40469. /** RG */
  40470. static readonly TEXTUREFORMAT_RG: number;
  40471. /** RED_INTEGER */
  40472. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40473. /** RED_INTEGER (2nd reference) */
  40474. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40475. /** RG_INTEGER */
  40476. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40477. /** RGB_INTEGER */
  40478. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40479. /** RGBA_INTEGER */
  40480. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40481. /** UNSIGNED_BYTE */
  40482. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40483. /** UNSIGNED_BYTE (2nd reference) */
  40484. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40485. /** FLOAT */
  40486. static readonly TEXTURETYPE_FLOAT: number;
  40487. /** HALF_FLOAT */
  40488. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40489. /** BYTE */
  40490. static readonly TEXTURETYPE_BYTE: number;
  40491. /** SHORT */
  40492. static readonly TEXTURETYPE_SHORT: number;
  40493. /** UNSIGNED_SHORT */
  40494. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40495. /** INT */
  40496. static readonly TEXTURETYPE_INT: number;
  40497. /** UNSIGNED_INT */
  40498. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40499. /** UNSIGNED_SHORT_4_4_4_4 */
  40500. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40501. /** UNSIGNED_SHORT_5_5_5_1 */
  40502. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40503. /** UNSIGNED_SHORT_5_6_5 */
  40504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40505. /** UNSIGNED_INT_2_10_10_10_REV */
  40506. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40507. /** UNSIGNED_INT_24_8 */
  40508. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40509. /** UNSIGNED_INT_10F_11F_11F_REV */
  40510. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40511. /** UNSIGNED_INT_5_9_9_9_REV */
  40512. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40513. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40514. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40515. /** nearest is mag = nearest and min = nearest and mip = linear */
  40516. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40517. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40518. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40519. /** Trilinear is mag = linear and min = linear and mip = linear */
  40520. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40521. /** nearest is mag = nearest and min = nearest and mip = linear */
  40522. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40524. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40525. /** Trilinear is mag = linear and min = linear and mip = linear */
  40526. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40527. /** mag = nearest and min = nearest and mip = nearest */
  40528. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40529. /** mag = nearest and min = linear and mip = nearest */
  40530. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40531. /** mag = nearest and min = linear and mip = linear */
  40532. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40533. /** mag = nearest and min = linear and mip = none */
  40534. static readonly TEXTURE_NEAREST_LINEAR: number;
  40535. /** mag = nearest and min = nearest and mip = none */
  40536. static readonly TEXTURE_NEAREST_NEAREST: number;
  40537. /** mag = linear and min = nearest and mip = nearest */
  40538. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40539. /** mag = linear and min = nearest and mip = linear */
  40540. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40541. /** mag = linear and min = linear and mip = none */
  40542. static readonly TEXTURE_LINEAR_LINEAR: number;
  40543. /** mag = linear and min = nearest and mip = none */
  40544. static readonly TEXTURE_LINEAR_NEAREST: number;
  40545. /** Explicit coordinates mode */
  40546. static readonly TEXTURE_EXPLICIT_MODE: number;
  40547. /** Spherical coordinates mode */
  40548. static readonly TEXTURE_SPHERICAL_MODE: number;
  40549. /** Planar coordinates mode */
  40550. static readonly TEXTURE_PLANAR_MODE: number;
  40551. /** Cubic coordinates mode */
  40552. static readonly TEXTURE_CUBIC_MODE: number;
  40553. /** Projection coordinates mode */
  40554. static readonly TEXTURE_PROJECTION_MODE: number;
  40555. /** Skybox coordinates mode */
  40556. static readonly TEXTURE_SKYBOX_MODE: number;
  40557. /** Inverse Cubic coordinates mode */
  40558. static readonly TEXTURE_INVCUBIC_MODE: number;
  40559. /** Equirectangular coordinates mode */
  40560. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40561. /** Equirectangular Fixed coordinates mode */
  40562. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40563. /** Equirectangular Fixed Mirrored coordinates mode */
  40564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40565. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40566. static readonly SCALEMODE_FLOOR: number;
  40567. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40568. static readonly SCALEMODE_NEAREST: number;
  40569. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40570. static readonly SCALEMODE_CEILING: number;
  40571. /**
  40572. * Returns the current npm package of the sdk
  40573. */
  40574. static get NpmPackage(): string;
  40575. /**
  40576. * Returns the current version of the framework
  40577. */
  40578. static get Version(): string;
  40579. /** Gets the list of created engines */
  40580. static get Instances(): Engine[];
  40581. /**
  40582. * Gets the latest created engine
  40583. */
  40584. static get LastCreatedEngine(): Nullable<Engine>;
  40585. /**
  40586. * Gets the latest created scene
  40587. */
  40588. static get LastCreatedScene(): Nullable<Scene>;
  40589. /**
  40590. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40591. * @param flag defines which part of the materials must be marked as dirty
  40592. * @param predicate defines a predicate used to filter which materials should be affected
  40593. */
  40594. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40595. /**
  40596. * Method called to create the default loading screen.
  40597. * This can be overriden in your own app.
  40598. * @param canvas The rendering canvas element
  40599. * @returns The loading screen
  40600. */
  40601. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40602. /**
  40603. * Method called to create the default rescale post process on each engine.
  40604. */
  40605. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40606. /**
  40607. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40608. **/
  40609. enableOfflineSupport: boolean;
  40610. /**
  40611. * 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)
  40612. **/
  40613. disableManifestCheck: boolean;
  40614. /**
  40615. * Gets the list of created scenes
  40616. */
  40617. scenes: Scene[];
  40618. /**
  40619. * Event raised when a new scene is created
  40620. */
  40621. onNewSceneAddedObservable: Observable<Scene>;
  40622. /**
  40623. * Gets the list of created postprocesses
  40624. */
  40625. postProcesses: PostProcess[];
  40626. /**
  40627. * Gets a boolean indicating if the pointer is currently locked
  40628. */
  40629. isPointerLock: boolean;
  40630. /**
  40631. * Observable event triggered each time the rendering canvas is resized
  40632. */
  40633. onResizeObservable: Observable<Engine>;
  40634. /**
  40635. * Observable event triggered each time the canvas loses focus
  40636. */
  40637. onCanvasBlurObservable: Observable<Engine>;
  40638. /**
  40639. * Observable event triggered each time the canvas gains focus
  40640. */
  40641. onCanvasFocusObservable: Observable<Engine>;
  40642. /**
  40643. * Observable event triggered each time the canvas receives pointerout event
  40644. */
  40645. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40646. /**
  40647. * Observable raised when the engine begins a new frame
  40648. */
  40649. onBeginFrameObservable: Observable<Engine>;
  40650. /**
  40651. * If set, will be used to request the next animation frame for the render loop
  40652. */
  40653. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40654. /**
  40655. * Observable raised when the engine ends the current frame
  40656. */
  40657. onEndFrameObservable: Observable<Engine>;
  40658. /**
  40659. * Observable raised when the engine is about to compile a shader
  40660. */
  40661. onBeforeShaderCompilationObservable: Observable<Engine>;
  40662. /**
  40663. * Observable raised when the engine has jsut compiled a shader
  40664. */
  40665. onAfterShaderCompilationObservable: Observable<Engine>;
  40666. /**
  40667. * Gets the audio engine
  40668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40669. * @ignorenaming
  40670. */
  40671. static audioEngine: IAudioEngine;
  40672. /**
  40673. * Default AudioEngine factory responsible of creating the Audio Engine.
  40674. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40675. */
  40676. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40677. /**
  40678. * Default offline support factory responsible of creating a tool used to store data locally.
  40679. * By default, this will create a Database object if the workload has been embedded.
  40680. */
  40681. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40682. private _loadingScreen;
  40683. private _pointerLockRequested;
  40684. private _rescalePostProcess;
  40685. private _deterministicLockstep;
  40686. private _lockstepMaxSteps;
  40687. private _timeStep;
  40688. protected get _supportsHardwareTextureRescaling(): boolean;
  40689. private _fps;
  40690. private _deltaTime;
  40691. /** @hidden */
  40692. _drawCalls: PerfCounter;
  40693. /** 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 */
  40694. canvasTabIndex: number;
  40695. /**
  40696. * Turn this value on if you want to pause FPS computation when in background
  40697. */
  40698. disablePerformanceMonitorInBackground: boolean;
  40699. private _performanceMonitor;
  40700. /**
  40701. * Gets the performance monitor attached to this engine
  40702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40703. */
  40704. get performanceMonitor(): PerformanceMonitor;
  40705. private _onFocus;
  40706. private _onBlur;
  40707. private _onCanvasPointerOut;
  40708. private _onCanvasBlur;
  40709. private _onCanvasFocus;
  40710. private _onFullscreenChange;
  40711. private _onPointerLockChange;
  40712. /**
  40713. * Gets the HTML element used to attach event listeners
  40714. * @returns a HTML element
  40715. */
  40716. getInputElement(): Nullable<HTMLElement>;
  40717. /**
  40718. * Creates a new engine
  40719. * @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
  40720. * @param antialias defines enable antialiasing (default: false)
  40721. * @param options defines further options to be sent to the getContext() function
  40722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40723. */
  40724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40725. /**
  40726. * Gets current aspect ratio
  40727. * @param viewportOwner defines the camera to use to get the aspect ratio
  40728. * @param useScreen defines if screen size must be used (or the current render target if any)
  40729. * @returns a number defining the aspect ratio
  40730. */
  40731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40732. /**
  40733. * Gets current screen aspect ratio
  40734. * @returns a number defining the aspect ratio
  40735. */
  40736. getScreenAspectRatio(): number;
  40737. /**
  40738. * Gets the client rect of the HTML canvas attached with the current webGL context
  40739. * @returns a client rectanglee
  40740. */
  40741. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40742. /**
  40743. * Gets the client rect of the HTML element used for events
  40744. * @returns a client rectanglee
  40745. */
  40746. getInputElementClientRect(): Nullable<ClientRect>;
  40747. /**
  40748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40750. * @returns true if engine is in deterministic lock step mode
  40751. */
  40752. isDeterministicLockStep(): boolean;
  40753. /**
  40754. * Gets the max steps when engine is running in deterministic lock step
  40755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40756. * @returns the max steps
  40757. */
  40758. getLockstepMaxSteps(): number;
  40759. /**
  40760. * Returns the time in ms between steps when using deterministic lock step.
  40761. * @returns time step in (ms)
  40762. */
  40763. getTimeStep(): number;
  40764. /**
  40765. * Force the mipmap generation for the given render target texture
  40766. * @param texture defines the render target texture to use
  40767. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40768. */
  40769. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40770. /** States */
  40771. /**
  40772. * Set various states to the webGL context
  40773. * @param culling defines backface culling state
  40774. * @param zOffset defines the value to apply to zOffset (0 by default)
  40775. * @param force defines if states must be applied even if cache is up to date
  40776. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40777. */
  40778. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40779. /**
  40780. * Set the z offset to apply to current rendering
  40781. * @param value defines the offset to apply
  40782. */
  40783. setZOffset(value: number): void;
  40784. /**
  40785. * Gets the current value of the zOffset
  40786. * @returns the current zOffset state
  40787. */
  40788. getZOffset(): number;
  40789. /**
  40790. * Enable or disable depth buffering
  40791. * @param enable defines the state to set
  40792. */
  40793. setDepthBuffer(enable: boolean): void;
  40794. /**
  40795. * Gets a boolean indicating if depth writing is enabled
  40796. * @returns the current depth writing state
  40797. */
  40798. getDepthWrite(): boolean;
  40799. /**
  40800. * Enable or disable depth writing
  40801. * @param enable defines the state to set
  40802. */
  40803. setDepthWrite(enable: boolean): void;
  40804. /**
  40805. * Gets a boolean indicating if stencil buffer is enabled
  40806. * @returns the current stencil buffer state
  40807. */
  40808. getStencilBuffer(): boolean;
  40809. /**
  40810. * Enable or disable the stencil buffer
  40811. * @param enable defines if the stencil buffer must be enabled or disabled
  40812. */
  40813. setStencilBuffer(enable: boolean): void;
  40814. /**
  40815. * Gets the current stencil mask
  40816. * @returns a number defining the new stencil mask to use
  40817. */
  40818. getStencilMask(): number;
  40819. /**
  40820. * Sets the current stencil mask
  40821. * @param mask defines the new stencil mask to use
  40822. */
  40823. setStencilMask(mask: number): void;
  40824. /**
  40825. * Gets the current stencil function
  40826. * @returns a number defining the stencil function to use
  40827. */
  40828. getStencilFunction(): number;
  40829. /**
  40830. * Gets the current stencil reference value
  40831. * @returns a number defining the stencil reference value to use
  40832. */
  40833. getStencilFunctionReference(): number;
  40834. /**
  40835. * Gets the current stencil mask
  40836. * @returns a number defining the stencil mask to use
  40837. */
  40838. getStencilFunctionMask(): number;
  40839. /**
  40840. * Sets the current stencil function
  40841. * @param stencilFunc defines the new stencil function to use
  40842. */
  40843. setStencilFunction(stencilFunc: number): void;
  40844. /**
  40845. * Sets the current stencil reference
  40846. * @param reference defines the new stencil reference to use
  40847. */
  40848. setStencilFunctionReference(reference: number): void;
  40849. /**
  40850. * Sets the current stencil mask
  40851. * @param mask defines the new stencil mask to use
  40852. */
  40853. setStencilFunctionMask(mask: number): void;
  40854. /**
  40855. * Gets the current stencil operation when stencil fails
  40856. * @returns a number defining stencil operation to use when stencil fails
  40857. */
  40858. getStencilOperationFail(): number;
  40859. /**
  40860. * Gets the current stencil operation when depth fails
  40861. * @returns a number defining stencil operation to use when depth fails
  40862. */
  40863. getStencilOperationDepthFail(): number;
  40864. /**
  40865. * Gets the current stencil operation when stencil passes
  40866. * @returns a number defining stencil operation to use when stencil passes
  40867. */
  40868. getStencilOperationPass(): number;
  40869. /**
  40870. * Sets the stencil operation to use when stencil fails
  40871. * @param operation defines the stencil operation to use when stencil fails
  40872. */
  40873. setStencilOperationFail(operation: number): void;
  40874. /**
  40875. * Sets the stencil operation to use when depth fails
  40876. * @param operation defines the stencil operation to use when depth fails
  40877. */
  40878. setStencilOperationDepthFail(operation: number): void;
  40879. /**
  40880. * Sets the stencil operation to use when stencil passes
  40881. * @param operation defines the stencil operation to use when stencil passes
  40882. */
  40883. setStencilOperationPass(operation: number): void;
  40884. /**
  40885. * Sets a boolean indicating if the dithering state is enabled or disabled
  40886. * @param value defines the dithering state
  40887. */
  40888. setDitheringState(value: boolean): void;
  40889. /**
  40890. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40891. * @param value defines the rasterizer state
  40892. */
  40893. setRasterizerState(value: boolean): void;
  40894. /**
  40895. * Gets the current depth function
  40896. * @returns a number defining the depth function
  40897. */
  40898. getDepthFunction(): Nullable<number>;
  40899. /**
  40900. * Sets the current depth function
  40901. * @param depthFunc defines the function to use
  40902. */
  40903. setDepthFunction(depthFunc: number): void;
  40904. /**
  40905. * Sets the current depth function to GREATER
  40906. */
  40907. setDepthFunctionToGreater(): void;
  40908. /**
  40909. * Sets the current depth function to GEQUAL
  40910. */
  40911. setDepthFunctionToGreaterOrEqual(): void;
  40912. /**
  40913. * Sets the current depth function to LESS
  40914. */
  40915. setDepthFunctionToLess(): void;
  40916. /**
  40917. * Sets the current depth function to LEQUAL
  40918. */
  40919. setDepthFunctionToLessOrEqual(): void;
  40920. private _cachedStencilBuffer;
  40921. private _cachedStencilFunction;
  40922. private _cachedStencilMask;
  40923. private _cachedStencilOperationPass;
  40924. private _cachedStencilOperationFail;
  40925. private _cachedStencilOperationDepthFail;
  40926. private _cachedStencilReference;
  40927. /**
  40928. * Caches the the state of the stencil buffer
  40929. */
  40930. cacheStencilState(): void;
  40931. /**
  40932. * Restores the state of the stencil buffer
  40933. */
  40934. restoreStencilState(): void;
  40935. /**
  40936. * Directly set the WebGL Viewport
  40937. * @param x defines the x coordinate of the viewport (in screen space)
  40938. * @param y defines the y coordinate of the viewport (in screen space)
  40939. * @param width defines the width of the viewport (in screen space)
  40940. * @param height defines the height of the viewport (in screen space)
  40941. * @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
  40942. */
  40943. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40944. /**
  40945. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40947. * @param y defines the y-coordinate of the corner of the clear rectangle
  40948. * @param width defines the width of the clear rectangle
  40949. * @param height defines the height of the clear rectangle
  40950. * @param clearColor defines the clear color
  40951. */
  40952. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40953. /**
  40954. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40956. * @param y defines the y-coordinate of the corner of the clear rectangle
  40957. * @param width defines the width of the clear rectangle
  40958. * @param height defines the height of the clear rectangle
  40959. */
  40960. enableScissor(x: number, y: number, width: number, height: number): void;
  40961. /**
  40962. * Disable previously set scissor test rectangle
  40963. */
  40964. disableScissor(): void;
  40965. protected _reportDrawCall(): void;
  40966. /**
  40967. * Initializes a webVR display and starts listening to display change events
  40968. * The onVRDisplayChangedObservable will be notified upon these changes
  40969. * @returns The onVRDisplayChangedObservable
  40970. */
  40971. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40972. /** @hidden */
  40973. _prepareVRComponent(): void;
  40974. /** @hidden */
  40975. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40976. /** @hidden */
  40977. _submitVRFrame(): void;
  40978. /**
  40979. * Call this function to leave webVR mode
  40980. * Will do nothing if webVR is not supported or if there is no webVR device
  40981. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40982. */
  40983. disableVR(): void;
  40984. /**
  40985. * Gets a boolean indicating that the system is in VR mode and is presenting
  40986. * @returns true if VR mode is engaged
  40987. */
  40988. isVRPresenting(): boolean;
  40989. /** @hidden */
  40990. _requestVRFrame(): void;
  40991. /** @hidden */
  40992. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40993. /**
  40994. * Gets the source code of the vertex shader associated with a specific webGL program
  40995. * @param program defines the program to use
  40996. * @returns a string containing the source code of the vertex shader associated with the program
  40997. */
  40998. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  40999. /**
  41000. * Gets the source code of the fragment shader associated with a specific webGL program
  41001. * @param program defines the program to use
  41002. * @returns a string containing the source code of the fragment shader associated with the program
  41003. */
  41004. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41005. /**
  41006. * Sets a depth stencil texture from a render target to the according uniform.
  41007. * @param channel The texture channel
  41008. * @param uniform The uniform to set
  41009. * @param texture The render target texture containing the depth stencil texture to apply
  41010. */
  41011. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41012. /**
  41013. * Sets a texture to the webGL context from a postprocess
  41014. * @param channel defines the channel to use
  41015. * @param postProcess defines the source postprocess
  41016. */
  41017. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41018. /**
  41019. * Binds the output of the passed in post process to the texture channel specified
  41020. * @param channel The channel the texture should be bound to
  41021. * @param postProcess The post process which's output should be bound
  41022. */
  41023. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41024. protected _rebuildBuffers(): void;
  41025. /** @hidden */
  41026. _renderFrame(): void;
  41027. _renderLoop(): void;
  41028. /** @hidden */
  41029. _renderViews(): boolean;
  41030. /**
  41031. * Toggle full screen mode
  41032. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41033. */
  41034. switchFullscreen(requestPointerLock: boolean): void;
  41035. /**
  41036. * Enters full screen mode
  41037. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41038. */
  41039. enterFullscreen(requestPointerLock: boolean): void;
  41040. /**
  41041. * Exits full screen mode
  41042. */
  41043. exitFullscreen(): void;
  41044. /**
  41045. * Enters Pointerlock mode
  41046. */
  41047. enterPointerlock(): void;
  41048. /**
  41049. * Exits Pointerlock mode
  41050. */
  41051. exitPointerlock(): void;
  41052. /**
  41053. * Begin a new frame
  41054. */
  41055. beginFrame(): void;
  41056. /**
  41057. * Enf the current frame
  41058. */
  41059. endFrame(): void;
  41060. resize(): void;
  41061. /**
  41062. * Force a specific size of the canvas
  41063. * @param width defines the new canvas' width
  41064. * @param height defines the new canvas' height
  41065. * @returns true if the size was changed
  41066. */
  41067. setSize(width: number, height: number): boolean;
  41068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41069. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41070. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41071. _releaseTexture(texture: InternalTexture): void;
  41072. /**
  41073. * @hidden
  41074. * Rescales a texture
  41075. * @param source input texutre
  41076. * @param destination destination texture
  41077. * @param scene scene to use to render the resize
  41078. * @param internalFormat format to use when resizing
  41079. * @param onComplete callback to be called when resize has completed
  41080. */
  41081. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41082. /**
  41083. * Gets the current framerate
  41084. * @returns a number representing the framerate
  41085. */
  41086. getFps(): number;
  41087. /**
  41088. * Gets the time spent between current and previous frame
  41089. * @returns a number representing the delta time in ms
  41090. */
  41091. getDeltaTime(): number;
  41092. private _measureFps;
  41093. /** @hidden */
  41094. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41095. /**
  41096. * Updates the sample count of a render target texture
  41097. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41098. * @param texture defines the texture to update
  41099. * @param samples defines the sample count to set
  41100. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41101. */
  41102. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41103. /**
  41104. * Updates a depth texture Comparison Mode and Function.
  41105. * If the comparison Function is equal to 0, the mode will be set to none.
  41106. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41107. * @param texture The texture to set the comparison function for
  41108. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41109. */
  41110. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41111. /**
  41112. * Creates a webGL buffer to use with instanciation
  41113. * @param capacity defines the size of the buffer
  41114. * @returns the webGL buffer
  41115. */
  41116. createInstancesBuffer(capacity: number): DataBuffer;
  41117. /**
  41118. * Delete a webGL buffer used with instanciation
  41119. * @param buffer defines the webGL buffer to delete
  41120. */
  41121. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41122. private _clientWaitAsync;
  41123. /** @hidden */
  41124. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41125. dispose(): void;
  41126. private _disableTouchAction;
  41127. /**
  41128. * Display the loading screen
  41129. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41130. */
  41131. displayLoadingUI(): void;
  41132. /**
  41133. * Hide the loading screen
  41134. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41135. */
  41136. hideLoadingUI(): void;
  41137. /**
  41138. * Gets the current loading screen object
  41139. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41140. */
  41141. get loadingScreen(): ILoadingScreen;
  41142. /**
  41143. * Sets the current loading screen object
  41144. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41145. */
  41146. set loadingScreen(loadingScreen: ILoadingScreen);
  41147. /**
  41148. * Sets the current loading screen text
  41149. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41150. */
  41151. set loadingUIText(text: string);
  41152. /**
  41153. * Sets the current loading screen background color
  41154. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41155. */
  41156. set loadingUIBackgroundColor(color: string);
  41157. /** Pointerlock and fullscreen */
  41158. /**
  41159. * Ask the browser to promote the current element to pointerlock mode
  41160. * @param element defines the DOM element to promote
  41161. */
  41162. static _RequestPointerlock(element: HTMLElement): void;
  41163. /**
  41164. * Asks the browser to exit pointerlock mode
  41165. */
  41166. static _ExitPointerlock(): void;
  41167. /**
  41168. * Ask the browser to promote the current element to fullscreen rendering mode
  41169. * @param element defines the DOM element to promote
  41170. */
  41171. static _RequestFullscreen(element: HTMLElement): void;
  41172. /**
  41173. * Asks the browser to exit fullscreen mode
  41174. */
  41175. static _ExitFullscreen(): void;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41181. * during the life time of the application.
  41182. */
  41183. export class EngineStore {
  41184. /** Gets the list of created engines */
  41185. static Instances: Engine[];
  41186. /** @hidden */
  41187. static _LastCreatedScene: Nullable<Scene>;
  41188. /**
  41189. * Gets the latest created engine
  41190. */
  41191. static get LastCreatedEngine(): Nullable<Engine>;
  41192. /**
  41193. * Gets the latest created scene
  41194. */
  41195. static get LastCreatedScene(): Nullable<Scene>;
  41196. /**
  41197. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41198. * @ignorenaming
  41199. */
  41200. static UseFallbackTexture: boolean;
  41201. /**
  41202. * Texture content used if a texture cannot loaded
  41203. * @ignorenaming
  41204. */
  41205. static FallbackTexture: string;
  41206. }
  41207. }
  41208. declare module BABYLON {
  41209. /**
  41210. * Helper class that provides a small promise polyfill
  41211. */
  41212. export class PromisePolyfill {
  41213. /**
  41214. * Static function used to check if the polyfill is required
  41215. * If this is the case then the function will inject the polyfill to window.Promise
  41216. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41217. */
  41218. static Apply(force?: boolean): void;
  41219. }
  41220. }
  41221. declare module BABYLON {
  41222. /**
  41223. * Interface for screenshot methods with describe argument called `size` as object with options
  41224. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41225. */
  41226. export interface IScreenshotSize {
  41227. /**
  41228. * number in pixels for canvas height
  41229. */
  41230. height?: number;
  41231. /**
  41232. * multiplier allowing render at a higher or lower resolution
  41233. * If value is defined then height and width will be ignored and taken from camera
  41234. */
  41235. precision?: number;
  41236. /**
  41237. * number in pixels for canvas width
  41238. */
  41239. width?: number;
  41240. }
  41241. }
  41242. declare module BABYLON {
  41243. interface IColor4Like {
  41244. r: float;
  41245. g: float;
  41246. b: float;
  41247. a: float;
  41248. }
  41249. /**
  41250. * Class containing a set of static utilities functions
  41251. */
  41252. export class Tools {
  41253. /**
  41254. * Gets or sets the base URL to use to load assets
  41255. */
  41256. static get BaseUrl(): string;
  41257. static set BaseUrl(value: string);
  41258. /**
  41259. * Enable/Disable Custom HTTP Request Headers globally.
  41260. * default = false
  41261. * @see CustomRequestHeaders
  41262. */
  41263. static UseCustomRequestHeaders: boolean;
  41264. /**
  41265. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41266. * i.e. when loading files, where the server/service expects an Authorization header
  41267. */
  41268. static CustomRequestHeaders: {
  41269. [key: string]: string;
  41270. };
  41271. /**
  41272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41273. */
  41274. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41275. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41276. /**
  41277. * Default behaviour for cors in the application.
  41278. * It can be a string if the expected behavior is identical in the entire app.
  41279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41280. */
  41281. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41282. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41283. /**
  41284. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41285. * @ignorenaming
  41286. */
  41287. static get UseFallbackTexture(): boolean;
  41288. static set UseFallbackTexture(value: boolean);
  41289. /**
  41290. * Use this object to register external classes like custom textures or material
  41291. * to allow the laoders to instantiate them
  41292. */
  41293. static get RegisteredExternalClasses(): {
  41294. [key: string]: Object;
  41295. };
  41296. static set RegisteredExternalClasses(classes: {
  41297. [key: string]: Object;
  41298. });
  41299. /**
  41300. * Texture content used if a texture cannot loaded
  41301. * @ignorenaming
  41302. */
  41303. static get fallbackTexture(): string;
  41304. static set fallbackTexture(value: string);
  41305. /**
  41306. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41307. * @param u defines the coordinate on X axis
  41308. * @param v defines the coordinate on Y axis
  41309. * @param width defines the width of the source data
  41310. * @param height defines the height of the source data
  41311. * @param pixels defines the source byte array
  41312. * @param color defines the output color
  41313. */
  41314. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41315. /**
  41316. * Interpolates between a and b via alpha
  41317. * @param a The lower value (returned when alpha = 0)
  41318. * @param b The upper value (returned when alpha = 1)
  41319. * @param alpha The interpolation-factor
  41320. * @return The mixed value
  41321. */
  41322. static Mix(a: number, b: number, alpha: number): number;
  41323. /**
  41324. * Tries to instantiate a new object from a given class name
  41325. * @param className defines the class name to instantiate
  41326. * @returns the new object or null if the system was not able to do the instantiation
  41327. */
  41328. static Instantiate(className: string): any;
  41329. /**
  41330. * Provides a slice function that will work even on IE
  41331. * @param data defines the array to slice
  41332. * @param start defines the start of the data (optional)
  41333. * @param end defines the end of the data (optional)
  41334. * @returns the new sliced array
  41335. */
  41336. static Slice<T>(data: T, start?: number, end?: number): T;
  41337. /**
  41338. * Polyfill for setImmediate
  41339. * @param action defines the action to execute after the current execution block
  41340. */
  41341. static SetImmediate(action: () => void): void;
  41342. /**
  41343. * Function indicating if a number is an exponent of 2
  41344. * @param value defines the value to test
  41345. * @returns true if the value is an exponent of 2
  41346. */
  41347. static IsExponentOfTwo(value: number): boolean;
  41348. private static _tmpFloatArray;
  41349. /**
  41350. * Returns the nearest 32-bit single precision float representation of a Number
  41351. * @param value A Number. If the parameter is of a different type, it will get converted
  41352. * to a number or to NaN if it cannot be converted
  41353. * @returns number
  41354. */
  41355. static FloatRound(value: number): number;
  41356. /**
  41357. * Extracts the filename from a path
  41358. * @param path defines the path to use
  41359. * @returns the filename
  41360. */
  41361. static GetFilename(path: string): string;
  41362. /**
  41363. * Extracts the "folder" part of a path (everything before the filename).
  41364. * @param uri The URI to extract the info from
  41365. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41366. * @returns The "folder" part of the path
  41367. */
  41368. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41369. /**
  41370. * Extracts text content from a DOM element hierarchy
  41371. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41372. */
  41373. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41374. /**
  41375. * Convert an angle in radians to degrees
  41376. * @param angle defines the angle to convert
  41377. * @returns the angle in degrees
  41378. */
  41379. static ToDegrees(angle: number): number;
  41380. /**
  41381. * Convert an angle in degrees to radians
  41382. * @param angle defines the angle to convert
  41383. * @returns the angle in radians
  41384. */
  41385. static ToRadians(angle: number): number;
  41386. /**
  41387. * Returns an array if obj is not an array
  41388. * @param obj defines the object to evaluate as an array
  41389. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41390. * @returns either obj directly if obj is an array or a new array containing obj
  41391. */
  41392. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41393. /**
  41394. * Gets the pointer prefix to use
  41395. * @param engine defines the engine we are finding the prefix for
  41396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41397. */
  41398. static GetPointerPrefix(engine: Engine): string;
  41399. /**
  41400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41401. * @param url define the url we are trying
  41402. * @param element define the dom element where to configure the cors policy
  41403. */
  41404. static SetCorsBehavior(url: string | string[], element: {
  41405. crossOrigin: string | null;
  41406. }): void;
  41407. /**
  41408. * Removes unwanted characters from an url
  41409. * @param url defines the url to clean
  41410. * @returns the cleaned url
  41411. */
  41412. static CleanUrl(url: string): string;
  41413. /**
  41414. * Gets or sets a function used to pre-process url before using them to load assets
  41415. */
  41416. static get PreprocessUrl(): (url: string) => string;
  41417. static set PreprocessUrl(processor: (url: string) => string);
  41418. /**
  41419. * Loads an image as an HTMLImageElement.
  41420. * @param input url string, ArrayBuffer, or Blob to load
  41421. * @param onLoad callback called when the image successfully loads
  41422. * @param onError callback called when the image fails to load
  41423. * @param offlineProvider offline provider for caching
  41424. * @param mimeType optional mime type
  41425. * @returns the HTMLImageElement of the loaded image
  41426. */
  41427. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41428. /**
  41429. * Loads a file from a url
  41430. * @param url url string, ArrayBuffer, or Blob to load
  41431. * @param onSuccess callback called when the file successfully loads
  41432. * @param onProgress callback called while file is loading (if the server supports this mode)
  41433. * @param offlineProvider defines the offline provider for caching
  41434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41435. * @param onError callback called when the file fails to load
  41436. * @returns a file request object
  41437. */
  41438. 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;
  41439. /**
  41440. * Loads a file from a url
  41441. * @param url the file url to load
  41442. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41443. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41444. */
  41445. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41446. /**
  41447. * Load a script (identified by an url). When the url returns, the
  41448. * content of this file is added into a new script element, attached to the DOM (body element)
  41449. * @param scriptUrl defines the url of the script to laod
  41450. * @param onSuccess defines the callback called when the script is loaded
  41451. * @param onError defines the callback to call if an error occurs
  41452. * @param scriptId defines the id of the script element
  41453. */
  41454. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41455. /**
  41456. * Load an asynchronous script (identified by an url). When the url returns, the
  41457. * content of this file is added into a new script element, attached to the DOM (body element)
  41458. * @param scriptUrl defines the url of the script to laod
  41459. * @param scriptId defines the id of the script element
  41460. * @returns a promise request object
  41461. */
  41462. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41463. /**
  41464. * Loads a file from a blob
  41465. * @param fileToLoad defines the blob to use
  41466. * @param callback defines the callback to call when data is loaded
  41467. * @param progressCallback defines the callback to call during loading process
  41468. * @returns a file request object
  41469. */
  41470. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41471. /**
  41472. * Reads a file from a File object
  41473. * @param file defines the file to load
  41474. * @param onSuccess defines the callback to call when data is loaded
  41475. * @param onProgress defines the callback to call during loading process
  41476. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41477. * @param onError defines the callback to call when an error occurs
  41478. * @returns a file request object
  41479. */
  41480. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41481. /**
  41482. * Creates a data url from a given string content
  41483. * @param content defines the content to convert
  41484. * @returns the new data url link
  41485. */
  41486. static FileAsURL(content: string): string;
  41487. /**
  41488. * Format the given number to a specific decimal format
  41489. * @param value defines the number to format
  41490. * @param decimals defines the number of decimals to use
  41491. * @returns the formatted string
  41492. */
  41493. static Format(value: number, decimals?: number): string;
  41494. /**
  41495. * Tries to copy an object by duplicating every property
  41496. * @param source defines the source object
  41497. * @param destination defines the target object
  41498. * @param doNotCopyList defines a list of properties to avoid
  41499. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41500. */
  41501. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41502. /**
  41503. * Gets a boolean indicating if the given object has no own property
  41504. * @param obj defines the object to test
  41505. * @returns true if object has no own property
  41506. */
  41507. static IsEmpty(obj: any): boolean;
  41508. /**
  41509. * Function used to register events at window level
  41510. * @param windowElement defines the Window object to use
  41511. * @param events defines the events to register
  41512. */
  41513. static RegisterTopRootEvents(windowElement: Window, events: {
  41514. name: string;
  41515. handler: Nullable<(e: FocusEvent) => any>;
  41516. }[]): void;
  41517. /**
  41518. * Function used to unregister events from window level
  41519. * @param windowElement defines the Window object to use
  41520. * @param events defines the events to unregister
  41521. */
  41522. static UnregisterTopRootEvents(windowElement: Window, events: {
  41523. name: string;
  41524. handler: Nullable<(e: FocusEvent) => any>;
  41525. }[]): void;
  41526. /**
  41527. * @ignore
  41528. */
  41529. static _ScreenshotCanvas: HTMLCanvasElement;
  41530. /**
  41531. * Dumps the current bound framebuffer
  41532. * @param width defines the rendering width
  41533. * @param height defines the rendering height
  41534. * @param engine defines the hosting engine
  41535. * @param successCallback defines the callback triggered once the data are available
  41536. * @param mimeType defines the mime type of the result
  41537. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41538. */
  41539. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41540. /**
  41541. * Converts the canvas data to blob.
  41542. * This acts as a polyfill for browsers not supporting the to blob function.
  41543. * @param canvas Defines the canvas to extract the data from
  41544. * @param successCallback Defines the callback triggered once the data are available
  41545. * @param mimeType Defines the mime type of the result
  41546. */
  41547. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41548. /**
  41549. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41550. * @param successCallback defines the callback triggered once the data are available
  41551. * @param mimeType defines the mime type of the result
  41552. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41553. */
  41554. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41555. /**
  41556. * Downloads a blob in the browser
  41557. * @param blob defines the blob to download
  41558. * @param fileName defines the name of the downloaded file
  41559. */
  41560. static Download(blob: Blob, fileName: string): void;
  41561. /**
  41562. * Captures a screenshot of the current rendering
  41563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41564. * @param engine defines the rendering engine
  41565. * @param camera defines the source camera
  41566. * @param size This parameter can be set to a single number or to an object with the
  41567. * following (optional) properties: precision, width, height. If a single number is passed,
  41568. * it will be used for both width and height. If an object is passed, the screenshot size
  41569. * will be derived from the parameters. The precision property is a multiplier allowing
  41570. * rendering at a higher or lower resolution
  41571. * @param successCallback defines the callback receives a single parameter which contains the
  41572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41573. * src parameter of an <img> to display it
  41574. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41575. * Check your browser for supported MIME types
  41576. */
  41577. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41578. /**
  41579. * Captures a screenshot of the current rendering
  41580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41581. * @param engine defines the rendering engine
  41582. * @param camera defines the source camera
  41583. * @param size This parameter can be set to a single number or to an object with the
  41584. * following (optional) properties: precision, width, height. If a single number is passed,
  41585. * it will be used for both width and height. If an object is passed, the screenshot size
  41586. * will be derived from the parameters. The precision property is a multiplier allowing
  41587. * rendering at a higher or lower resolution
  41588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41589. * Check your browser for supported MIME types
  41590. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41591. * to the src parameter of an <img> to display it
  41592. */
  41593. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41594. /**
  41595. * Generates an image screenshot from the specified camera.
  41596. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41597. * @param engine The engine to use for rendering
  41598. * @param camera The camera to use for rendering
  41599. * @param size This parameter can be set to a single number or to an object with the
  41600. * following (optional) properties: precision, width, height. If a single number is passed,
  41601. * it will be used for both width and height. If an object is passed, the screenshot size
  41602. * will be derived from the parameters. The precision property is a multiplier allowing
  41603. * rendering at a higher or lower resolution
  41604. * @param successCallback The callback receives a single parameter which contains the
  41605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41606. * src parameter of an <img> to display it
  41607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41608. * Check your browser for supported MIME types
  41609. * @param samples Texture samples (default: 1)
  41610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41611. * @param fileName A name for for the downloaded file.
  41612. */
  41613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41614. /**
  41615. * Generates an image screenshot from the specified camera.
  41616. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41617. * @param engine The engine to use for rendering
  41618. * @param camera The camera to use for rendering
  41619. * @param size This parameter can be set to a single number or to an object with the
  41620. * following (optional) properties: precision, width, height. If a single number is passed,
  41621. * it will be used for both width and height. If an object is passed, the screenshot size
  41622. * will be derived from the parameters. The precision property is a multiplier allowing
  41623. * rendering at a higher or lower resolution
  41624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41625. * Check your browser for supported MIME types
  41626. * @param samples Texture samples (default: 1)
  41627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41628. * @param fileName A name for for the downloaded file.
  41629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41630. * to the src parameter of an <img> to display it
  41631. */
  41632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41633. /**
  41634. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41635. * Be aware Math.random() could cause collisions, but:
  41636. * "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"
  41637. * @returns a pseudo random id
  41638. */
  41639. static RandomId(): string;
  41640. /**
  41641. * Test if the given uri is a base64 string
  41642. * @param uri The uri to test
  41643. * @return True if the uri is a base64 string or false otherwise
  41644. */
  41645. static IsBase64(uri: string): boolean;
  41646. /**
  41647. * Decode the given base64 uri.
  41648. * @param uri The uri to decode
  41649. * @return The decoded base64 data.
  41650. */
  41651. static DecodeBase64(uri: string): ArrayBuffer;
  41652. /**
  41653. * Gets the absolute url.
  41654. * @param url the input url
  41655. * @return the absolute url
  41656. */
  41657. static GetAbsoluteUrl(url: string): string;
  41658. /**
  41659. * No log
  41660. */
  41661. static readonly NoneLogLevel: number;
  41662. /**
  41663. * Only message logs
  41664. */
  41665. static readonly MessageLogLevel: number;
  41666. /**
  41667. * Only warning logs
  41668. */
  41669. static readonly WarningLogLevel: number;
  41670. /**
  41671. * Only error logs
  41672. */
  41673. static readonly ErrorLogLevel: number;
  41674. /**
  41675. * All logs
  41676. */
  41677. static readonly AllLogLevel: number;
  41678. /**
  41679. * Gets a value indicating the number of loading errors
  41680. * @ignorenaming
  41681. */
  41682. static get errorsCount(): number;
  41683. /**
  41684. * Callback called when a new log is added
  41685. */
  41686. static OnNewCacheEntry: (entry: string) => void;
  41687. /**
  41688. * Log a message to the console
  41689. * @param message defines the message to log
  41690. */
  41691. static Log(message: string): void;
  41692. /**
  41693. * Write a warning message to the console
  41694. * @param message defines the message to log
  41695. */
  41696. static Warn(message: string): void;
  41697. /**
  41698. * Write an error message to the console
  41699. * @param message defines the message to log
  41700. */
  41701. static Error(message: string): void;
  41702. /**
  41703. * Gets current log cache (list of logs)
  41704. */
  41705. static get LogCache(): string;
  41706. /**
  41707. * Clears the log cache
  41708. */
  41709. static ClearLogCache(): void;
  41710. /**
  41711. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41712. */
  41713. static set LogLevels(level: number);
  41714. /**
  41715. * Checks if the window object exists
  41716. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41717. */
  41718. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41719. /**
  41720. * No performance log
  41721. */
  41722. static readonly PerformanceNoneLogLevel: number;
  41723. /**
  41724. * Use user marks to log performance
  41725. */
  41726. static readonly PerformanceUserMarkLogLevel: number;
  41727. /**
  41728. * Log performance to the console
  41729. */
  41730. static readonly PerformanceConsoleLogLevel: number;
  41731. private static _performance;
  41732. /**
  41733. * Sets the current performance log level
  41734. */
  41735. static set PerformanceLogLevel(level: number);
  41736. private static _StartPerformanceCounterDisabled;
  41737. private static _EndPerformanceCounterDisabled;
  41738. private static _StartUserMark;
  41739. private static _EndUserMark;
  41740. private static _StartPerformanceConsole;
  41741. private static _EndPerformanceConsole;
  41742. /**
  41743. * Starts a performance counter
  41744. */
  41745. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41746. /**
  41747. * Ends a specific performance coutner
  41748. */
  41749. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41750. /**
  41751. * Gets either window.performance.now() if supported or Date.now() else
  41752. */
  41753. static get Now(): number;
  41754. /**
  41755. * This method will return the name of the class used to create the instance of the given object.
  41756. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41757. * @param object the object to get the class name from
  41758. * @param isType defines if the object is actually a type
  41759. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41760. */
  41761. static GetClassName(object: any, isType?: boolean): string;
  41762. /**
  41763. * Gets the first element of an array satisfying a given predicate
  41764. * @param array defines the array to browse
  41765. * @param predicate defines the predicate to use
  41766. * @returns null if not found or the element
  41767. */
  41768. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41769. /**
  41770. * This method will return the name of the full name of the class, including its owning module (if any).
  41771. * 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).
  41772. * @param object the object to get the class name from
  41773. * @param isType defines if the object is actually a type
  41774. * @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.
  41775. * @ignorenaming
  41776. */
  41777. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41778. /**
  41779. * Returns a promise that resolves after the given amount of time.
  41780. * @param delay Number of milliseconds to delay
  41781. * @returns Promise that resolves after the given amount of time
  41782. */
  41783. static DelayAsync(delay: number): Promise<void>;
  41784. /**
  41785. * Utility function to detect if the current user agent is Safari
  41786. * @returns whether or not the current user agent is safari
  41787. */
  41788. static IsSafari(): boolean;
  41789. }
  41790. /**
  41791. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41792. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41793. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41794. * @param name The name of the class, case should be preserved
  41795. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41796. */
  41797. export function className(name: string, module?: string): (target: Object) => void;
  41798. /**
  41799. * An implementation of a loop for asynchronous functions.
  41800. */
  41801. export class AsyncLoop {
  41802. /**
  41803. * Defines the number of iterations for the loop
  41804. */
  41805. iterations: number;
  41806. /**
  41807. * Defines the current index of the loop.
  41808. */
  41809. index: number;
  41810. private _done;
  41811. private _fn;
  41812. private _successCallback;
  41813. /**
  41814. * Constructor.
  41815. * @param iterations the number of iterations.
  41816. * @param func the function to run each iteration
  41817. * @param successCallback the callback that will be called upon succesful execution
  41818. * @param offset starting offset.
  41819. */
  41820. constructor(
  41821. /**
  41822. * Defines the number of iterations for the loop
  41823. */
  41824. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41825. /**
  41826. * Execute the next iteration. Must be called after the last iteration was finished.
  41827. */
  41828. executeNext(): void;
  41829. /**
  41830. * Break the loop and run the success callback.
  41831. */
  41832. breakLoop(): void;
  41833. /**
  41834. * Create and run an async loop.
  41835. * @param iterations the number of iterations.
  41836. * @param fn the function to run each iteration
  41837. * @param successCallback the callback that will be called upon succesful execution
  41838. * @param offset starting offset.
  41839. * @returns the created async loop object
  41840. */
  41841. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41842. /**
  41843. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41844. * @param iterations total number of iterations
  41845. * @param syncedIterations number of synchronous iterations in each async iteration.
  41846. * @param fn the function to call each iteration.
  41847. * @param callback a success call back that will be called when iterating stops.
  41848. * @param breakFunction a break condition (optional)
  41849. * @param timeout timeout settings for the setTimeout function. default - 0.
  41850. * @returns the created async loop object
  41851. */
  41852. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41858. * The underlying implementation relies on an associative array to ensure the best performances.
  41859. * The value can be anything including 'null' but except 'undefined'
  41860. */
  41861. export class StringDictionary<T> {
  41862. /**
  41863. * This will clear this dictionary and copy the content from the 'source' one.
  41864. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41865. * @param source the dictionary to take the content from and copy to this dictionary
  41866. */
  41867. copyFrom(source: StringDictionary<T>): void;
  41868. /**
  41869. * Get a value based from its key
  41870. * @param key the given key to get the matching value from
  41871. * @return the value if found, otherwise undefined is returned
  41872. */
  41873. get(key: string): T | undefined;
  41874. /**
  41875. * Get a value from its key or add it if it doesn't exist.
  41876. * This method will ensure you that a given key/data will be present in the dictionary.
  41877. * @param key the given key to get the matching value from
  41878. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41879. * The factory will only be invoked if there's no data for the given key.
  41880. * @return the value corresponding to the key.
  41881. */
  41882. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41883. /**
  41884. * Get a value from its key if present in the dictionary otherwise add it
  41885. * @param key the key to get the value from
  41886. * @param val if there's no such key/value pair in the dictionary add it with this value
  41887. * @return the value corresponding to the key
  41888. */
  41889. getOrAdd(key: string, val: T): T;
  41890. /**
  41891. * Check if there's a given key in the dictionary
  41892. * @param key the key to check for
  41893. * @return true if the key is present, false otherwise
  41894. */
  41895. contains(key: string): boolean;
  41896. /**
  41897. * Add a new key and its corresponding value
  41898. * @param key the key to add
  41899. * @param value the value corresponding to the key
  41900. * @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
  41901. */
  41902. add(key: string, value: T): boolean;
  41903. /**
  41904. * Update a specific value associated to a key
  41905. * @param key defines the key to use
  41906. * @param value defines the value to store
  41907. * @returns true if the value was updated (or false if the key was not found)
  41908. */
  41909. set(key: string, value: T): boolean;
  41910. /**
  41911. * Get the element of the given key and remove it from the dictionary
  41912. * @param key defines the key to search
  41913. * @returns the value associated with the key or null if not found
  41914. */
  41915. getAndRemove(key: string): Nullable<T>;
  41916. /**
  41917. * Remove a key/value from the dictionary.
  41918. * @param key the key to remove
  41919. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41920. */
  41921. remove(key: string): boolean;
  41922. /**
  41923. * Clear the whole content of the dictionary
  41924. */
  41925. clear(): void;
  41926. /**
  41927. * Gets the current count
  41928. */
  41929. get count(): number;
  41930. /**
  41931. * Execute a callback on each key/val of the dictionary.
  41932. * Note that you can remove any element in this dictionary in the callback implementation
  41933. * @param callback the callback to execute on a given key/value pair
  41934. */
  41935. forEach(callback: (key: string, val: T) => void): void;
  41936. /**
  41937. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41938. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41939. * Note that you can remove any element in this dictionary in the callback implementation
  41940. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41941. * @returns the first item
  41942. */
  41943. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41944. private _count;
  41945. private _data;
  41946. }
  41947. }
  41948. declare module BABYLON {
  41949. /** @hidden */
  41950. export interface ICollisionCoordinator {
  41951. createCollider(): Collider;
  41952. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41953. init(scene: Scene): void;
  41954. }
  41955. /** @hidden */
  41956. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41957. private _scene;
  41958. private _scaledPosition;
  41959. private _scaledVelocity;
  41960. private _finalPosition;
  41961. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41962. createCollider(): Collider;
  41963. init(scene: Scene): void;
  41964. private _collideWithWorld;
  41965. }
  41966. }
  41967. declare module BABYLON {
  41968. /**
  41969. * Class used to manage all inputs for the scene.
  41970. */
  41971. export class InputManager {
  41972. /** The distance in pixel that you have to move to prevent some events */
  41973. static DragMovementThreshold: number;
  41974. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41975. static LongPressDelay: number;
  41976. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41977. static DoubleClickDelay: number;
  41978. /** If you need to check double click without raising a single click at first click, enable this flag */
  41979. static ExclusiveDoubleClickMode: boolean;
  41980. /** 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. */
  41981. private _alreadyAttached;
  41982. private _wheelEventName;
  41983. private _onPointerMove;
  41984. private _onPointerDown;
  41985. private _onPointerUp;
  41986. private _initClickEvent;
  41987. private _initActionManager;
  41988. private _delayedSimpleClick;
  41989. private _delayedSimpleClickTimeout;
  41990. private _previousDelayedSimpleClickTimeout;
  41991. private _meshPickProceed;
  41992. private _previousButtonPressed;
  41993. private _currentPickResult;
  41994. private _previousPickResult;
  41995. private _totalPointersPressed;
  41996. private _doubleClickOccured;
  41997. private _pointerOverMesh;
  41998. private _pickedDownMesh;
  41999. private _pickedUpMesh;
  42000. private _pointerX;
  42001. private _pointerY;
  42002. private _unTranslatedPointerX;
  42003. private _unTranslatedPointerY;
  42004. private _startingPointerPosition;
  42005. private _previousStartingPointerPosition;
  42006. private _startingPointerTime;
  42007. private _previousStartingPointerTime;
  42008. private _pointerCaptures;
  42009. private _meshUnderPointerId;
  42010. private _onKeyDown;
  42011. private _onKeyUp;
  42012. private _onCanvasFocusObserver;
  42013. private _onCanvasBlurObserver;
  42014. private _scene;
  42015. /**
  42016. * Creates a new InputManager
  42017. * @param scene defines the hosting scene
  42018. */
  42019. constructor(scene: Scene);
  42020. /**
  42021. * Gets the mesh that is currently under the pointer
  42022. */
  42023. get meshUnderPointer(): Nullable<AbstractMesh>;
  42024. /**
  42025. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42026. * @param pointerId the pointer id to use
  42027. * @returns The mesh under this pointer id or null if not found
  42028. */
  42029. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42030. /**
  42031. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42032. */
  42033. get unTranslatedPointer(): Vector2;
  42034. /**
  42035. * Gets or sets the current on-screen X position of the pointer
  42036. */
  42037. get pointerX(): number;
  42038. set pointerX(value: number);
  42039. /**
  42040. * Gets or sets the current on-screen Y position of the pointer
  42041. */
  42042. get pointerY(): number;
  42043. set pointerY(value: number);
  42044. private _updatePointerPosition;
  42045. private _processPointerMove;
  42046. private _setRayOnPointerInfo;
  42047. private _checkPrePointerObservable;
  42048. /**
  42049. * Use this method to simulate a pointer move on a mesh
  42050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42053. */
  42054. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42055. /**
  42056. * Use this method to simulate a pointer down on a mesh
  42057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42060. */
  42061. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42062. private _processPointerDown;
  42063. /** @hidden */
  42064. _isPointerSwiping(): boolean;
  42065. /**
  42066. * Use this method to simulate a pointer up on a mesh
  42067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42070. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42071. */
  42072. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42073. private _processPointerUp;
  42074. /**
  42075. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42076. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42077. * @returns true if the pointer was captured
  42078. */
  42079. isPointerCaptured(pointerId?: number): boolean;
  42080. /**
  42081. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42082. * @param attachUp defines if you want to attach events to pointerup
  42083. * @param attachDown defines if you want to attach events to pointerdown
  42084. * @param attachMove defines if you want to attach events to pointermove
  42085. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42086. */
  42087. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42088. /**
  42089. * Detaches all event handlers
  42090. */
  42091. detachControl(): void;
  42092. /**
  42093. * Force the value of meshUnderPointer
  42094. * @param mesh defines the mesh to use
  42095. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42096. */
  42097. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42098. /**
  42099. * Gets the mesh under the pointer
  42100. * @returns a Mesh or null if no mesh is under the pointer
  42101. */
  42102. getPointerOverMesh(): Nullable<AbstractMesh>;
  42103. }
  42104. }
  42105. declare module BABYLON {
  42106. /**
  42107. * This class defines the direct association between an animation and a target
  42108. */
  42109. export class TargetedAnimation {
  42110. /**
  42111. * Animation to perform
  42112. */
  42113. animation: Animation;
  42114. /**
  42115. * Target to animate
  42116. */
  42117. target: any;
  42118. /**
  42119. * Returns the string "TargetedAnimation"
  42120. * @returns "TargetedAnimation"
  42121. */
  42122. getClassName(): string;
  42123. /**
  42124. * Serialize the object
  42125. * @returns the JSON object representing the current entity
  42126. */
  42127. serialize(): any;
  42128. }
  42129. /**
  42130. * Use this class to create coordinated animations on multiple targets
  42131. */
  42132. export class AnimationGroup implements IDisposable {
  42133. /** The name of the animation group */
  42134. name: string;
  42135. private _scene;
  42136. private _targetedAnimations;
  42137. private _animatables;
  42138. private _from;
  42139. private _to;
  42140. private _isStarted;
  42141. private _isPaused;
  42142. private _speedRatio;
  42143. private _loopAnimation;
  42144. private _isAdditive;
  42145. /**
  42146. * Gets or sets the unique id of the node
  42147. */
  42148. uniqueId: number;
  42149. /**
  42150. * This observable will notify when one animation have ended
  42151. */
  42152. onAnimationEndObservable: Observable<TargetedAnimation>;
  42153. /**
  42154. * Observer raised when one animation loops
  42155. */
  42156. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42157. /**
  42158. * Observer raised when all animations have looped
  42159. */
  42160. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42161. /**
  42162. * This observable will notify when all animations have ended.
  42163. */
  42164. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42165. /**
  42166. * This observable will notify when all animations have paused.
  42167. */
  42168. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42169. /**
  42170. * This observable will notify when all animations are playing.
  42171. */
  42172. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42173. /**
  42174. * Gets the first frame
  42175. */
  42176. get from(): number;
  42177. /**
  42178. * Gets the last frame
  42179. */
  42180. get to(): number;
  42181. /**
  42182. * Define if the animations are started
  42183. */
  42184. get isStarted(): boolean;
  42185. /**
  42186. * Gets a value indicating that the current group is playing
  42187. */
  42188. get isPlaying(): boolean;
  42189. /**
  42190. * Gets or sets the speed ratio to use for all animations
  42191. */
  42192. get speedRatio(): number;
  42193. /**
  42194. * Gets or sets the speed ratio to use for all animations
  42195. */
  42196. set speedRatio(value: number);
  42197. /**
  42198. * Gets or sets if all animations should loop or not
  42199. */
  42200. get loopAnimation(): boolean;
  42201. set loopAnimation(value: boolean);
  42202. /**
  42203. * Gets or sets if all animations should be evaluated additively
  42204. */
  42205. get isAdditive(): boolean;
  42206. set isAdditive(value: boolean);
  42207. /**
  42208. * Gets the targeted animations for this animation group
  42209. */
  42210. get targetedAnimations(): Array<TargetedAnimation>;
  42211. /**
  42212. * returning the list of animatables controlled by this animation group.
  42213. */
  42214. get animatables(): Array<Animatable>;
  42215. /**
  42216. * Gets the list of target animations
  42217. */
  42218. get children(): TargetedAnimation[];
  42219. /**
  42220. * Instantiates a new Animation Group.
  42221. * This helps managing several animations at once.
  42222. * @see https://doc.babylonjs.com/how_to/group
  42223. * @param name Defines the name of the group
  42224. * @param scene Defines the scene the group belongs to
  42225. */
  42226. constructor(
  42227. /** The name of the animation group */
  42228. name: string, scene?: Nullable<Scene>);
  42229. /**
  42230. * Add an animation (with its target) in the group
  42231. * @param animation defines the animation we want to add
  42232. * @param target defines the target of the animation
  42233. * @returns the TargetedAnimation object
  42234. */
  42235. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42236. /**
  42237. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42238. * It can add constant keys at begin or end
  42239. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42240. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42241. * @returns the animation group
  42242. */
  42243. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42244. private _animationLoopCount;
  42245. private _animationLoopFlags;
  42246. private _processLoop;
  42247. /**
  42248. * Start all animations on given targets
  42249. * @param loop defines if animations must loop
  42250. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42251. * @param from defines the from key (optional)
  42252. * @param to defines the to key (optional)
  42253. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42254. * @returns the current animation group
  42255. */
  42256. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42257. /**
  42258. * Pause all animations
  42259. * @returns the animation group
  42260. */
  42261. pause(): AnimationGroup;
  42262. /**
  42263. * Play all animations to initial state
  42264. * This function will start() the animations if they were not started or will restart() them if they were paused
  42265. * @param loop defines if animations must loop
  42266. * @returns the animation group
  42267. */
  42268. play(loop?: boolean): AnimationGroup;
  42269. /**
  42270. * Reset all animations to initial state
  42271. * @returns the animation group
  42272. */
  42273. reset(): AnimationGroup;
  42274. /**
  42275. * Restart animations from key 0
  42276. * @returns the animation group
  42277. */
  42278. restart(): AnimationGroup;
  42279. /**
  42280. * Stop all animations
  42281. * @returns the animation group
  42282. */
  42283. stop(): AnimationGroup;
  42284. /**
  42285. * Set animation weight for all animatables
  42286. * @param weight defines the weight to use
  42287. * @return the animationGroup
  42288. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42289. */
  42290. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42291. /**
  42292. * Synchronize and normalize all animatables with a source animatable
  42293. * @param root defines the root animatable to synchronize with
  42294. * @return the animationGroup
  42295. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42296. */
  42297. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42298. /**
  42299. * Goes to a specific frame in this animation group
  42300. * @param frame the frame number to go to
  42301. * @return the animationGroup
  42302. */
  42303. goToFrame(frame: number): AnimationGroup;
  42304. /**
  42305. * Dispose all associated resources
  42306. */
  42307. dispose(): void;
  42308. private _checkAnimationGroupEnded;
  42309. /**
  42310. * Clone the current animation group and returns a copy
  42311. * @param newName defines the name of the new group
  42312. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42313. * @returns the new aniamtion group
  42314. */
  42315. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42316. /**
  42317. * Serializes the animationGroup to an object
  42318. * @returns Serialized object
  42319. */
  42320. serialize(): any;
  42321. /**
  42322. * Returns a new AnimationGroup object parsed from the source provided.
  42323. * @param parsedAnimationGroup defines the source
  42324. * @param scene defines the scene that will receive the animationGroup
  42325. * @returns a new AnimationGroup
  42326. */
  42327. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42328. /**
  42329. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42330. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42331. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42332. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42333. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42334. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42335. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42336. */
  42337. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42338. /**
  42339. * Returns the string "AnimationGroup"
  42340. * @returns "AnimationGroup"
  42341. */
  42342. getClassName(): string;
  42343. /**
  42344. * Creates a detailled string about the object
  42345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42346. * @returns a string representing the object
  42347. */
  42348. toString(fullDetails?: boolean): string;
  42349. }
  42350. }
  42351. declare module BABYLON {
  42352. /**
  42353. * Define an interface for all classes that will hold resources
  42354. */
  42355. export interface IDisposable {
  42356. /**
  42357. * Releases all held resources
  42358. */
  42359. dispose(): void;
  42360. }
  42361. /** Interface defining initialization parameters for Scene class */
  42362. export interface SceneOptions {
  42363. /**
  42364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42365. * It will improve performance when the number of geometries becomes important.
  42366. */
  42367. useGeometryUniqueIdsMap?: boolean;
  42368. /**
  42369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42371. */
  42372. useMaterialMeshMap?: boolean;
  42373. /**
  42374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42376. */
  42377. useClonedMeshMap?: boolean;
  42378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42379. virtual?: boolean;
  42380. }
  42381. /**
  42382. * Represents a scene to be rendered by the engine.
  42383. * @see https://doc.babylonjs.com/features/scene
  42384. */
  42385. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42386. /** The fog is deactivated */
  42387. static readonly FOGMODE_NONE: number;
  42388. /** The fog density is following an exponential function */
  42389. static readonly FOGMODE_EXP: number;
  42390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42391. static readonly FOGMODE_EXP2: number;
  42392. /** The fog density is following a linear function. */
  42393. static readonly FOGMODE_LINEAR: number;
  42394. /**
  42395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42397. */
  42398. static MinDeltaTime: number;
  42399. /**
  42400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42401. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42402. */
  42403. static MaxDeltaTime: number;
  42404. /**
  42405. * Factory used to create the default material.
  42406. * @param name The name of the material to create
  42407. * @param scene The scene to create the material for
  42408. * @returns The default material
  42409. */
  42410. static DefaultMaterialFactory(scene: Scene): Material;
  42411. /**
  42412. * Factory used to create the a collision coordinator.
  42413. * @returns The collision coordinator
  42414. */
  42415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42416. /** @hidden */
  42417. _inputManager: InputManager;
  42418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42419. cameraToUseForPointers: Nullable<Camera>;
  42420. /** @hidden */
  42421. readonly _isScene: boolean;
  42422. /** @hidden */
  42423. _blockEntityCollection: boolean;
  42424. /**
  42425. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42426. */
  42427. autoClear: boolean;
  42428. /**
  42429. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42430. */
  42431. autoClearDepthAndStencil: boolean;
  42432. /**
  42433. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42434. */
  42435. clearColor: Color4;
  42436. /**
  42437. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42438. */
  42439. ambientColor: Color3;
  42440. /**
  42441. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42442. * It should only be one of the following (if not the default embedded one):
  42443. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42444. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42445. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42446. * The material properties need to be setup according to the type of texture in use.
  42447. */
  42448. environmentBRDFTexture: BaseTexture;
  42449. /**
  42450. * Texture used in all pbr material as the reflection texture.
  42451. * As in the majority of the scene they are the same (exception for multi room and so on),
  42452. * this is easier to reference from here than from all the materials.
  42453. */
  42454. get environmentTexture(): Nullable<BaseTexture>;
  42455. /**
  42456. * Texture used in all pbr material as the reflection texture.
  42457. * As in the majority of the scene they are the same (exception for multi room and so on),
  42458. * this is easier to set here than in all the materials.
  42459. */
  42460. set environmentTexture(value: Nullable<BaseTexture>);
  42461. /** @hidden */
  42462. protected _environmentIntensity: number;
  42463. /**
  42464. * Intensity of the environment in all pbr material.
  42465. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42466. * As in the majority of the scene they are the same (exception for multi room and so on),
  42467. * this is easier to reference from here than from all the materials.
  42468. */
  42469. get environmentIntensity(): number;
  42470. /**
  42471. * Intensity of the environment in all pbr material.
  42472. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42473. * As in the majority of the scene they are the same (exception for multi room and so on),
  42474. * this is easier to set here than in all the materials.
  42475. */
  42476. set environmentIntensity(value: number);
  42477. /** @hidden */
  42478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42479. /**
  42480. * Default image processing configuration used either in the rendering
  42481. * Forward main pass or through the imageProcessingPostProcess if present.
  42482. * As in the majority of the scene they are the same (exception for multi camera),
  42483. * this is easier to reference from here than from all the materials and post process.
  42484. *
  42485. * No setter as we it is a shared configuration, you can set the values instead.
  42486. */
  42487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42488. private _forceWireframe;
  42489. /**
  42490. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42491. */
  42492. set forceWireframe(value: boolean);
  42493. get forceWireframe(): boolean;
  42494. private _skipFrustumClipping;
  42495. /**
  42496. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42497. */
  42498. set skipFrustumClipping(value: boolean);
  42499. get skipFrustumClipping(): boolean;
  42500. private _forcePointsCloud;
  42501. /**
  42502. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42503. */
  42504. set forcePointsCloud(value: boolean);
  42505. get forcePointsCloud(): boolean;
  42506. /**
  42507. * Gets or sets the active clipplane 1
  42508. */
  42509. clipPlane: Nullable<Plane>;
  42510. /**
  42511. * Gets or sets the active clipplane 2
  42512. */
  42513. clipPlane2: Nullable<Plane>;
  42514. /**
  42515. * Gets or sets the active clipplane 3
  42516. */
  42517. clipPlane3: Nullable<Plane>;
  42518. /**
  42519. * Gets or sets the active clipplane 4
  42520. */
  42521. clipPlane4: Nullable<Plane>;
  42522. /**
  42523. * Gets or sets the active clipplane 5
  42524. */
  42525. clipPlane5: Nullable<Plane>;
  42526. /**
  42527. * Gets or sets the active clipplane 6
  42528. */
  42529. clipPlane6: Nullable<Plane>;
  42530. /**
  42531. * Gets or sets a boolean indicating if animations are enabled
  42532. */
  42533. animationsEnabled: boolean;
  42534. private _animationPropertiesOverride;
  42535. /**
  42536. * Gets or sets the animation properties override
  42537. */
  42538. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42539. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42540. /**
  42541. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42542. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42543. */
  42544. useConstantAnimationDeltaTime: boolean;
  42545. /**
  42546. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42547. * Please note that it requires to run a ray cast through the scene on every frame
  42548. */
  42549. constantlyUpdateMeshUnderPointer: boolean;
  42550. /**
  42551. * Defines the HTML cursor to use when hovering over interactive elements
  42552. */
  42553. hoverCursor: string;
  42554. /**
  42555. * Defines the HTML default cursor to use (empty by default)
  42556. */
  42557. defaultCursor: string;
  42558. /**
  42559. * Defines whether cursors are handled by the scene.
  42560. */
  42561. doNotHandleCursors: boolean;
  42562. /**
  42563. * This is used to call preventDefault() on pointer down
  42564. * in order to block unwanted artifacts like system double clicks
  42565. */
  42566. preventDefaultOnPointerDown: boolean;
  42567. /**
  42568. * This is used to call preventDefault() on pointer up
  42569. * in order to block unwanted artifacts like system double clicks
  42570. */
  42571. preventDefaultOnPointerUp: boolean;
  42572. /**
  42573. * Gets or sets user defined metadata
  42574. */
  42575. metadata: any;
  42576. /**
  42577. * For internal use only. Please do not use.
  42578. */
  42579. reservedDataStore: any;
  42580. /**
  42581. * Gets the name of the plugin used to load this scene (null by default)
  42582. */
  42583. loadingPluginName: string;
  42584. /**
  42585. * Use this array to add regular expressions used to disable offline support for specific urls
  42586. */
  42587. disableOfflineSupportExceptionRules: RegExp[];
  42588. /**
  42589. * An event triggered when the scene is disposed.
  42590. */
  42591. onDisposeObservable: Observable<Scene>;
  42592. private _onDisposeObserver;
  42593. /** Sets a function to be executed when this scene is disposed. */
  42594. set onDispose(callback: () => void);
  42595. /**
  42596. * An event triggered before rendering the scene (right after animations and physics)
  42597. */
  42598. onBeforeRenderObservable: Observable<Scene>;
  42599. private _onBeforeRenderObserver;
  42600. /** Sets a function to be executed before rendering this scene */
  42601. set beforeRender(callback: Nullable<() => void>);
  42602. /**
  42603. * An event triggered after rendering the scene
  42604. */
  42605. onAfterRenderObservable: Observable<Scene>;
  42606. /**
  42607. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42608. */
  42609. onAfterRenderCameraObservable: Observable<Camera>;
  42610. private _onAfterRenderObserver;
  42611. /** Sets a function to be executed after rendering this scene */
  42612. set afterRender(callback: Nullable<() => void>);
  42613. /**
  42614. * An event triggered before animating the scene
  42615. */
  42616. onBeforeAnimationsObservable: Observable<Scene>;
  42617. /**
  42618. * An event triggered after animations processing
  42619. */
  42620. onAfterAnimationsObservable: Observable<Scene>;
  42621. /**
  42622. * An event triggered before draw calls are ready to be sent
  42623. */
  42624. onBeforeDrawPhaseObservable: Observable<Scene>;
  42625. /**
  42626. * An event triggered after draw calls have been sent
  42627. */
  42628. onAfterDrawPhaseObservable: Observable<Scene>;
  42629. /**
  42630. * An event triggered when the scene is ready
  42631. */
  42632. onReadyObservable: Observable<Scene>;
  42633. /**
  42634. * An event triggered before rendering a camera
  42635. */
  42636. onBeforeCameraRenderObservable: Observable<Camera>;
  42637. private _onBeforeCameraRenderObserver;
  42638. /** Sets a function to be executed before rendering a camera*/
  42639. set beforeCameraRender(callback: () => void);
  42640. /**
  42641. * An event triggered after rendering a camera
  42642. */
  42643. onAfterCameraRenderObservable: Observable<Camera>;
  42644. private _onAfterCameraRenderObserver;
  42645. /** Sets a function to be executed after rendering a camera*/
  42646. set afterCameraRender(callback: () => void);
  42647. /**
  42648. * An event triggered when active meshes evaluation is about to start
  42649. */
  42650. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42651. /**
  42652. * An event triggered when active meshes evaluation is done
  42653. */
  42654. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42655. /**
  42656. * An event triggered when particles rendering is about to start
  42657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42658. */
  42659. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42660. /**
  42661. * An event triggered when particles rendering is done
  42662. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42663. */
  42664. onAfterParticlesRenderingObservable: Observable<Scene>;
  42665. /**
  42666. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42667. */
  42668. onDataLoadedObservable: Observable<Scene>;
  42669. /**
  42670. * An event triggered when a camera is created
  42671. */
  42672. onNewCameraAddedObservable: Observable<Camera>;
  42673. /**
  42674. * An event triggered when a camera is removed
  42675. */
  42676. onCameraRemovedObservable: Observable<Camera>;
  42677. /**
  42678. * An event triggered when a light is created
  42679. */
  42680. onNewLightAddedObservable: Observable<Light>;
  42681. /**
  42682. * An event triggered when a light is removed
  42683. */
  42684. onLightRemovedObservable: Observable<Light>;
  42685. /**
  42686. * An event triggered when a geometry is created
  42687. */
  42688. onNewGeometryAddedObservable: Observable<Geometry>;
  42689. /**
  42690. * An event triggered when a geometry is removed
  42691. */
  42692. onGeometryRemovedObservable: Observable<Geometry>;
  42693. /**
  42694. * An event triggered when a transform node is created
  42695. */
  42696. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42697. /**
  42698. * An event triggered when a transform node is removed
  42699. */
  42700. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42701. /**
  42702. * An event triggered when a mesh is created
  42703. */
  42704. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42705. /**
  42706. * An event triggered when a mesh is removed
  42707. */
  42708. onMeshRemovedObservable: Observable<AbstractMesh>;
  42709. /**
  42710. * An event triggered when a skeleton is created
  42711. */
  42712. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42713. /**
  42714. * An event triggered when a skeleton is removed
  42715. */
  42716. onSkeletonRemovedObservable: Observable<Skeleton>;
  42717. /**
  42718. * An event triggered when a material is created
  42719. */
  42720. onNewMaterialAddedObservable: Observable<Material>;
  42721. /**
  42722. * An event triggered when a material is removed
  42723. */
  42724. onMaterialRemovedObservable: Observable<Material>;
  42725. /**
  42726. * An event triggered when a texture is created
  42727. */
  42728. onNewTextureAddedObservable: Observable<BaseTexture>;
  42729. /**
  42730. * An event triggered when a texture is removed
  42731. */
  42732. onTextureRemovedObservable: Observable<BaseTexture>;
  42733. /**
  42734. * An event triggered when render targets are about to be rendered
  42735. * Can happen multiple times per frame.
  42736. */
  42737. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42738. /**
  42739. * An event triggered when render targets were rendered.
  42740. * Can happen multiple times per frame.
  42741. */
  42742. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42743. /**
  42744. * An event triggered before calculating deterministic simulation step
  42745. */
  42746. onBeforeStepObservable: Observable<Scene>;
  42747. /**
  42748. * An event triggered after calculating deterministic simulation step
  42749. */
  42750. onAfterStepObservable: Observable<Scene>;
  42751. /**
  42752. * An event triggered when the activeCamera property is updated
  42753. */
  42754. onActiveCameraChanged: Observable<Scene>;
  42755. /**
  42756. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42757. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42758. * 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)
  42759. */
  42760. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42761. /**
  42762. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42763. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42764. * 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)
  42765. */
  42766. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42767. /**
  42768. * This Observable will when a mesh has been imported into the scene.
  42769. */
  42770. onMeshImportedObservable: Observable<AbstractMesh>;
  42771. /**
  42772. * This Observable will when an animation file has been imported into the scene.
  42773. */
  42774. onAnimationFileImportedObservable: Observable<Scene>;
  42775. /**
  42776. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42777. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42778. */
  42779. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42780. /** @hidden */
  42781. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42782. /**
  42783. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42784. */
  42785. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42786. /**
  42787. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42788. */
  42789. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42790. /**
  42791. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42792. */
  42793. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42794. /** Callback called when a pointer move is detected */
  42795. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42796. /** Callback called when a pointer down is detected */
  42797. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42798. /** Callback called when a pointer up is detected */
  42799. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42800. /** Callback called when a pointer pick is detected */
  42801. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42802. /**
  42803. * 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).
  42804. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42805. */
  42806. onPrePointerObservable: Observable<PointerInfoPre>;
  42807. /**
  42808. * Observable event triggered each time an input event is received from the rendering canvas
  42809. */
  42810. onPointerObservable: Observable<PointerInfo>;
  42811. /**
  42812. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42813. */
  42814. get unTranslatedPointer(): Vector2;
  42815. /**
  42816. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42817. */
  42818. static get DragMovementThreshold(): number;
  42819. static set DragMovementThreshold(value: number);
  42820. /**
  42821. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42822. */
  42823. static get LongPressDelay(): number;
  42824. static set LongPressDelay(value: number);
  42825. /**
  42826. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42827. */
  42828. static get DoubleClickDelay(): number;
  42829. static set DoubleClickDelay(value: number);
  42830. /** If you need to check double click without raising a single click at first click, enable this flag */
  42831. static get ExclusiveDoubleClickMode(): boolean;
  42832. static set ExclusiveDoubleClickMode(value: boolean);
  42833. /** @hidden */
  42834. _mirroredCameraPosition: Nullable<Vector3>;
  42835. /**
  42836. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42837. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42838. */
  42839. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42840. /**
  42841. * Observable event triggered each time an keyboard event is received from the hosting window
  42842. */
  42843. onKeyboardObservable: Observable<KeyboardInfo>;
  42844. private _useRightHandedSystem;
  42845. /**
  42846. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42847. */
  42848. set useRightHandedSystem(value: boolean);
  42849. get useRightHandedSystem(): boolean;
  42850. private _timeAccumulator;
  42851. private _currentStepId;
  42852. private _currentInternalStep;
  42853. /**
  42854. * Sets the step Id used by deterministic lock step
  42855. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42856. * @param newStepId defines the step Id
  42857. */
  42858. setStepId(newStepId: number): void;
  42859. /**
  42860. * Gets the step Id used by deterministic lock step
  42861. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42862. * @returns the step Id
  42863. */
  42864. getStepId(): number;
  42865. /**
  42866. * Gets the internal step used by deterministic lock step
  42867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42868. * @returns the internal step
  42869. */
  42870. getInternalStep(): number;
  42871. private _fogEnabled;
  42872. /**
  42873. * Gets or sets a boolean indicating if fog is enabled on this scene
  42874. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42875. * (Default is true)
  42876. */
  42877. set fogEnabled(value: boolean);
  42878. get fogEnabled(): boolean;
  42879. private _fogMode;
  42880. /**
  42881. * Gets or sets the fog mode to use
  42882. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42883. * | mode | value |
  42884. * | --- | --- |
  42885. * | FOGMODE_NONE | 0 |
  42886. * | FOGMODE_EXP | 1 |
  42887. * | FOGMODE_EXP2 | 2 |
  42888. * | FOGMODE_LINEAR | 3 |
  42889. */
  42890. set fogMode(value: number);
  42891. get fogMode(): number;
  42892. /**
  42893. * Gets or sets the fog color to use
  42894. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42895. * (Default is Color3(0.2, 0.2, 0.3))
  42896. */
  42897. fogColor: Color3;
  42898. /**
  42899. * Gets or sets the fog density to use
  42900. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42901. * (Default is 0.1)
  42902. */
  42903. fogDensity: number;
  42904. /**
  42905. * Gets or sets the fog start distance to use
  42906. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42907. * (Default is 0)
  42908. */
  42909. fogStart: number;
  42910. /**
  42911. * Gets or sets the fog end distance to use
  42912. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42913. * (Default is 1000)
  42914. */
  42915. fogEnd: number;
  42916. /**
  42917. * Flag indicating that the frame buffer binding is handled by another component
  42918. */
  42919. prePass: boolean;
  42920. private _shadowsEnabled;
  42921. /**
  42922. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42923. */
  42924. set shadowsEnabled(value: boolean);
  42925. get shadowsEnabled(): boolean;
  42926. private _lightsEnabled;
  42927. /**
  42928. * Gets or sets a boolean indicating if lights are enabled on this scene
  42929. */
  42930. set lightsEnabled(value: boolean);
  42931. get lightsEnabled(): boolean;
  42932. /** All of the active cameras added to this scene. */
  42933. activeCameras: Camera[];
  42934. /** @hidden */
  42935. _activeCamera: Nullable<Camera>;
  42936. /** Gets or sets the current active camera */
  42937. get activeCamera(): Nullable<Camera>;
  42938. set activeCamera(value: Nullable<Camera>);
  42939. private _defaultMaterial;
  42940. /** The default material used on meshes when no material is affected */
  42941. get defaultMaterial(): Material;
  42942. /** The default material used on meshes when no material is affected */
  42943. set defaultMaterial(value: Material);
  42944. private _texturesEnabled;
  42945. /**
  42946. * Gets or sets a boolean indicating if textures are enabled on this scene
  42947. */
  42948. set texturesEnabled(value: boolean);
  42949. get texturesEnabled(): boolean;
  42950. /**
  42951. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42952. */
  42953. physicsEnabled: boolean;
  42954. /**
  42955. * Gets or sets a boolean indicating if particles are enabled on this scene
  42956. */
  42957. particlesEnabled: boolean;
  42958. /**
  42959. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42960. */
  42961. spritesEnabled: boolean;
  42962. private _skeletonsEnabled;
  42963. /**
  42964. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42965. */
  42966. set skeletonsEnabled(value: boolean);
  42967. get skeletonsEnabled(): boolean;
  42968. /**
  42969. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42970. */
  42971. lensFlaresEnabled: boolean;
  42972. /**
  42973. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42974. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42975. */
  42976. collisionsEnabled: boolean;
  42977. private _collisionCoordinator;
  42978. /** @hidden */
  42979. get collisionCoordinator(): ICollisionCoordinator;
  42980. /**
  42981. * Defines the gravity applied to this scene (used only for collisions)
  42982. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42983. */
  42984. gravity: Vector3;
  42985. /**
  42986. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42987. */
  42988. postProcessesEnabled: boolean;
  42989. /**
  42990. * Gets the current postprocess manager
  42991. */
  42992. postProcessManager: PostProcessManager;
  42993. /**
  42994. * Gets or sets a boolean indicating if render targets are enabled on this scene
  42995. */
  42996. renderTargetsEnabled: boolean;
  42997. /**
  42998. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  42999. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43000. */
  43001. dumpNextRenderTargets: boolean;
  43002. /**
  43003. * The list of user defined render targets added to the scene
  43004. */
  43005. customRenderTargets: RenderTargetTexture[];
  43006. /**
  43007. * Defines if texture loading must be delayed
  43008. * If true, textures will only be loaded when they need to be rendered
  43009. */
  43010. useDelayedTextureLoading: boolean;
  43011. /**
  43012. * Gets the list of meshes imported to the scene through SceneLoader
  43013. */
  43014. importedMeshesFiles: String[];
  43015. /**
  43016. * Gets or sets a boolean indicating if probes are enabled on this scene
  43017. */
  43018. probesEnabled: boolean;
  43019. /**
  43020. * Gets or sets the current offline provider to use to store scene data
  43021. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43022. */
  43023. offlineProvider: IOfflineProvider;
  43024. /**
  43025. * Gets or sets the action manager associated with the scene
  43026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43027. */
  43028. actionManager: AbstractActionManager;
  43029. private _meshesForIntersections;
  43030. /**
  43031. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43032. */
  43033. proceduralTexturesEnabled: boolean;
  43034. private _engine;
  43035. private _totalVertices;
  43036. /** @hidden */
  43037. _activeIndices: PerfCounter;
  43038. /** @hidden */
  43039. _activeParticles: PerfCounter;
  43040. /** @hidden */
  43041. _activeBones: PerfCounter;
  43042. private _animationRatio;
  43043. /** @hidden */
  43044. _animationTimeLast: number;
  43045. /** @hidden */
  43046. _animationTime: number;
  43047. /**
  43048. * Gets or sets a general scale for animation speed
  43049. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43050. */
  43051. animationTimeScale: number;
  43052. /** @hidden */
  43053. _cachedMaterial: Nullable<Material>;
  43054. /** @hidden */
  43055. _cachedEffect: Nullable<Effect>;
  43056. /** @hidden */
  43057. _cachedVisibility: Nullable<number>;
  43058. private _renderId;
  43059. private _frameId;
  43060. private _executeWhenReadyTimeoutId;
  43061. private _intermediateRendering;
  43062. private _viewUpdateFlag;
  43063. private _projectionUpdateFlag;
  43064. /** @hidden */
  43065. _toBeDisposed: Nullable<IDisposable>[];
  43066. private _activeRequests;
  43067. /** @hidden */
  43068. _pendingData: any[];
  43069. private _isDisposed;
  43070. /**
  43071. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43072. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43073. */
  43074. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43075. private _activeMeshes;
  43076. private _processedMaterials;
  43077. private _renderTargets;
  43078. /** @hidden */
  43079. _activeParticleSystems: SmartArray<IParticleSystem>;
  43080. private _activeSkeletons;
  43081. private _softwareSkinnedMeshes;
  43082. private _renderingManager;
  43083. /** @hidden */
  43084. _activeAnimatables: Animatable[];
  43085. private _transformMatrix;
  43086. private _sceneUbo;
  43087. /** @hidden */
  43088. _viewMatrix: Matrix;
  43089. private _projectionMatrix;
  43090. /** @hidden */
  43091. _forcedViewPosition: Nullable<Vector3>;
  43092. /** @hidden */
  43093. _frustumPlanes: Plane[];
  43094. /**
  43095. * Gets the list of frustum planes (built from the active camera)
  43096. */
  43097. get frustumPlanes(): Plane[];
  43098. /**
  43099. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43100. * This is useful if there are more lights that the maximum simulteanous authorized
  43101. */
  43102. requireLightSorting: boolean;
  43103. /** @hidden */
  43104. readonly useMaterialMeshMap: boolean;
  43105. /** @hidden */
  43106. readonly useClonedMeshMap: boolean;
  43107. private _externalData;
  43108. private _uid;
  43109. /**
  43110. * @hidden
  43111. * Backing store of defined scene components.
  43112. */
  43113. _components: ISceneComponent[];
  43114. /**
  43115. * @hidden
  43116. * Backing store of defined scene components.
  43117. */
  43118. _serializableComponents: ISceneSerializableComponent[];
  43119. /**
  43120. * List of components to register on the next registration step.
  43121. */
  43122. private _transientComponents;
  43123. /**
  43124. * Registers the transient components if needed.
  43125. */
  43126. private _registerTransientComponents;
  43127. /**
  43128. * @hidden
  43129. * Add a component to the scene.
  43130. * Note that the ccomponent could be registered on th next frame if this is called after
  43131. * the register component stage.
  43132. * @param component Defines the component to add to the scene
  43133. */
  43134. _addComponent(component: ISceneComponent): void;
  43135. /**
  43136. * @hidden
  43137. * Gets a component from the scene.
  43138. * @param name defines the name of the component to retrieve
  43139. * @returns the component or null if not present
  43140. */
  43141. _getComponent(name: string): Nullable<ISceneComponent>;
  43142. /**
  43143. * @hidden
  43144. * Defines the actions happening before camera updates.
  43145. */
  43146. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43147. /**
  43148. * @hidden
  43149. * Defines the actions happening before clear the canvas.
  43150. */
  43151. _beforeClearStage: Stage<SimpleStageAction>;
  43152. /**
  43153. * @hidden
  43154. * Defines the actions when collecting render targets for the frame.
  43155. */
  43156. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43157. /**
  43158. * @hidden
  43159. * Defines the actions happening for one camera in the frame.
  43160. */
  43161. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43162. /**
  43163. * @hidden
  43164. * Defines the actions happening during the per mesh ready checks.
  43165. */
  43166. _isReadyForMeshStage: Stage<MeshStageAction>;
  43167. /**
  43168. * @hidden
  43169. * Defines the actions happening before evaluate active mesh checks.
  43170. */
  43171. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43172. /**
  43173. * @hidden
  43174. * Defines the actions happening during the evaluate sub mesh checks.
  43175. */
  43176. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43177. /**
  43178. * @hidden
  43179. * Defines the actions happening during the active mesh stage.
  43180. */
  43181. _activeMeshStage: Stage<ActiveMeshStageAction>;
  43182. /**
  43183. * @hidden
  43184. * Defines the actions happening during the per camera render target step.
  43185. */
  43186. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43187. /**
  43188. * @hidden
  43189. * Defines the actions happening just before the active camera is drawing.
  43190. */
  43191. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43192. /**
  43193. * @hidden
  43194. * Defines the actions happening just before a render target is drawing.
  43195. */
  43196. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43197. /**
  43198. * @hidden
  43199. * Defines the actions happening just before a rendering group is drawing.
  43200. */
  43201. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43202. /**
  43203. * @hidden
  43204. * Defines the actions happening just before a mesh is drawing.
  43205. */
  43206. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43207. /**
  43208. * @hidden
  43209. * Defines the actions happening just after a mesh has been drawn.
  43210. */
  43211. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43212. /**
  43213. * @hidden
  43214. * Defines the actions happening just after a rendering group has been drawn.
  43215. */
  43216. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43217. /**
  43218. * @hidden
  43219. * Defines the actions happening just after the active camera has been drawn.
  43220. */
  43221. _afterCameraDrawStage: Stage<CameraStageAction>;
  43222. /**
  43223. * @hidden
  43224. * Defines the actions happening just after a render target has been drawn.
  43225. */
  43226. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43227. /**
  43228. * @hidden
  43229. * Defines the actions happening just after rendering all cameras and computing intersections.
  43230. */
  43231. _afterRenderStage: Stage<SimpleStageAction>;
  43232. /**
  43233. * @hidden
  43234. * Defines the actions happening when a pointer move event happens.
  43235. */
  43236. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43237. /**
  43238. * @hidden
  43239. * Defines the actions happening when a pointer down event happens.
  43240. */
  43241. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43242. /**
  43243. * @hidden
  43244. * Defines the actions happening when a pointer up event happens.
  43245. */
  43246. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43247. /**
  43248. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43249. */
  43250. private geometriesByUniqueId;
  43251. /**
  43252. * Creates a new Scene
  43253. * @param engine defines the engine to use to render this scene
  43254. * @param options defines the scene options
  43255. */
  43256. constructor(engine: Engine, options?: SceneOptions);
  43257. /**
  43258. * Gets a string identifying the name of the class
  43259. * @returns "Scene" string
  43260. */
  43261. getClassName(): string;
  43262. private _defaultMeshCandidates;
  43263. /**
  43264. * @hidden
  43265. */
  43266. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43267. private _defaultSubMeshCandidates;
  43268. /**
  43269. * @hidden
  43270. */
  43271. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43272. /**
  43273. * Sets the default candidate providers for the scene.
  43274. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43275. * and getCollidingSubMeshCandidates to their default function
  43276. */
  43277. setDefaultCandidateProviders(): void;
  43278. /**
  43279. * Gets the mesh that is currently under the pointer
  43280. */
  43281. get meshUnderPointer(): Nullable<AbstractMesh>;
  43282. /**
  43283. * Gets or sets the current on-screen X position of the pointer
  43284. */
  43285. get pointerX(): number;
  43286. set pointerX(value: number);
  43287. /**
  43288. * Gets or sets the current on-screen Y position of the pointer
  43289. */
  43290. get pointerY(): number;
  43291. set pointerY(value: number);
  43292. /**
  43293. * Gets the cached material (ie. the latest rendered one)
  43294. * @returns the cached material
  43295. */
  43296. getCachedMaterial(): Nullable<Material>;
  43297. /**
  43298. * Gets the cached effect (ie. the latest rendered one)
  43299. * @returns the cached effect
  43300. */
  43301. getCachedEffect(): Nullable<Effect>;
  43302. /**
  43303. * Gets the cached visibility state (ie. the latest rendered one)
  43304. * @returns the cached visibility state
  43305. */
  43306. getCachedVisibility(): Nullable<number>;
  43307. /**
  43308. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43309. * @param material defines the current material
  43310. * @param effect defines the current effect
  43311. * @param visibility defines the current visibility state
  43312. * @returns true if one parameter is not cached
  43313. */
  43314. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43315. /**
  43316. * Gets the engine associated with the scene
  43317. * @returns an Engine
  43318. */
  43319. getEngine(): Engine;
  43320. /**
  43321. * Gets the total number of vertices rendered per frame
  43322. * @returns the total number of vertices rendered per frame
  43323. */
  43324. getTotalVertices(): number;
  43325. /**
  43326. * Gets the performance counter for total vertices
  43327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43328. */
  43329. get totalVerticesPerfCounter(): PerfCounter;
  43330. /**
  43331. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43332. * @returns the total number of active indices rendered per frame
  43333. */
  43334. getActiveIndices(): number;
  43335. /**
  43336. * Gets the performance counter for active indices
  43337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43338. */
  43339. get totalActiveIndicesPerfCounter(): PerfCounter;
  43340. /**
  43341. * Gets the total number of active particles rendered per frame
  43342. * @returns the total number of active particles rendered per frame
  43343. */
  43344. getActiveParticles(): number;
  43345. /**
  43346. * Gets the performance counter for active particles
  43347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43348. */
  43349. get activeParticlesPerfCounter(): PerfCounter;
  43350. /**
  43351. * Gets the total number of active bones rendered per frame
  43352. * @returns the total number of active bones rendered per frame
  43353. */
  43354. getActiveBones(): number;
  43355. /**
  43356. * Gets the performance counter for active bones
  43357. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43358. */
  43359. get activeBonesPerfCounter(): PerfCounter;
  43360. /**
  43361. * Gets the array of active meshes
  43362. * @returns an array of AbstractMesh
  43363. */
  43364. getActiveMeshes(): SmartArray<AbstractMesh>;
  43365. /**
  43366. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43367. * @returns a number
  43368. */
  43369. getAnimationRatio(): number;
  43370. /**
  43371. * Gets an unique Id for the current render phase
  43372. * @returns a number
  43373. */
  43374. getRenderId(): number;
  43375. /**
  43376. * Gets an unique Id for the current frame
  43377. * @returns a number
  43378. */
  43379. getFrameId(): number;
  43380. /** Call this function if you want to manually increment the render Id*/
  43381. incrementRenderId(): void;
  43382. private _createUbo;
  43383. /**
  43384. * Use this method to simulate a pointer move on a mesh
  43385. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43386. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43387. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43388. * @returns the current scene
  43389. */
  43390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43391. /**
  43392. * Use this method to simulate a pointer down on a mesh
  43393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43396. * @returns the current scene
  43397. */
  43398. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43399. /**
  43400. * Use this method to simulate a pointer up on a mesh
  43401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43404. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43405. * @returns the current scene
  43406. */
  43407. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43408. /**
  43409. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43410. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43411. * @returns true if the pointer was captured
  43412. */
  43413. isPointerCaptured(pointerId?: number): boolean;
  43414. /**
  43415. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43416. * @param attachUp defines if you want to attach events to pointerup
  43417. * @param attachDown defines if you want to attach events to pointerdown
  43418. * @param attachMove defines if you want to attach events to pointermove
  43419. */
  43420. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43421. /** Detaches all event handlers*/
  43422. detachControl(): void;
  43423. /**
  43424. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43425. * Delay loaded resources are not taking in account
  43426. * @return true if all required resources are ready
  43427. */
  43428. isReady(): boolean;
  43429. /** Resets all cached information relative to material (including effect and visibility) */
  43430. resetCachedMaterial(): void;
  43431. /**
  43432. * Registers a function to be called before every frame render
  43433. * @param func defines the function to register
  43434. */
  43435. registerBeforeRender(func: () => void): void;
  43436. /**
  43437. * Unregisters a function called before every frame render
  43438. * @param func defines the function to unregister
  43439. */
  43440. unregisterBeforeRender(func: () => void): void;
  43441. /**
  43442. * Registers a function to be called after every frame render
  43443. * @param func defines the function to register
  43444. */
  43445. registerAfterRender(func: () => void): void;
  43446. /**
  43447. * Unregisters a function called after every frame render
  43448. * @param func defines the function to unregister
  43449. */
  43450. unregisterAfterRender(func: () => void): void;
  43451. private _executeOnceBeforeRender;
  43452. /**
  43453. * The provided function will run before render once and will be disposed afterwards.
  43454. * A timeout delay can be provided so that the function will be executed in N ms.
  43455. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43456. * @param func The function to be executed.
  43457. * @param timeout optional delay in ms
  43458. */
  43459. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43460. /** @hidden */
  43461. _addPendingData(data: any): void;
  43462. /** @hidden */
  43463. _removePendingData(data: any): void;
  43464. /**
  43465. * Returns the number of items waiting to be loaded
  43466. * @returns the number of items waiting to be loaded
  43467. */
  43468. getWaitingItemsCount(): number;
  43469. /**
  43470. * Returns a boolean indicating if the scene is still loading data
  43471. */
  43472. get isLoading(): boolean;
  43473. /**
  43474. * Registers a function to be executed when the scene is ready
  43475. * @param {Function} func - the function to be executed
  43476. */
  43477. executeWhenReady(func: () => void): void;
  43478. /**
  43479. * Returns a promise that resolves when the scene is ready
  43480. * @returns A promise that resolves when the scene is ready
  43481. */
  43482. whenReadyAsync(): Promise<void>;
  43483. /** @hidden */
  43484. _checkIsReady(): void;
  43485. /**
  43486. * Gets all animatable attached to the scene
  43487. */
  43488. get animatables(): Animatable[];
  43489. /**
  43490. * Resets the last animation time frame.
  43491. * Useful to override when animations start running when loading a scene for the first time.
  43492. */
  43493. resetLastAnimationTimeFrame(): void;
  43494. /**
  43495. * Gets the current view matrix
  43496. * @returns a Matrix
  43497. */
  43498. getViewMatrix(): Matrix;
  43499. /**
  43500. * Gets the current projection matrix
  43501. * @returns a Matrix
  43502. */
  43503. getProjectionMatrix(): Matrix;
  43504. /**
  43505. * Gets the current transform matrix
  43506. * @returns a Matrix made of View * Projection
  43507. */
  43508. getTransformMatrix(): Matrix;
  43509. /**
  43510. * Sets the current transform matrix
  43511. * @param viewL defines the View matrix to use
  43512. * @param projectionL defines the Projection matrix to use
  43513. * @param viewR defines the right View matrix to use (if provided)
  43514. * @param projectionR defines the right Projection matrix to use (if provided)
  43515. */
  43516. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43517. /**
  43518. * Gets the uniform buffer used to store scene data
  43519. * @returns a UniformBuffer
  43520. */
  43521. getSceneUniformBuffer(): UniformBuffer;
  43522. /**
  43523. * Gets an unique (relatively to the current scene) Id
  43524. * @returns an unique number for the scene
  43525. */
  43526. getUniqueId(): number;
  43527. /**
  43528. * Add a mesh to the list of scene's meshes
  43529. * @param newMesh defines the mesh to add
  43530. * @param recursive if all child meshes should also be added to the scene
  43531. */
  43532. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43533. /**
  43534. * Remove a mesh for the list of scene's meshes
  43535. * @param toRemove defines the mesh to remove
  43536. * @param recursive if all child meshes should also be removed from the scene
  43537. * @returns the index where the mesh was in the mesh list
  43538. */
  43539. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43540. /**
  43541. * Add a transform node to the list of scene's transform nodes
  43542. * @param newTransformNode defines the transform node to add
  43543. */
  43544. addTransformNode(newTransformNode: TransformNode): void;
  43545. /**
  43546. * Remove a transform node for the list of scene's transform nodes
  43547. * @param toRemove defines the transform node to remove
  43548. * @returns the index where the transform node was in the transform node list
  43549. */
  43550. removeTransformNode(toRemove: TransformNode): number;
  43551. /**
  43552. * Remove a skeleton for the list of scene's skeletons
  43553. * @param toRemove defines the skeleton to remove
  43554. * @returns the index where the skeleton was in the skeleton list
  43555. */
  43556. removeSkeleton(toRemove: Skeleton): number;
  43557. /**
  43558. * Remove a morph target for the list of scene's morph targets
  43559. * @param toRemove defines the morph target to remove
  43560. * @returns the index where the morph target was in the morph target list
  43561. */
  43562. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43563. /**
  43564. * Remove a light for the list of scene's lights
  43565. * @param toRemove defines the light to remove
  43566. * @returns the index where the light was in the light list
  43567. */
  43568. removeLight(toRemove: Light): number;
  43569. /**
  43570. * Remove a camera for the list of scene's cameras
  43571. * @param toRemove defines the camera to remove
  43572. * @returns the index where the camera was in the camera list
  43573. */
  43574. removeCamera(toRemove: Camera): number;
  43575. /**
  43576. * Remove a particle system for the list of scene's particle systems
  43577. * @param toRemove defines the particle system to remove
  43578. * @returns the index where the particle system was in the particle system list
  43579. */
  43580. removeParticleSystem(toRemove: IParticleSystem): number;
  43581. /**
  43582. * Remove a animation for the list of scene's animations
  43583. * @param toRemove defines the animation to remove
  43584. * @returns the index where the animation was in the animation list
  43585. */
  43586. removeAnimation(toRemove: Animation): number;
  43587. /**
  43588. * Will stop the animation of the given target
  43589. * @param target - the target
  43590. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43591. * @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)
  43592. */
  43593. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43594. /**
  43595. * Removes the given animation group from this scene.
  43596. * @param toRemove The animation group to remove
  43597. * @returns The index of the removed animation group
  43598. */
  43599. removeAnimationGroup(toRemove: AnimationGroup): number;
  43600. /**
  43601. * Removes the given multi-material from this scene.
  43602. * @param toRemove The multi-material to remove
  43603. * @returns The index of the removed multi-material
  43604. */
  43605. removeMultiMaterial(toRemove: MultiMaterial): number;
  43606. /**
  43607. * Removes the given material from this scene.
  43608. * @param toRemove The material to remove
  43609. * @returns The index of the removed material
  43610. */
  43611. removeMaterial(toRemove: Material): number;
  43612. /**
  43613. * Removes the given action manager from this scene.
  43614. * @param toRemove The action manager to remove
  43615. * @returns The index of the removed action manager
  43616. */
  43617. removeActionManager(toRemove: AbstractActionManager): number;
  43618. /**
  43619. * Removes the given texture from this scene.
  43620. * @param toRemove The texture to remove
  43621. * @returns The index of the removed texture
  43622. */
  43623. removeTexture(toRemove: BaseTexture): number;
  43624. /**
  43625. * Adds the given light to this scene
  43626. * @param newLight The light to add
  43627. */
  43628. addLight(newLight: Light): void;
  43629. /**
  43630. * Sorts the list list based on light priorities
  43631. */
  43632. sortLightsByPriority(): void;
  43633. /**
  43634. * Adds the given camera to this scene
  43635. * @param newCamera The camera to add
  43636. */
  43637. addCamera(newCamera: Camera): void;
  43638. /**
  43639. * Adds the given skeleton to this scene
  43640. * @param newSkeleton The skeleton to add
  43641. */
  43642. addSkeleton(newSkeleton: Skeleton): void;
  43643. /**
  43644. * Adds the given particle system to this scene
  43645. * @param newParticleSystem The particle system to add
  43646. */
  43647. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43648. /**
  43649. * Adds the given animation to this scene
  43650. * @param newAnimation The animation to add
  43651. */
  43652. addAnimation(newAnimation: Animation): void;
  43653. /**
  43654. * Adds the given animation group to this scene.
  43655. * @param newAnimationGroup The animation group to add
  43656. */
  43657. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43658. /**
  43659. * Adds the given multi-material to this scene
  43660. * @param newMultiMaterial The multi-material to add
  43661. */
  43662. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43663. /**
  43664. * Adds the given material to this scene
  43665. * @param newMaterial The material to add
  43666. */
  43667. addMaterial(newMaterial: Material): void;
  43668. /**
  43669. * Adds the given morph target to this scene
  43670. * @param newMorphTargetManager The morph target to add
  43671. */
  43672. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43673. /**
  43674. * Adds the given geometry to this scene
  43675. * @param newGeometry The geometry to add
  43676. */
  43677. addGeometry(newGeometry: Geometry): void;
  43678. /**
  43679. * Adds the given action manager to this scene
  43680. * @param newActionManager The action manager to add
  43681. */
  43682. addActionManager(newActionManager: AbstractActionManager): void;
  43683. /**
  43684. * Adds the given texture to this scene.
  43685. * @param newTexture The texture to add
  43686. */
  43687. addTexture(newTexture: BaseTexture): void;
  43688. /**
  43689. * Switch active camera
  43690. * @param newCamera defines the new active camera
  43691. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43692. */
  43693. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43694. /**
  43695. * sets the active camera of the scene using its ID
  43696. * @param id defines the camera's ID
  43697. * @return the new active camera or null if none found.
  43698. */
  43699. setActiveCameraByID(id: string): Nullable<Camera>;
  43700. /**
  43701. * sets the active camera of the scene using its name
  43702. * @param name defines the camera's name
  43703. * @returns the new active camera or null if none found.
  43704. */
  43705. setActiveCameraByName(name: string): Nullable<Camera>;
  43706. /**
  43707. * get an animation group using its name
  43708. * @param name defines the material's name
  43709. * @return the animation group or null if none found.
  43710. */
  43711. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43712. /**
  43713. * Get a material using its unique id
  43714. * @param uniqueId defines the material's unique id
  43715. * @return the material or null if none found.
  43716. */
  43717. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43718. /**
  43719. * get a material using its id
  43720. * @param id defines the material's ID
  43721. * @return the material or null if none found.
  43722. */
  43723. getMaterialByID(id: string): Nullable<Material>;
  43724. /**
  43725. * Gets a the last added material using a given id
  43726. * @param id defines the material's ID
  43727. * @return the last material with the given id or null if none found.
  43728. */
  43729. getLastMaterialByID(id: string): Nullable<Material>;
  43730. /**
  43731. * Gets a material using its name
  43732. * @param name defines the material's name
  43733. * @return the material or null if none found.
  43734. */
  43735. getMaterialByName(name: string): Nullable<Material>;
  43736. /**
  43737. * Get a texture using its unique id
  43738. * @param uniqueId defines the texture's unique id
  43739. * @return the texture or null if none found.
  43740. */
  43741. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43742. /**
  43743. * Gets a camera using its id
  43744. * @param id defines the id to look for
  43745. * @returns the camera or null if not found
  43746. */
  43747. getCameraByID(id: string): Nullable<Camera>;
  43748. /**
  43749. * Gets a camera using its unique id
  43750. * @param uniqueId defines the unique id to look for
  43751. * @returns the camera or null if not found
  43752. */
  43753. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43754. /**
  43755. * Gets a camera using its name
  43756. * @param name defines the camera's name
  43757. * @return the camera or null if none found.
  43758. */
  43759. getCameraByName(name: string): Nullable<Camera>;
  43760. /**
  43761. * Gets a bone using its id
  43762. * @param id defines the bone's id
  43763. * @return the bone or null if not found
  43764. */
  43765. getBoneByID(id: string): Nullable<Bone>;
  43766. /**
  43767. * Gets a bone using its id
  43768. * @param name defines the bone's name
  43769. * @return the bone or null if not found
  43770. */
  43771. getBoneByName(name: string): Nullable<Bone>;
  43772. /**
  43773. * Gets a light node using its name
  43774. * @param name defines the the light's name
  43775. * @return the light or null if none found.
  43776. */
  43777. getLightByName(name: string): Nullable<Light>;
  43778. /**
  43779. * Gets a light node using its id
  43780. * @param id defines the light's id
  43781. * @return the light or null if none found.
  43782. */
  43783. getLightByID(id: string): Nullable<Light>;
  43784. /**
  43785. * Gets a light node using its scene-generated unique ID
  43786. * @param uniqueId defines the light's unique id
  43787. * @return the light or null if none found.
  43788. */
  43789. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43790. /**
  43791. * Gets a particle system by id
  43792. * @param id defines the particle system id
  43793. * @return the corresponding system or null if none found
  43794. */
  43795. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43796. /**
  43797. * Gets a geometry using its ID
  43798. * @param id defines the geometry's id
  43799. * @return the geometry or null if none found.
  43800. */
  43801. getGeometryByID(id: string): Nullable<Geometry>;
  43802. private _getGeometryByUniqueID;
  43803. /**
  43804. * Add a new geometry to this scene
  43805. * @param geometry defines the geometry to be added to the scene.
  43806. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43807. * @return a boolean defining if the geometry was added or not
  43808. */
  43809. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43810. /**
  43811. * Removes an existing geometry
  43812. * @param geometry defines the geometry to be removed from the scene
  43813. * @return a boolean defining if the geometry was removed or not
  43814. */
  43815. removeGeometry(geometry: Geometry): boolean;
  43816. /**
  43817. * Gets the list of geometries attached to the scene
  43818. * @returns an array of Geometry
  43819. */
  43820. getGeometries(): Geometry[];
  43821. /**
  43822. * Gets the first added mesh found of a given ID
  43823. * @param id defines the id to search for
  43824. * @return the mesh found or null if not found at all
  43825. */
  43826. getMeshByID(id: string): Nullable<AbstractMesh>;
  43827. /**
  43828. * Gets a list of meshes using their id
  43829. * @param id defines the id to search for
  43830. * @returns a list of meshes
  43831. */
  43832. getMeshesByID(id: string): Array<AbstractMesh>;
  43833. /**
  43834. * Gets the first added transform node found of a given ID
  43835. * @param id defines the id to search for
  43836. * @return the found transform node or null if not found at all.
  43837. */
  43838. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43839. /**
  43840. * Gets a transform node with its auto-generated unique id
  43841. * @param uniqueId efines the unique id to search for
  43842. * @return the found transform node or null if not found at all.
  43843. */
  43844. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43845. /**
  43846. * Gets a list of transform nodes using their id
  43847. * @param id defines the id to search for
  43848. * @returns a list of transform nodes
  43849. */
  43850. getTransformNodesByID(id: string): Array<TransformNode>;
  43851. /**
  43852. * Gets a mesh with its auto-generated unique id
  43853. * @param uniqueId defines the unique id to search for
  43854. * @return the found mesh or null if not found at all.
  43855. */
  43856. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43857. /**
  43858. * Gets a the last added mesh using a given id
  43859. * @param id defines the id to search for
  43860. * @return the found mesh or null if not found at all.
  43861. */
  43862. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43863. /**
  43864. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43865. * @param id defines the id to search for
  43866. * @return the found node or null if not found at all
  43867. */
  43868. getLastEntryByID(id: string): Nullable<Node>;
  43869. /**
  43870. * Gets a node (Mesh, Camera, Light) using a given id
  43871. * @param id defines the id to search for
  43872. * @return the found node or null if not found at all
  43873. */
  43874. getNodeByID(id: string): Nullable<Node>;
  43875. /**
  43876. * Gets a node (Mesh, Camera, Light) using a given name
  43877. * @param name defines the name to search for
  43878. * @return the found node or null if not found at all.
  43879. */
  43880. getNodeByName(name: string): Nullable<Node>;
  43881. /**
  43882. * Gets a mesh using a given name
  43883. * @param name defines the name to search for
  43884. * @return the found mesh or null if not found at all.
  43885. */
  43886. getMeshByName(name: string): Nullable<AbstractMesh>;
  43887. /**
  43888. * Gets a transform node using a given name
  43889. * @param name defines the name to search for
  43890. * @return the found transform node or null if not found at all.
  43891. */
  43892. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43893. /**
  43894. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43895. * @param id defines the id to search for
  43896. * @return the found skeleton or null if not found at all.
  43897. */
  43898. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43899. /**
  43900. * Gets a skeleton using a given auto generated unique id
  43901. * @param uniqueId defines the unique id to search for
  43902. * @return the found skeleton or null if not found at all.
  43903. */
  43904. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43905. /**
  43906. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43907. * @param id defines the id to search for
  43908. * @return the found skeleton or null if not found at all.
  43909. */
  43910. getSkeletonById(id: string): Nullable<Skeleton>;
  43911. /**
  43912. * Gets a skeleton using a given name
  43913. * @param name defines the name to search for
  43914. * @return the found skeleton or null if not found at all.
  43915. */
  43916. getSkeletonByName(name: string): Nullable<Skeleton>;
  43917. /**
  43918. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43919. * @param id defines the id to search for
  43920. * @return the found morph target manager or null if not found at all.
  43921. */
  43922. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43923. /**
  43924. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43925. * @param id defines the id to search for
  43926. * @return the found morph target or null if not found at all.
  43927. */
  43928. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43929. /**
  43930. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43931. * @param name defines the name to search for
  43932. * @return the found morph target or null if not found at all.
  43933. */
  43934. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43935. /**
  43936. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43937. * @param name defines the name to search for
  43938. * @return the found post process or null if not found at all.
  43939. */
  43940. getPostProcessByName(name: string): Nullable<PostProcess>;
  43941. /**
  43942. * Gets a boolean indicating if the given mesh is active
  43943. * @param mesh defines the mesh to look for
  43944. * @returns true if the mesh is in the active list
  43945. */
  43946. isActiveMesh(mesh: AbstractMesh): boolean;
  43947. /**
  43948. * Return a unique id as a string which can serve as an identifier for the scene
  43949. */
  43950. get uid(): string;
  43951. /**
  43952. * Add an externaly attached data from its key.
  43953. * This method call will fail and return false, if such key already exists.
  43954. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43955. * @param key the unique key that identifies the data
  43956. * @param data the data object to associate to the key for this Engine instance
  43957. * @return true if no such key were already present and the data was added successfully, false otherwise
  43958. */
  43959. addExternalData<T>(key: string, data: T): boolean;
  43960. /**
  43961. * Get an externaly attached data from its key
  43962. * @param key the unique key that identifies the data
  43963. * @return the associated data, if present (can be null), or undefined if not present
  43964. */
  43965. getExternalData<T>(key: string): Nullable<T>;
  43966. /**
  43967. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43968. * @param key the unique key that identifies the data
  43969. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43970. * @return the associated data, can be null if the factory returned null.
  43971. */
  43972. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43973. /**
  43974. * Remove an externaly attached data from the Engine instance
  43975. * @param key the unique key that identifies the data
  43976. * @return true if the data was successfully removed, false if it doesn't exist
  43977. */
  43978. removeExternalData(key: string): boolean;
  43979. private _evaluateSubMesh;
  43980. /**
  43981. * Clear the processed materials smart array preventing retention point in material dispose.
  43982. */
  43983. freeProcessedMaterials(): void;
  43984. private _preventFreeActiveMeshesAndRenderingGroups;
  43985. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43986. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43987. * when disposing several meshes in a row or a hierarchy of meshes.
  43988. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  43989. */
  43990. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  43991. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  43992. /**
  43993. * Clear the active meshes smart array preventing retention point in mesh dispose.
  43994. */
  43995. freeActiveMeshes(): void;
  43996. /**
  43997. * Clear the info related to rendering groups preventing retention points during dispose.
  43998. */
  43999. freeRenderingGroups(): void;
  44000. /** @hidden */
  44001. _isInIntermediateRendering(): boolean;
  44002. /**
  44003. * Lambda returning the list of potentially active meshes.
  44004. */
  44005. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44006. /**
  44007. * Lambda returning the list of potentially active sub meshes.
  44008. */
  44009. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44010. /**
  44011. * Lambda returning the list of potentially intersecting sub meshes.
  44012. */
  44013. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44014. /**
  44015. * Lambda returning the list of potentially colliding sub meshes.
  44016. */
  44017. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44018. private _activeMeshesFrozen;
  44019. private _skipEvaluateActiveMeshesCompletely;
  44020. /**
  44021. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44022. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44023. * @param onSuccess optional success callback
  44024. * @param onError optional error callback
  44025. * @returns the current scene
  44026. */
  44027. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44028. /**
  44029. * Use this function to restart evaluating active meshes on every frame
  44030. * @returns the current scene
  44031. */
  44032. unfreezeActiveMeshes(): Scene;
  44033. private _evaluateActiveMeshes;
  44034. private _activeMesh;
  44035. /**
  44036. * Update the transform matrix to update from the current active camera
  44037. * @param force defines a boolean used to force the update even if cache is up to date
  44038. */
  44039. updateTransformMatrix(force?: boolean): void;
  44040. private _bindFrameBuffer;
  44041. /** @hidden */
  44042. _allowPostProcessClearColor: boolean;
  44043. /** @hidden */
  44044. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44045. private _processSubCameras;
  44046. private _checkIntersections;
  44047. /** @hidden */
  44048. _advancePhysicsEngineStep(step: number): void;
  44049. /**
  44050. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44051. */
  44052. getDeterministicFrameTime: () => number;
  44053. /** @hidden */
  44054. _animate(): void;
  44055. /** Execute all animations (for a frame) */
  44056. animate(): void;
  44057. /**
  44058. * Render the scene
  44059. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44060. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44061. */
  44062. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44063. /**
  44064. * Freeze all materials
  44065. * A frozen material will not be updatable but should be faster to render
  44066. */
  44067. freezeMaterials(): void;
  44068. /**
  44069. * Unfreeze all materials
  44070. * A frozen material will not be updatable but should be faster to render
  44071. */
  44072. unfreezeMaterials(): void;
  44073. /**
  44074. * Releases all held ressources
  44075. */
  44076. dispose(): void;
  44077. /**
  44078. * Gets if the scene is already disposed
  44079. */
  44080. get isDisposed(): boolean;
  44081. /**
  44082. * Call this function to reduce memory footprint of the scene.
  44083. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44084. */
  44085. clearCachedVertexData(): void;
  44086. /**
  44087. * This function will remove the local cached buffer data from texture.
  44088. * It will save memory but will prevent the texture from being rebuilt
  44089. */
  44090. cleanCachedTextureBuffer(): void;
  44091. /**
  44092. * Get the world extend vectors with an optional filter
  44093. *
  44094. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44095. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44096. */
  44097. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44098. min: Vector3;
  44099. max: Vector3;
  44100. };
  44101. /**
  44102. * Creates a ray that can be used to pick in the scene
  44103. * @param x defines the x coordinate of the origin (on-screen)
  44104. * @param y defines the y coordinate of the origin (on-screen)
  44105. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44106. * @param camera defines the camera to use for the picking
  44107. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44108. * @returns a Ray
  44109. */
  44110. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44111. /**
  44112. * Creates a ray that can be used to pick in the scene
  44113. * @param x defines the x coordinate of the origin (on-screen)
  44114. * @param y defines the y coordinate of the origin (on-screen)
  44115. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44116. * @param result defines the ray where to store the picking ray
  44117. * @param camera defines the camera to use for the picking
  44118. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44119. * @returns the current scene
  44120. */
  44121. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44122. /**
  44123. * Creates a ray that can be used to pick in the scene
  44124. * @param x defines the x coordinate of the origin (on-screen)
  44125. * @param y defines the y coordinate of the origin (on-screen)
  44126. * @param camera defines the camera to use for the picking
  44127. * @returns a Ray
  44128. */
  44129. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44130. /**
  44131. * Creates a ray that can be used to pick in the scene
  44132. * @param x defines the x coordinate of the origin (on-screen)
  44133. * @param y defines the y coordinate of the origin (on-screen)
  44134. * @param result defines the ray where to store the picking ray
  44135. * @param camera defines the camera to use for the picking
  44136. * @returns the current scene
  44137. */
  44138. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44139. /** Launch a ray to try to pick a mesh in the scene
  44140. * @param x position on screen
  44141. * @param y position on screen
  44142. * @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
  44143. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44144. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44146. * @returns a PickingInfo
  44147. */
  44148. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44149. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44150. * @param x position on screen
  44151. * @param y position on screen
  44152. * @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
  44153. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44154. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44155. * @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)
  44156. */
  44157. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44158. /** Use the given ray to pick a mesh in the scene
  44159. * @param ray The ray to use to pick meshes
  44160. * @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
  44161. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44162. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44163. * @returns a PickingInfo
  44164. */
  44165. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44166. /**
  44167. * Launch a ray to try to pick a mesh in the scene
  44168. * @param x X position on screen
  44169. * @param y Y position on screen
  44170. * @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
  44171. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44172. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44173. * @returns an array of PickingInfo
  44174. */
  44175. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44176. /**
  44177. * Launch a ray to try to pick a mesh in the scene
  44178. * @param ray Ray to use
  44179. * @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
  44180. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44181. * @returns an array of PickingInfo
  44182. */
  44183. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44184. /**
  44185. * Force the value of meshUnderPointer
  44186. * @param mesh defines the mesh to use
  44187. * @param pointerId optional pointer id when using more than one pointer
  44188. */
  44189. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44190. /**
  44191. * Gets the mesh under the pointer
  44192. * @returns a Mesh or null if no mesh is under the pointer
  44193. */
  44194. getPointerOverMesh(): Nullable<AbstractMesh>;
  44195. /** @hidden */
  44196. _rebuildGeometries(): void;
  44197. /** @hidden */
  44198. _rebuildTextures(): void;
  44199. private _getByTags;
  44200. /**
  44201. * Get a list of meshes by tags
  44202. * @param tagsQuery defines the tags query to use
  44203. * @param forEach defines a predicate used to filter results
  44204. * @returns an array of Mesh
  44205. */
  44206. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44207. /**
  44208. * Get a list of cameras by tags
  44209. * @param tagsQuery defines the tags query to use
  44210. * @param forEach defines a predicate used to filter results
  44211. * @returns an array of Camera
  44212. */
  44213. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44214. /**
  44215. * Get a list of lights by tags
  44216. * @param tagsQuery defines the tags query to use
  44217. * @param forEach defines a predicate used to filter results
  44218. * @returns an array of Light
  44219. */
  44220. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44221. /**
  44222. * Get a list of materials by tags
  44223. * @param tagsQuery defines the tags query to use
  44224. * @param forEach defines a predicate used to filter results
  44225. * @returns an array of Material
  44226. */
  44227. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44228. /**
  44229. * Get a list of transform nodes by tags
  44230. * @param tagsQuery defines the tags query to use
  44231. * @param forEach defines a predicate used to filter results
  44232. * @returns an array of TransformNode
  44233. */
  44234. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44235. /**
  44236. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44237. * This allowed control for front to back rendering or reversly depending of the special needs.
  44238. *
  44239. * @param renderingGroupId The rendering group id corresponding to its index
  44240. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44241. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44242. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44243. */
  44244. 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;
  44245. /**
  44246. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44247. *
  44248. * @param renderingGroupId The rendering group id corresponding to its index
  44249. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44250. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44251. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44252. */
  44253. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44254. /**
  44255. * Gets the current auto clear configuration for one rendering group of the rendering
  44256. * manager.
  44257. * @param index the rendering group index to get the information for
  44258. * @returns The auto clear setup for the requested rendering group
  44259. */
  44260. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44261. private _blockMaterialDirtyMechanism;
  44262. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44263. get blockMaterialDirtyMechanism(): boolean;
  44264. set blockMaterialDirtyMechanism(value: boolean);
  44265. /**
  44266. * Will flag all materials as dirty to trigger new shader compilation
  44267. * @param flag defines the flag used to specify which material part must be marked as dirty
  44268. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44269. */
  44270. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44271. /** @hidden */
  44272. _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;
  44273. /** @hidden */
  44274. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44275. /** @hidden */
  44276. _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;
  44277. /** @hidden */
  44278. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44279. /** @hidden */
  44280. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44281. /** @hidden */
  44282. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44283. }
  44284. }
  44285. declare module BABYLON {
  44286. /**
  44287. * Set of assets to keep when moving a scene into an asset container.
  44288. */
  44289. export class KeepAssets extends AbstractScene {
  44290. }
  44291. /**
  44292. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44293. */
  44294. export class InstantiatedEntries {
  44295. /**
  44296. * List of new root nodes (eg. nodes with no parent)
  44297. */
  44298. rootNodes: TransformNode[];
  44299. /**
  44300. * List of new skeletons
  44301. */
  44302. skeletons: Skeleton[];
  44303. /**
  44304. * List of new animation groups
  44305. */
  44306. animationGroups: AnimationGroup[];
  44307. }
  44308. /**
  44309. * Container with a set of assets that can be added or removed from a scene.
  44310. */
  44311. export class AssetContainer extends AbstractScene {
  44312. private _wasAddedToScene;
  44313. /**
  44314. * The scene the AssetContainer belongs to.
  44315. */
  44316. scene: Scene;
  44317. /**
  44318. * Instantiates an AssetContainer.
  44319. * @param scene The scene the AssetContainer belongs to.
  44320. */
  44321. constructor(scene: Scene);
  44322. /**
  44323. * Instantiate or clone all meshes and add the new ones to the scene.
  44324. * Skeletons and animation groups will all be cloned
  44325. * @param nameFunction defines an optional function used to get new names for clones
  44326. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44327. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44328. */
  44329. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44330. /**
  44331. * Adds all the assets from the container to the scene.
  44332. */
  44333. addAllToScene(): void;
  44334. /**
  44335. * Removes all the assets in the container from the scene
  44336. */
  44337. removeAllFromScene(): void;
  44338. /**
  44339. * Disposes all the assets in the container
  44340. */
  44341. dispose(): void;
  44342. private _moveAssets;
  44343. /**
  44344. * Removes all the assets contained in the scene and adds them to the container.
  44345. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44346. */
  44347. moveAllFromScene(keepAssets?: KeepAssets): void;
  44348. /**
  44349. * 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.
  44350. * @returns the root mesh
  44351. */
  44352. createRootMesh(): Mesh;
  44353. /**
  44354. * Merge animations (direct and animation groups) from this asset container into a scene
  44355. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44356. * @param animatables set of animatables to retarget to a node from the scene
  44357. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44358. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44359. */
  44360. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44361. }
  44362. }
  44363. declare module BABYLON {
  44364. /**
  44365. * Defines how the parser contract is defined.
  44366. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44367. */
  44368. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44369. /**
  44370. * Defines how the individual parser contract is defined.
  44371. * These parser can parse an individual asset
  44372. */
  44373. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44374. /**
  44375. * Base class of the scene acting as a container for the different elements composing a scene.
  44376. * This class is dynamically extended by the different components of the scene increasing
  44377. * flexibility and reducing coupling
  44378. */
  44379. export abstract class AbstractScene {
  44380. /**
  44381. * Stores the list of available parsers in the application.
  44382. */
  44383. private static _BabylonFileParsers;
  44384. /**
  44385. * Stores the list of available individual parsers in the application.
  44386. */
  44387. private static _IndividualBabylonFileParsers;
  44388. /**
  44389. * Adds a parser in the list of available ones
  44390. * @param name Defines the name of the parser
  44391. * @param parser Defines the parser to add
  44392. */
  44393. static AddParser(name: string, parser: BabylonFileParser): void;
  44394. /**
  44395. * Gets a general parser from the list of avaialble ones
  44396. * @param name Defines the name of the parser
  44397. * @returns the requested parser or null
  44398. */
  44399. static GetParser(name: string): Nullable<BabylonFileParser>;
  44400. /**
  44401. * Adds n individual parser in the list of available ones
  44402. * @param name Defines the name of the parser
  44403. * @param parser Defines the parser to add
  44404. */
  44405. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44406. /**
  44407. * Gets an individual parser from the list of avaialble ones
  44408. * @param name Defines the name of the parser
  44409. * @returns the requested parser or null
  44410. */
  44411. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44412. /**
  44413. * Parser json data and populate both a scene and its associated container object
  44414. * @param jsonData Defines the data to parse
  44415. * @param scene Defines the scene to parse the data for
  44416. * @param container Defines the container attached to the parsing sequence
  44417. * @param rootUrl Defines the root url of the data
  44418. */
  44419. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44420. /**
  44421. * Gets the list of root nodes (ie. nodes with no parent)
  44422. */
  44423. rootNodes: Node[];
  44424. /** All of the cameras added to this scene
  44425. * @see https://doc.babylonjs.com/babylon101/cameras
  44426. */
  44427. cameras: Camera[];
  44428. /**
  44429. * All of the lights added to this scene
  44430. * @see https://doc.babylonjs.com/babylon101/lights
  44431. */
  44432. lights: Light[];
  44433. /**
  44434. * All of the (abstract) meshes added to this scene
  44435. */
  44436. meshes: AbstractMesh[];
  44437. /**
  44438. * The list of skeletons added to the scene
  44439. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44440. */
  44441. skeletons: Skeleton[];
  44442. /**
  44443. * All of the particle systems added to this scene
  44444. * @see https://doc.babylonjs.com/babylon101/particles
  44445. */
  44446. particleSystems: IParticleSystem[];
  44447. /**
  44448. * Gets a list of Animations associated with the scene
  44449. */
  44450. animations: Animation[];
  44451. /**
  44452. * All of the animation groups added to this scene
  44453. * @see https://doc.babylonjs.com/how_to/group
  44454. */
  44455. animationGroups: AnimationGroup[];
  44456. /**
  44457. * All of the multi-materials added to this scene
  44458. * @see https://doc.babylonjs.com/how_to/multi_materials
  44459. */
  44460. multiMaterials: MultiMaterial[];
  44461. /**
  44462. * All of the materials added to this scene
  44463. * In the context of a Scene, it is not supposed to be modified manually.
  44464. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44465. * Note also that the order of the Material within the array is not significant and might change.
  44466. * @see https://doc.babylonjs.com/babylon101/materials
  44467. */
  44468. materials: Material[];
  44469. /**
  44470. * The list of morph target managers added to the scene
  44471. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44472. */
  44473. morphTargetManagers: MorphTargetManager[];
  44474. /**
  44475. * The list of geometries used in the scene.
  44476. */
  44477. geometries: Geometry[];
  44478. /**
  44479. * All of the tranform nodes added to this scene
  44480. * In the context of a Scene, it is not supposed to be modified manually.
  44481. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44482. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44483. * @see https://doc.babylonjs.com/how_to/transformnode
  44484. */
  44485. transformNodes: TransformNode[];
  44486. /**
  44487. * ActionManagers available on the scene.
  44488. */
  44489. actionManagers: AbstractActionManager[];
  44490. /**
  44491. * Textures to keep.
  44492. */
  44493. textures: BaseTexture[];
  44494. /** @hidden */
  44495. protected _environmentTexture: Nullable<BaseTexture>;
  44496. /**
  44497. * Texture used in all pbr material as the reflection texture.
  44498. * As in the majority of the scene they are the same (exception for multi room and so on),
  44499. * this is easier to reference from here than from all the materials.
  44500. */
  44501. get environmentTexture(): Nullable<BaseTexture>;
  44502. set environmentTexture(value: Nullable<BaseTexture>);
  44503. /**
  44504. * The list of postprocesses added to the scene
  44505. */
  44506. postProcesses: PostProcess[];
  44507. /**
  44508. * @returns all meshes, lights, cameras, transformNodes and bones
  44509. */
  44510. getNodes(): Array<Node>;
  44511. }
  44512. }
  44513. declare module BABYLON {
  44514. /**
  44515. * Interface used to define options for Sound class
  44516. */
  44517. export interface ISoundOptions {
  44518. /**
  44519. * Does the sound autoplay once loaded.
  44520. */
  44521. autoplay?: boolean;
  44522. /**
  44523. * Does the sound loop after it finishes playing once.
  44524. */
  44525. loop?: boolean;
  44526. /**
  44527. * Sound's volume
  44528. */
  44529. volume?: number;
  44530. /**
  44531. * Is it a spatial sound?
  44532. */
  44533. spatialSound?: boolean;
  44534. /**
  44535. * Maximum distance to hear that sound
  44536. */
  44537. maxDistance?: number;
  44538. /**
  44539. * Uses user defined attenuation function
  44540. */
  44541. useCustomAttenuation?: boolean;
  44542. /**
  44543. * Define the roll off factor of spatial sounds.
  44544. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44545. */
  44546. rolloffFactor?: number;
  44547. /**
  44548. * Define the reference distance the sound should be heard perfectly.
  44549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44550. */
  44551. refDistance?: number;
  44552. /**
  44553. * Define the distance attenuation model the sound will follow.
  44554. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44555. */
  44556. distanceModel?: string;
  44557. /**
  44558. * Defines the playback speed (1 by default)
  44559. */
  44560. playbackRate?: number;
  44561. /**
  44562. * Defines if the sound is from a streaming source
  44563. */
  44564. streaming?: boolean;
  44565. /**
  44566. * Defines an optional length (in seconds) inside the sound file
  44567. */
  44568. length?: number;
  44569. /**
  44570. * Defines an optional offset (in seconds) inside the sound file
  44571. */
  44572. offset?: number;
  44573. /**
  44574. * If true, URLs will not be required to state the audio file codec to use.
  44575. */
  44576. skipCodecCheck?: boolean;
  44577. }
  44578. /**
  44579. * Defines a sound that can be played in the application.
  44580. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44581. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44582. */
  44583. export class Sound {
  44584. /**
  44585. * The name of the sound in the scene.
  44586. */
  44587. name: string;
  44588. /**
  44589. * Does the sound autoplay once loaded.
  44590. */
  44591. autoplay: boolean;
  44592. /**
  44593. * Does the sound loop after it finishes playing once.
  44594. */
  44595. loop: boolean;
  44596. /**
  44597. * Does the sound use a custom attenuation curve to simulate the falloff
  44598. * happening when the source gets further away from the camera.
  44599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44600. */
  44601. useCustomAttenuation: boolean;
  44602. /**
  44603. * The sound track id this sound belongs to.
  44604. */
  44605. soundTrackId: number;
  44606. /**
  44607. * Is this sound currently played.
  44608. */
  44609. isPlaying: boolean;
  44610. /**
  44611. * Is this sound currently paused.
  44612. */
  44613. isPaused: boolean;
  44614. /**
  44615. * Does this sound enables spatial sound.
  44616. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44617. */
  44618. spatialSound: boolean;
  44619. /**
  44620. * Define the reference distance the sound should be heard perfectly.
  44621. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44622. */
  44623. refDistance: number;
  44624. /**
  44625. * Define the roll off factor of spatial sounds.
  44626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44627. */
  44628. rolloffFactor: number;
  44629. /**
  44630. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44632. */
  44633. maxDistance: number;
  44634. /**
  44635. * Define the distance attenuation model the sound will follow.
  44636. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44637. */
  44638. distanceModel: string;
  44639. /**
  44640. * @hidden
  44641. * Back Compat
  44642. **/
  44643. onended: () => any;
  44644. /**
  44645. * Gets or sets an object used to store user defined information for the sound.
  44646. */
  44647. metadata: any;
  44648. /**
  44649. * Observable event when the current playing sound finishes.
  44650. */
  44651. onEndedObservable: Observable<Sound>;
  44652. private _panningModel;
  44653. private _playbackRate;
  44654. private _streaming;
  44655. private _startTime;
  44656. private _startOffset;
  44657. private _position;
  44658. /** @hidden */
  44659. _positionInEmitterSpace: boolean;
  44660. private _localDirection;
  44661. private _volume;
  44662. private _isReadyToPlay;
  44663. private _isDirectional;
  44664. private _readyToPlayCallback;
  44665. private _audioBuffer;
  44666. private _soundSource;
  44667. private _streamingSource;
  44668. private _soundPanner;
  44669. private _soundGain;
  44670. private _inputAudioNode;
  44671. private _outputAudioNode;
  44672. private _coneInnerAngle;
  44673. private _coneOuterAngle;
  44674. private _coneOuterGain;
  44675. private _scene;
  44676. private _connectedTransformNode;
  44677. private _customAttenuationFunction;
  44678. private _registerFunc;
  44679. private _isOutputConnected;
  44680. private _htmlAudioElement;
  44681. private _urlType;
  44682. private _length?;
  44683. private _offset?;
  44684. /** @hidden */
  44685. static _SceneComponentInitialization: (scene: Scene) => void;
  44686. /**
  44687. * Create a sound and attach it to a scene
  44688. * @param name Name of your sound
  44689. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44690. * @param scene defines the scene the sound belongs to
  44691. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44692. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44693. */
  44694. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44695. /**
  44696. * Release the sound and its associated resources
  44697. */
  44698. dispose(): void;
  44699. /**
  44700. * Gets if the sounds is ready to be played or not.
  44701. * @returns true if ready, otherwise false
  44702. */
  44703. isReady(): boolean;
  44704. private _soundLoaded;
  44705. /**
  44706. * Sets the data of the sound from an audiobuffer
  44707. * @param audioBuffer The audioBuffer containing the data
  44708. */
  44709. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44710. /**
  44711. * Updates the current sounds options such as maxdistance, loop...
  44712. * @param options A JSON object containing values named as the object properties
  44713. */
  44714. updateOptions(options: ISoundOptions): void;
  44715. private _createSpatialParameters;
  44716. private _updateSpatialParameters;
  44717. /**
  44718. * Switch the panning model to HRTF:
  44719. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44721. */
  44722. switchPanningModelToHRTF(): void;
  44723. /**
  44724. * Switch the panning model to Equal Power:
  44725. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44727. */
  44728. switchPanningModelToEqualPower(): void;
  44729. private _switchPanningModel;
  44730. /**
  44731. * Connect this sound to a sound track audio node like gain...
  44732. * @param soundTrackAudioNode the sound track audio node to connect to
  44733. */
  44734. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44735. /**
  44736. * Transform this sound into a directional source
  44737. * @param coneInnerAngle Size of the inner cone in degree
  44738. * @param coneOuterAngle Size of the outer cone in degree
  44739. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44740. */
  44741. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44742. /**
  44743. * Gets or sets the inner angle for the directional cone.
  44744. */
  44745. get directionalConeInnerAngle(): number;
  44746. /**
  44747. * Gets or sets the inner angle for the directional cone.
  44748. */
  44749. set directionalConeInnerAngle(value: number);
  44750. /**
  44751. * Gets or sets the outer angle for the directional cone.
  44752. */
  44753. get directionalConeOuterAngle(): number;
  44754. /**
  44755. * Gets or sets the outer angle for the directional cone.
  44756. */
  44757. set directionalConeOuterAngle(value: number);
  44758. /**
  44759. * Sets the position of the emitter if spatial sound is enabled
  44760. * @param newPosition Defines the new posisiton
  44761. */
  44762. setPosition(newPosition: Vector3): void;
  44763. /**
  44764. * Sets the local direction of the emitter if spatial sound is enabled
  44765. * @param newLocalDirection Defines the new local direction
  44766. */
  44767. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44768. private _updateDirection;
  44769. /** @hidden */
  44770. updateDistanceFromListener(): void;
  44771. /**
  44772. * Sets a new custom attenuation function for the sound.
  44773. * @param callback Defines the function used for the attenuation
  44774. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44775. */
  44776. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44777. /**
  44778. * Play the sound
  44779. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44780. * @param offset (optional) Start the sound at a specific time in seconds
  44781. * @param length (optional) Sound duration (in seconds)
  44782. */
  44783. play(time?: number, offset?: number, length?: number): void;
  44784. private _onended;
  44785. /**
  44786. * Stop the sound
  44787. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44788. */
  44789. stop(time?: number): void;
  44790. /**
  44791. * Put the sound in pause
  44792. */
  44793. pause(): void;
  44794. /**
  44795. * Sets a dedicated volume for this sounds
  44796. * @param newVolume Define the new volume of the sound
  44797. * @param time Define time for gradual change to new volume
  44798. */
  44799. setVolume(newVolume: number, time?: number): void;
  44800. /**
  44801. * Set the sound play back rate
  44802. * @param newPlaybackRate Define the playback rate the sound should be played at
  44803. */
  44804. setPlaybackRate(newPlaybackRate: number): void;
  44805. /**
  44806. * Gets the volume of the sound.
  44807. * @returns the volume of the sound
  44808. */
  44809. getVolume(): number;
  44810. /**
  44811. * Attach the sound to a dedicated mesh
  44812. * @param transformNode The transform node to connect the sound with
  44813. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44814. */
  44815. attachToMesh(transformNode: TransformNode): void;
  44816. /**
  44817. * Detach the sound from the previously attached mesh
  44818. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44819. */
  44820. detachFromMesh(): void;
  44821. private _onRegisterAfterWorldMatrixUpdate;
  44822. /**
  44823. * Clone the current sound in the scene.
  44824. * @returns the new sound clone
  44825. */
  44826. clone(): Nullable<Sound>;
  44827. /**
  44828. * Gets the current underlying audio buffer containing the data
  44829. * @returns the audio buffer
  44830. */
  44831. getAudioBuffer(): Nullable<AudioBuffer>;
  44832. /**
  44833. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44834. * @returns the source node
  44835. */
  44836. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44837. /**
  44838. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44839. * @returns the gain node
  44840. */
  44841. getSoundGain(): Nullable<GainNode>;
  44842. /**
  44843. * Serializes the Sound in a JSON representation
  44844. * @returns the JSON representation of the sound
  44845. */
  44846. serialize(): any;
  44847. /**
  44848. * Parse a JSON representation of a sound to innstantiate in a given scene
  44849. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44850. * @param scene Define the scene the new parsed sound should be created in
  44851. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44852. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44853. * @returns the newly parsed sound
  44854. */
  44855. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44856. }
  44857. }
  44858. declare module BABYLON {
  44859. /**
  44860. * This defines an action helpful to play a defined sound on a triggered action.
  44861. */
  44862. export class PlaySoundAction extends Action {
  44863. private _sound;
  44864. /**
  44865. * Instantiate the action
  44866. * @param triggerOptions defines the trigger options
  44867. * @param sound defines the sound to play
  44868. * @param condition defines the trigger related conditions
  44869. */
  44870. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44871. /** @hidden */
  44872. _prepare(): void;
  44873. /**
  44874. * Execute the action and play the sound.
  44875. */
  44876. execute(): void;
  44877. /**
  44878. * Serializes the actions and its related information.
  44879. * @param parent defines the object to serialize in
  44880. * @returns the serialized object
  44881. */
  44882. serialize(parent: any): any;
  44883. }
  44884. /**
  44885. * This defines an action helpful to stop a defined sound on a triggered action.
  44886. */
  44887. export class StopSoundAction extends Action {
  44888. private _sound;
  44889. /**
  44890. * Instantiate the action
  44891. * @param triggerOptions defines the trigger options
  44892. * @param sound defines the sound to stop
  44893. * @param condition defines the trigger related conditions
  44894. */
  44895. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44896. /** @hidden */
  44897. _prepare(): void;
  44898. /**
  44899. * Execute the action and stop the sound.
  44900. */
  44901. execute(): void;
  44902. /**
  44903. * Serializes the actions and its related information.
  44904. * @param parent defines the object to serialize in
  44905. * @returns the serialized object
  44906. */
  44907. serialize(parent: any): any;
  44908. }
  44909. }
  44910. declare module BABYLON {
  44911. /**
  44912. * This defines an action responsible to change the value of a property
  44913. * by interpolating between its current value and the newly set one once triggered.
  44914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44915. */
  44916. export class InterpolateValueAction extends Action {
  44917. /**
  44918. * Defines the path of the property where the value should be interpolated
  44919. */
  44920. propertyPath: string;
  44921. /**
  44922. * Defines the target value at the end of the interpolation.
  44923. */
  44924. value: any;
  44925. /**
  44926. * Defines the time it will take for the property to interpolate to the value.
  44927. */
  44928. duration: number;
  44929. /**
  44930. * Defines if the other scene animations should be stopped when the action has been triggered
  44931. */
  44932. stopOtherAnimations?: boolean;
  44933. /**
  44934. * Defines a callback raised once the interpolation animation has been done.
  44935. */
  44936. onInterpolationDone?: () => void;
  44937. /**
  44938. * Observable triggered once the interpolation animation has been done.
  44939. */
  44940. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44941. private _target;
  44942. private _effectiveTarget;
  44943. private _property;
  44944. /**
  44945. * Instantiate the action
  44946. * @param triggerOptions defines the trigger options
  44947. * @param target defines the object containing the value to interpolate
  44948. * @param propertyPath defines the path to the property in the target object
  44949. * @param value defines the target value at the end of the interpolation
  44950. * @param duration deines the time it will take for the property to interpolate to the value.
  44951. * @param condition defines the trigger related conditions
  44952. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44953. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44954. */
  44955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44956. /** @hidden */
  44957. _prepare(): void;
  44958. /**
  44959. * Execute the action starts the value interpolation.
  44960. */
  44961. execute(): void;
  44962. /**
  44963. * Serializes the actions and its related information.
  44964. * @param parent defines the object to serialize in
  44965. * @returns the serialized object
  44966. */
  44967. serialize(parent: any): any;
  44968. }
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * Options allowed during the creation of a sound track.
  44973. */
  44974. export interface ISoundTrackOptions {
  44975. /**
  44976. * The volume the sound track should take during creation
  44977. */
  44978. volume?: number;
  44979. /**
  44980. * Define if the sound track is the main sound track of the scene
  44981. */
  44982. mainTrack?: boolean;
  44983. }
  44984. /**
  44985. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44986. * It will be also used in a future release to apply effects on a specific track.
  44987. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44988. */
  44989. export class SoundTrack {
  44990. /**
  44991. * The unique identifier of the sound track in the scene.
  44992. */
  44993. id: number;
  44994. /**
  44995. * The list of sounds included in the sound track.
  44996. */
  44997. soundCollection: Array<Sound>;
  44998. private _outputAudioNode;
  44999. private _scene;
  45000. private _connectedAnalyser;
  45001. private _options;
  45002. private _isInitialized;
  45003. /**
  45004. * Creates a new sound track.
  45005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45006. * @param scene Define the scene the sound track belongs to
  45007. * @param options
  45008. */
  45009. constructor(scene: Scene, options?: ISoundTrackOptions);
  45010. private _initializeSoundTrackAudioGraph;
  45011. /**
  45012. * Release the sound track and its associated resources
  45013. */
  45014. dispose(): void;
  45015. /**
  45016. * Adds a sound to this sound track
  45017. * @param sound define the cound to add
  45018. * @ignoreNaming
  45019. */
  45020. AddSound(sound: Sound): void;
  45021. /**
  45022. * Removes a sound to this sound track
  45023. * @param sound define the cound to remove
  45024. * @ignoreNaming
  45025. */
  45026. RemoveSound(sound: Sound): void;
  45027. /**
  45028. * Set a global volume for the full sound track.
  45029. * @param newVolume Define the new volume of the sound track
  45030. */
  45031. setVolume(newVolume: number): void;
  45032. /**
  45033. * Switch the panning model to HRTF:
  45034. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45035. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45036. */
  45037. switchPanningModelToHRTF(): void;
  45038. /**
  45039. * Switch the panning model to Equal Power:
  45040. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45041. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45042. */
  45043. switchPanningModelToEqualPower(): void;
  45044. /**
  45045. * Connect the sound track to an audio analyser allowing some amazing
  45046. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45048. * @param analyser The analyser to connect to the engine
  45049. */
  45050. connectToAnalyser(analyser: Analyser): void;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. interface AbstractScene {
  45055. /**
  45056. * The list of sounds used in the scene.
  45057. */
  45058. sounds: Nullable<Array<Sound>>;
  45059. }
  45060. interface Scene {
  45061. /**
  45062. * @hidden
  45063. * Backing field
  45064. */
  45065. _mainSoundTrack: SoundTrack;
  45066. /**
  45067. * The main sound track played by the scene.
  45068. * It cotains your primary collection of sounds.
  45069. */
  45070. mainSoundTrack: SoundTrack;
  45071. /**
  45072. * The list of sound tracks added to the scene
  45073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45074. */
  45075. soundTracks: Nullable<Array<SoundTrack>>;
  45076. /**
  45077. * Gets a sound using a given name
  45078. * @param name defines the name to search for
  45079. * @return the found sound or null if not found at all.
  45080. */
  45081. getSoundByName(name: string): Nullable<Sound>;
  45082. /**
  45083. * Gets or sets if audio support is enabled
  45084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45085. */
  45086. audioEnabled: boolean;
  45087. /**
  45088. * Gets or sets if audio will be output to headphones
  45089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45090. */
  45091. headphone: boolean;
  45092. /**
  45093. * Gets or sets custom audio listener position provider
  45094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45095. */
  45096. audioListenerPositionProvider: Nullable<() => Vector3>;
  45097. /**
  45098. * Gets or sets a refresh rate when using 3D audio positioning
  45099. */
  45100. audioPositioningRefreshRate: number;
  45101. }
  45102. /**
  45103. * Defines the sound scene component responsible to manage any sounds
  45104. * in a given scene.
  45105. */
  45106. export class AudioSceneComponent implements ISceneSerializableComponent {
  45107. private static _CameraDirectionLH;
  45108. private static _CameraDirectionRH;
  45109. /**
  45110. * The component name helpfull to identify the component in the list of scene components.
  45111. */
  45112. readonly name: string;
  45113. /**
  45114. * The scene the component belongs to.
  45115. */
  45116. scene: Scene;
  45117. private _audioEnabled;
  45118. /**
  45119. * Gets whether audio is enabled or not.
  45120. * Please use related enable/disable method to switch state.
  45121. */
  45122. get audioEnabled(): boolean;
  45123. private _headphone;
  45124. /**
  45125. * Gets whether audio is outputing to headphone or not.
  45126. * Please use the according Switch methods to change output.
  45127. */
  45128. get headphone(): boolean;
  45129. /**
  45130. * Gets or sets a refresh rate when using 3D audio positioning
  45131. */
  45132. audioPositioningRefreshRate: number;
  45133. private _audioListenerPositionProvider;
  45134. /**
  45135. * Gets the current audio listener position provider
  45136. */
  45137. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45138. /**
  45139. * Sets a custom listener position for all sounds in the scene
  45140. * By default, this is the position of the first active camera
  45141. */
  45142. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45143. /**
  45144. * Creates a new instance of the component for the given scene
  45145. * @param scene Defines the scene to register the component in
  45146. */
  45147. constructor(scene: Scene);
  45148. /**
  45149. * Registers the component in a given scene
  45150. */
  45151. register(): void;
  45152. /**
  45153. * Rebuilds the elements related to this component in case of
  45154. * context lost for instance.
  45155. */
  45156. rebuild(): void;
  45157. /**
  45158. * Serializes the component data to the specified json object
  45159. * @param serializationObject The object to serialize to
  45160. */
  45161. serialize(serializationObject: any): void;
  45162. /**
  45163. * Adds all the elements from the container to the scene
  45164. * @param container the container holding the elements
  45165. */
  45166. addFromContainer(container: AbstractScene): void;
  45167. /**
  45168. * Removes all the elements in the container from the scene
  45169. * @param container contains the elements to remove
  45170. * @param dispose if the removed element should be disposed (default: false)
  45171. */
  45172. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45173. /**
  45174. * Disposes the component and the associated ressources.
  45175. */
  45176. dispose(): void;
  45177. /**
  45178. * Disables audio in the associated scene.
  45179. */
  45180. disableAudio(): void;
  45181. /**
  45182. * Enables audio in the associated scene.
  45183. */
  45184. enableAudio(): void;
  45185. /**
  45186. * Switch audio to headphone output.
  45187. */
  45188. switchAudioModeForHeadphones(): void;
  45189. /**
  45190. * Switch audio to normal speakers.
  45191. */
  45192. switchAudioModeForNormalSpeakers(): void;
  45193. private _cachedCameraDirection;
  45194. private _cachedCameraPosition;
  45195. private _lastCheck;
  45196. private _afterRender;
  45197. }
  45198. }
  45199. declare module BABYLON {
  45200. /**
  45201. * Wraps one or more Sound objects and selects one with random weight for playback.
  45202. */
  45203. export class WeightedSound {
  45204. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45205. loop: boolean;
  45206. private _coneInnerAngle;
  45207. private _coneOuterAngle;
  45208. private _volume;
  45209. /** A Sound is currently playing. */
  45210. isPlaying: boolean;
  45211. /** A Sound is currently paused. */
  45212. isPaused: boolean;
  45213. private _sounds;
  45214. private _weights;
  45215. private _currentIndex?;
  45216. /**
  45217. * Creates a new WeightedSound from the list of sounds given.
  45218. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45219. * @param sounds Array of Sounds that will be selected from.
  45220. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45221. */
  45222. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45223. /**
  45224. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45225. */
  45226. get directionalConeInnerAngle(): number;
  45227. /**
  45228. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45229. */
  45230. set directionalConeInnerAngle(value: number);
  45231. /**
  45232. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45233. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45234. */
  45235. get directionalConeOuterAngle(): number;
  45236. /**
  45237. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45238. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45239. */
  45240. set directionalConeOuterAngle(value: number);
  45241. /**
  45242. * Playback volume.
  45243. */
  45244. get volume(): number;
  45245. /**
  45246. * Playback volume.
  45247. */
  45248. set volume(value: number);
  45249. private _onended;
  45250. /**
  45251. * Suspend playback
  45252. */
  45253. pause(): void;
  45254. /**
  45255. * Stop playback
  45256. */
  45257. stop(): void;
  45258. /**
  45259. * Start playback.
  45260. * @param startOffset Position the clip head at a specific time in seconds.
  45261. */
  45262. play(startOffset?: number): void;
  45263. }
  45264. }
  45265. declare module BABYLON {
  45266. /**
  45267. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45268. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45269. */
  45270. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45271. /**
  45272. * Gets the name of the behavior.
  45273. */
  45274. get name(): string;
  45275. /**
  45276. * The easing function used by animations
  45277. */
  45278. static EasingFunction: BackEase;
  45279. /**
  45280. * The easing mode used by animations
  45281. */
  45282. static EasingMode: number;
  45283. /**
  45284. * The duration of the animation, in milliseconds
  45285. */
  45286. transitionDuration: number;
  45287. /**
  45288. * Length of the distance animated by the transition when lower radius is reached
  45289. */
  45290. lowerRadiusTransitionRange: number;
  45291. /**
  45292. * Length of the distance animated by the transition when upper radius is reached
  45293. */
  45294. upperRadiusTransitionRange: number;
  45295. private _autoTransitionRange;
  45296. /**
  45297. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45298. */
  45299. get autoTransitionRange(): boolean;
  45300. /**
  45301. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45302. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45303. */
  45304. set autoTransitionRange(value: boolean);
  45305. private _attachedCamera;
  45306. private _onAfterCheckInputsObserver;
  45307. private _onMeshTargetChangedObserver;
  45308. /**
  45309. * Initializes the behavior.
  45310. */
  45311. init(): void;
  45312. /**
  45313. * Attaches the behavior to its arc rotate camera.
  45314. * @param camera Defines the camera to attach the behavior to
  45315. */
  45316. attach(camera: ArcRotateCamera): void;
  45317. /**
  45318. * Detaches the behavior from its current arc rotate camera.
  45319. */
  45320. detach(): void;
  45321. private _radiusIsAnimating;
  45322. private _radiusBounceTransition;
  45323. private _animatables;
  45324. private _cachedWheelPrecision;
  45325. /**
  45326. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45327. * @param radiusLimit The limit to check against.
  45328. * @return Bool to indicate if at limit.
  45329. */
  45330. private _isRadiusAtLimit;
  45331. /**
  45332. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45333. * @param radiusDelta The delta by which to animate to. Can be negative.
  45334. */
  45335. private _applyBoundRadiusAnimation;
  45336. /**
  45337. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45338. */
  45339. protected _clearAnimationLocks(): void;
  45340. /**
  45341. * Stops and removes all animations that have been applied to the camera
  45342. */
  45343. stopAllAnimations(): void;
  45344. }
  45345. }
  45346. declare module BABYLON {
  45347. /**
  45348. * 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.
  45349. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45350. */
  45351. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45352. /**
  45353. * Gets the name of the behavior.
  45354. */
  45355. get name(): string;
  45356. private _mode;
  45357. private _radiusScale;
  45358. private _positionScale;
  45359. private _defaultElevation;
  45360. private _elevationReturnTime;
  45361. private _elevationReturnWaitTime;
  45362. private _zoomStopsAnimation;
  45363. private _framingTime;
  45364. /**
  45365. * The easing function used by animations
  45366. */
  45367. static EasingFunction: ExponentialEase;
  45368. /**
  45369. * The easing mode used by animations
  45370. */
  45371. static EasingMode: number;
  45372. /**
  45373. * Sets the current mode used by the behavior
  45374. */
  45375. set mode(mode: number);
  45376. /**
  45377. * Gets current mode used by the behavior.
  45378. */
  45379. get mode(): number;
  45380. /**
  45381. * Sets the scale applied to the radius (1 by default)
  45382. */
  45383. set radiusScale(radius: number);
  45384. /**
  45385. * Gets the scale applied to the radius
  45386. */
  45387. get radiusScale(): number;
  45388. /**
  45389. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45390. */
  45391. set positionScale(scale: number);
  45392. /**
  45393. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45394. */
  45395. get positionScale(): number;
  45396. /**
  45397. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45398. * behaviour is triggered, in radians.
  45399. */
  45400. set defaultElevation(elevation: number);
  45401. /**
  45402. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45403. * behaviour is triggered, in radians.
  45404. */
  45405. get defaultElevation(): number;
  45406. /**
  45407. * Sets the time (in milliseconds) taken to return to the default beta position.
  45408. * Negative value indicates camera should not return to default.
  45409. */
  45410. set elevationReturnTime(speed: number);
  45411. /**
  45412. * Gets the time (in milliseconds) taken to return to the default beta position.
  45413. * Negative value indicates camera should not return to default.
  45414. */
  45415. get elevationReturnTime(): number;
  45416. /**
  45417. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45418. */
  45419. set elevationReturnWaitTime(time: number);
  45420. /**
  45421. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45422. */
  45423. get elevationReturnWaitTime(): number;
  45424. /**
  45425. * Sets the flag that indicates if user zooming should stop animation.
  45426. */
  45427. set zoomStopsAnimation(flag: boolean);
  45428. /**
  45429. * Gets the flag that indicates if user zooming should stop animation.
  45430. */
  45431. get zoomStopsAnimation(): boolean;
  45432. /**
  45433. * Sets the transition time when framing the mesh, in milliseconds
  45434. */
  45435. set framingTime(time: number);
  45436. /**
  45437. * Gets the transition time when framing the mesh, in milliseconds
  45438. */
  45439. get framingTime(): number;
  45440. /**
  45441. * Define if the behavior should automatically change the configured
  45442. * camera limits and sensibilities.
  45443. */
  45444. autoCorrectCameraLimitsAndSensibility: boolean;
  45445. private _onPrePointerObservableObserver;
  45446. private _onAfterCheckInputsObserver;
  45447. private _onMeshTargetChangedObserver;
  45448. private _attachedCamera;
  45449. private _isPointerDown;
  45450. private _lastInteractionTime;
  45451. /**
  45452. * Initializes the behavior.
  45453. */
  45454. init(): void;
  45455. /**
  45456. * Attaches the behavior to its arc rotate camera.
  45457. * @param camera Defines the camera to attach the behavior to
  45458. */
  45459. attach(camera: ArcRotateCamera): void;
  45460. /**
  45461. * Detaches the behavior from its current arc rotate camera.
  45462. */
  45463. detach(): void;
  45464. private _animatables;
  45465. private _betaIsAnimating;
  45466. private _betaTransition;
  45467. private _radiusTransition;
  45468. private _vectorTransition;
  45469. /**
  45470. * Targets the given mesh and updates zoom level accordingly.
  45471. * @param mesh The mesh to target.
  45472. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45473. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45474. */
  45475. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45476. /**
  45477. * Targets the given mesh with its children and updates zoom level accordingly.
  45478. * @param mesh The mesh to target.
  45479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45481. */
  45482. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45483. /**
  45484. * Targets the given meshes with their children and updates zoom level accordingly.
  45485. * @param meshes The mesh to target.
  45486. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45487. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45488. */
  45489. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45490. /**
  45491. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45492. * @param minimumWorld Determines the smaller position of the bounding box extend
  45493. * @param maximumWorld Determines the bigger position of the bounding box extend
  45494. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45495. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45496. */
  45497. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45498. /**
  45499. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45500. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45501. * frustum width.
  45502. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45503. * to fully enclose the mesh in the viewing frustum.
  45504. */
  45505. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45506. /**
  45507. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45508. * is automatically returned to its default position (expected to be above ground plane).
  45509. */
  45510. private _maintainCameraAboveGround;
  45511. /**
  45512. * Returns the frustum slope based on the canvas ratio and camera FOV
  45513. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45514. */
  45515. private _getFrustumSlope;
  45516. /**
  45517. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45518. */
  45519. private _clearAnimationLocks;
  45520. /**
  45521. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45522. */
  45523. private _applyUserInteraction;
  45524. /**
  45525. * Stops and removes all animations that have been applied to the camera
  45526. */
  45527. stopAllAnimations(): void;
  45528. /**
  45529. * Gets a value indicating if the user is moving the camera
  45530. */
  45531. get isUserIsMoving(): boolean;
  45532. /**
  45533. * The camera can move all the way towards the mesh.
  45534. */
  45535. static IgnoreBoundsSizeMode: number;
  45536. /**
  45537. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45538. */
  45539. static FitFrustumSidesMode: number;
  45540. }
  45541. }
  45542. declare module BABYLON {
  45543. /**
  45544. * Base class for Camera Pointer Inputs.
  45545. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45546. * for example usage.
  45547. */
  45548. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45549. /**
  45550. * Defines the camera the input is attached to.
  45551. */
  45552. abstract camera: Camera;
  45553. /**
  45554. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45555. */
  45556. protected _altKey: boolean;
  45557. protected _ctrlKey: boolean;
  45558. protected _metaKey: boolean;
  45559. protected _shiftKey: boolean;
  45560. /**
  45561. * Which mouse buttons were pressed at time of last mouse event.
  45562. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45563. */
  45564. protected _buttonsPressed: number;
  45565. /**
  45566. * Defines the buttons associated with the input to handle camera move.
  45567. */
  45568. buttons: number[];
  45569. /**
  45570. * Attach the input controls to a specific dom element to get the input from.
  45571. * @param element Defines the element the controls should be listened from
  45572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45573. */
  45574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45575. /**
  45576. * Detach the current controls from the specified dom element.
  45577. * @param element Defines the element to stop listening the inputs from
  45578. */
  45579. detachControl(element: Nullable<HTMLElement>): void;
  45580. /**
  45581. * Gets the class name of the current input.
  45582. * @returns the class name
  45583. */
  45584. getClassName(): string;
  45585. /**
  45586. * Get the friendly name associated with the input class.
  45587. * @returns the input friendly name
  45588. */
  45589. getSimpleName(): string;
  45590. /**
  45591. * Called on pointer POINTERDOUBLETAP event.
  45592. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45593. */
  45594. protected onDoubleTap(type: string): void;
  45595. /**
  45596. * Called on pointer POINTERMOVE event if only a single touch is active.
  45597. * Override this method to provide functionality.
  45598. */
  45599. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45600. /**
  45601. * Called on pointer POINTERMOVE event if multiple touches are active.
  45602. * Override this method to provide functionality.
  45603. */
  45604. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45605. /**
  45606. * Called on JS contextmenu event.
  45607. * Override this method to provide functionality.
  45608. */
  45609. protected onContextMenu(evt: PointerEvent): void;
  45610. /**
  45611. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45612. * press.
  45613. * Override this method to provide functionality.
  45614. */
  45615. protected onButtonDown(evt: PointerEvent): void;
  45616. /**
  45617. * Called each time a new POINTERUP event occurs. Ie, for each button
  45618. * release.
  45619. * Override this method to provide functionality.
  45620. */
  45621. protected onButtonUp(evt: PointerEvent): void;
  45622. /**
  45623. * Called when window becomes inactive.
  45624. * Override this method to provide functionality.
  45625. */
  45626. protected onLostFocus(): void;
  45627. private _pointerInput;
  45628. private _observer;
  45629. private _onLostFocus;
  45630. private pointA;
  45631. private pointB;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /**
  45636. * Manage the pointers inputs to control an arc rotate camera.
  45637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45638. */
  45639. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45640. /**
  45641. * Defines the camera the input is attached to.
  45642. */
  45643. camera: ArcRotateCamera;
  45644. /**
  45645. * Gets the class name of the current input.
  45646. * @returns the class name
  45647. */
  45648. getClassName(): string;
  45649. /**
  45650. * Defines the buttons associated with the input to handle camera move.
  45651. */
  45652. buttons: number[];
  45653. /**
  45654. * Defines the pointer angular sensibility along the X axis or how fast is
  45655. * the camera rotating.
  45656. */
  45657. angularSensibilityX: number;
  45658. /**
  45659. * Defines the pointer angular sensibility along the Y axis or how fast is
  45660. * the camera rotating.
  45661. */
  45662. angularSensibilityY: number;
  45663. /**
  45664. * Defines the pointer pinch precision or how fast is the camera zooming.
  45665. */
  45666. pinchPrecision: number;
  45667. /**
  45668. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45669. * from 0.
  45670. * It defines the percentage of current camera.radius to use as delta when
  45671. * pinch zoom is used.
  45672. */
  45673. pinchDeltaPercentage: number;
  45674. /**
  45675. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45676. * that any object in the plane at the camera's target point will scale
  45677. * perfectly with finger motion.
  45678. * Overrides pinchDeltaPercentage and pinchPrecision.
  45679. */
  45680. useNaturalPinchZoom: boolean;
  45681. /**
  45682. * Defines the pointer panning sensibility or how fast is the camera moving.
  45683. */
  45684. panningSensibility: number;
  45685. /**
  45686. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45687. */
  45688. multiTouchPanning: boolean;
  45689. /**
  45690. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45691. * zoom (pinch) through multitouch.
  45692. */
  45693. multiTouchPanAndZoom: boolean;
  45694. /**
  45695. * Revers pinch action direction.
  45696. */
  45697. pinchInwards: boolean;
  45698. private _isPanClick;
  45699. private _twoFingerActivityCount;
  45700. private _isPinching;
  45701. /**
  45702. * Called on pointer POINTERMOVE event if only a single touch is active.
  45703. */
  45704. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45705. /**
  45706. * Called on pointer POINTERDOUBLETAP event.
  45707. */
  45708. protected onDoubleTap(type: string): void;
  45709. /**
  45710. * Called on pointer POINTERMOVE event if multiple touches are active.
  45711. */
  45712. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45713. /**
  45714. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45715. * press.
  45716. */
  45717. protected onButtonDown(evt: PointerEvent): void;
  45718. /**
  45719. * Called each time a new POINTERUP event occurs. Ie, for each button
  45720. * release.
  45721. */
  45722. protected onButtonUp(evt: PointerEvent): void;
  45723. /**
  45724. * Called when window becomes inactive.
  45725. */
  45726. protected onLostFocus(): void;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /**
  45731. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45733. */
  45734. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45735. /**
  45736. * Defines the camera the input is attached to.
  45737. */
  45738. camera: ArcRotateCamera;
  45739. /**
  45740. * Defines the list of key codes associated with the up action (increase alpha)
  45741. */
  45742. keysUp: number[];
  45743. /**
  45744. * Defines the list of key codes associated with the down action (decrease alpha)
  45745. */
  45746. keysDown: number[];
  45747. /**
  45748. * Defines the list of key codes associated with the left action (increase beta)
  45749. */
  45750. keysLeft: number[];
  45751. /**
  45752. * Defines the list of key codes associated with the right action (decrease beta)
  45753. */
  45754. keysRight: number[];
  45755. /**
  45756. * Defines the list of key codes associated with the reset action.
  45757. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45758. */
  45759. keysReset: number[];
  45760. /**
  45761. * Defines the panning sensibility of the inputs.
  45762. * (How fast is the camera panning)
  45763. */
  45764. panningSensibility: number;
  45765. /**
  45766. * Defines the zooming sensibility of the inputs.
  45767. * (How fast is the camera zooming)
  45768. */
  45769. zoomingSensibility: number;
  45770. /**
  45771. * Defines whether maintaining the alt key down switch the movement mode from
  45772. * orientation to zoom.
  45773. */
  45774. useAltToZoom: boolean;
  45775. /**
  45776. * Rotation speed of the camera
  45777. */
  45778. angularSpeed: number;
  45779. private _keys;
  45780. private _ctrlPressed;
  45781. private _altPressed;
  45782. private _onCanvasBlurObserver;
  45783. private _onKeyboardObserver;
  45784. private _engine;
  45785. private _scene;
  45786. /**
  45787. * Attach the input controls to a specific dom element to get the input from.
  45788. * @param element Defines the element the controls should be listened from
  45789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45790. */
  45791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45792. /**
  45793. * Detach the current controls from the specified dom element.
  45794. * @param element Defines the element to stop listening the inputs from
  45795. */
  45796. detachControl(element: Nullable<HTMLElement>): void;
  45797. /**
  45798. * Update the current camera state depending on the inputs that have been used this frame.
  45799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45800. */
  45801. checkInputs(): void;
  45802. /**
  45803. * Gets the class name of the current intput.
  45804. * @returns the class name
  45805. */
  45806. getClassName(): string;
  45807. /**
  45808. * Get the friendly name associated with the input class.
  45809. * @returns the input friendly name
  45810. */
  45811. getSimpleName(): string;
  45812. }
  45813. }
  45814. declare module BABYLON {
  45815. /**
  45816. * Manage the mouse wheel inputs to control an arc rotate camera.
  45817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45818. */
  45819. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45820. /**
  45821. * Defines the camera the input is attached to.
  45822. */
  45823. camera: ArcRotateCamera;
  45824. /**
  45825. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45826. */
  45827. wheelPrecision: number;
  45828. /**
  45829. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45830. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45831. */
  45832. wheelDeltaPercentage: number;
  45833. private _wheel;
  45834. private _observer;
  45835. private computeDeltaFromMouseWheelLegacyEvent;
  45836. /**
  45837. * Attach the input controls to a specific dom element to get the input from.
  45838. * @param element Defines the element the controls should be listened from
  45839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45840. */
  45841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45842. /**
  45843. * Detach the current controls from the specified dom element.
  45844. * @param element Defines the element to stop listening the inputs from
  45845. */
  45846. detachControl(element: Nullable<HTMLElement>): void;
  45847. /**
  45848. * Gets the class name of the current intput.
  45849. * @returns the class name
  45850. */
  45851. getClassName(): string;
  45852. /**
  45853. * Get the friendly name associated with the input class.
  45854. * @returns the input friendly name
  45855. */
  45856. getSimpleName(): string;
  45857. }
  45858. }
  45859. declare module BABYLON {
  45860. /**
  45861. * Default Inputs manager for the ArcRotateCamera.
  45862. * It groups all the default supported inputs for ease of use.
  45863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45864. */
  45865. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45866. /**
  45867. * Instantiates a new ArcRotateCameraInputsManager.
  45868. * @param camera Defines the camera the inputs belong to
  45869. */
  45870. constructor(camera: ArcRotateCamera);
  45871. /**
  45872. * Add mouse wheel input support to the input manager.
  45873. * @returns the current input manager
  45874. */
  45875. addMouseWheel(): ArcRotateCameraInputsManager;
  45876. /**
  45877. * Add pointers input support to the input manager.
  45878. * @returns the current input manager
  45879. */
  45880. addPointers(): ArcRotateCameraInputsManager;
  45881. /**
  45882. * Add keyboard input support to the input manager.
  45883. * @returns the current input manager
  45884. */
  45885. addKeyboard(): ArcRotateCameraInputsManager;
  45886. }
  45887. }
  45888. declare module BABYLON {
  45889. /**
  45890. * This represents an orbital type of camera.
  45891. *
  45892. * 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.
  45893. * 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.
  45894. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45895. */
  45896. export class ArcRotateCamera extends TargetCamera {
  45897. /**
  45898. * Defines the rotation angle of the camera along the longitudinal axis.
  45899. */
  45900. alpha: number;
  45901. /**
  45902. * Defines the rotation angle of the camera along the latitudinal axis.
  45903. */
  45904. beta: number;
  45905. /**
  45906. * Defines the radius of the camera from it s target point.
  45907. */
  45908. radius: number;
  45909. protected _target: Vector3;
  45910. protected _targetHost: Nullable<AbstractMesh>;
  45911. /**
  45912. * Defines the target point of the camera.
  45913. * The camera looks towards it form the radius distance.
  45914. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45915. */
  45916. get target(): Vector3;
  45917. set target(value: Vector3);
  45918. /**
  45919. * Define the current local position of the camera in the scene
  45920. */
  45921. get position(): Vector3;
  45922. set position(newPosition: Vector3);
  45923. protected _upToYMatrix: Matrix;
  45924. protected _YToUpMatrix: Matrix;
  45925. /**
  45926. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45927. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45928. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45929. */
  45930. set upVector(vec: Vector3);
  45931. get upVector(): Vector3;
  45932. /**
  45933. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45934. */
  45935. setMatUp(): void;
  45936. /**
  45937. * Current inertia value on the longitudinal axis.
  45938. * The bigger this number the longer it will take for the camera to stop.
  45939. */
  45940. inertialAlphaOffset: number;
  45941. /**
  45942. * Current inertia value on the latitudinal axis.
  45943. * The bigger this number the longer it will take for the camera to stop.
  45944. */
  45945. inertialBetaOffset: number;
  45946. /**
  45947. * Current inertia value on the radius axis.
  45948. * The bigger this number the longer it will take for the camera to stop.
  45949. */
  45950. inertialRadiusOffset: number;
  45951. /**
  45952. * Minimum allowed angle on the longitudinal axis.
  45953. * This can help limiting how the Camera is able to move in the scene.
  45954. */
  45955. lowerAlphaLimit: Nullable<number>;
  45956. /**
  45957. * Maximum allowed angle on the longitudinal axis.
  45958. * This can help limiting how the Camera is able to move in the scene.
  45959. */
  45960. upperAlphaLimit: Nullable<number>;
  45961. /**
  45962. * Minimum allowed angle on the latitudinal axis.
  45963. * This can help limiting how the Camera is able to move in the scene.
  45964. */
  45965. lowerBetaLimit: number;
  45966. /**
  45967. * Maximum allowed angle on the latitudinal axis.
  45968. * This can help limiting how the Camera is able to move in the scene.
  45969. */
  45970. upperBetaLimit: number;
  45971. /**
  45972. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45973. * This can help limiting how the Camera is able to move in the scene.
  45974. */
  45975. lowerRadiusLimit: Nullable<number>;
  45976. /**
  45977. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45978. * This can help limiting how the Camera is able to move in the scene.
  45979. */
  45980. upperRadiusLimit: Nullable<number>;
  45981. /**
  45982. * Defines the current inertia value used during panning of the camera along the X axis.
  45983. */
  45984. inertialPanningX: number;
  45985. /**
  45986. * Defines the current inertia value used during panning of the camera along the Y axis.
  45987. */
  45988. inertialPanningY: number;
  45989. /**
  45990. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  45991. * Basically if your fingers moves away from more than this distance you will be considered
  45992. * in pinch mode.
  45993. */
  45994. pinchToPanMaxDistance: number;
  45995. /**
  45996. * Defines the maximum distance the camera can pan.
  45997. * This could help keeping the cammera always in your scene.
  45998. */
  45999. panningDistanceLimit: Nullable<number>;
  46000. /**
  46001. * Defines the target of the camera before paning.
  46002. */
  46003. panningOriginTarget: Vector3;
  46004. /**
  46005. * Defines the value of the inertia used during panning.
  46006. * 0 would mean stop inertia and one would mean no decelleration at all.
  46007. */
  46008. panningInertia: number;
  46009. /**
  46010. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46011. */
  46012. get angularSensibilityX(): number;
  46013. set angularSensibilityX(value: number);
  46014. /**
  46015. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46016. */
  46017. get angularSensibilityY(): number;
  46018. set angularSensibilityY(value: number);
  46019. /**
  46020. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46021. */
  46022. get pinchPrecision(): number;
  46023. set pinchPrecision(value: number);
  46024. /**
  46025. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46026. * It will be used instead of pinchDeltaPrecision if different from 0.
  46027. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46028. */
  46029. get pinchDeltaPercentage(): number;
  46030. set pinchDeltaPercentage(value: number);
  46031. /**
  46032. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46033. * and pinch delta percentage.
  46034. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46035. * that any object in the plane at the camera's target point will scale
  46036. * perfectly with finger motion.
  46037. */
  46038. get useNaturalPinchZoom(): boolean;
  46039. set useNaturalPinchZoom(value: boolean);
  46040. /**
  46041. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46042. */
  46043. get panningSensibility(): number;
  46044. set panningSensibility(value: number);
  46045. /**
  46046. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46047. */
  46048. get keysUp(): number[];
  46049. set keysUp(value: number[]);
  46050. /**
  46051. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46052. */
  46053. get keysDown(): number[];
  46054. set keysDown(value: number[]);
  46055. /**
  46056. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46057. */
  46058. get keysLeft(): number[];
  46059. set keysLeft(value: number[]);
  46060. /**
  46061. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46062. */
  46063. get keysRight(): number[];
  46064. set keysRight(value: number[]);
  46065. /**
  46066. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46067. */
  46068. get wheelPrecision(): number;
  46069. set wheelPrecision(value: number);
  46070. /**
  46071. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46072. * It will be used instead of pinchDeltaPrecision if different from 0.
  46073. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46074. */
  46075. get wheelDeltaPercentage(): number;
  46076. set wheelDeltaPercentage(value: number);
  46077. /**
  46078. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46079. */
  46080. zoomOnFactor: number;
  46081. /**
  46082. * Defines a screen offset for the camera position.
  46083. */
  46084. targetScreenOffset: Vector2;
  46085. /**
  46086. * Allows the camera to be completely reversed.
  46087. * If false the camera can not arrive upside down.
  46088. */
  46089. allowUpsideDown: boolean;
  46090. /**
  46091. * Define if double tap/click is used to restore the previously saved state of the camera.
  46092. */
  46093. useInputToRestoreState: boolean;
  46094. /** @hidden */
  46095. _viewMatrix: Matrix;
  46096. /** @hidden */
  46097. _useCtrlForPanning: boolean;
  46098. /** @hidden */
  46099. _panningMouseButton: number;
  46100. /**
  46101. * Defines the input associated to the camera.
  46102. */
  46103. inputs: ArcRotateCameraInputsManager;
  46104. /** @hidden */
  46105. _reset: () => void;
  46106. /**
  46107. * Defines the allowed panning axis.
  46108. */
  46109. panningAxis: Vector3;
  46110. protected _localDirection: Vector3;
  46111. protected _transformedDirection: Vector3;
  46112. private _bouncingBehavior;
  46113. /**
  46114. * Gets the bouncing behavior of the camera if it has been enabled.
  46115. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46116. */
  46117. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46118. /**
  46119. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46120. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46121. */
  46122. get useBouncingBehavior(): boolean;
  46123. set useBouncingBehavior(value: boolean);
  46124. private _framingBehavior;
  46125. /**
  46126. * Gets the framing behavior of the camera if it has been enabled.
  46127. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46128. */
  46129. get framingBehavior(): Nullable<FramingBehavior>;
  46130. /**
  46131. * Defines if the framing behavior of the camera is enabled on the camera.
  46132. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46133. */
  46134. get useFramingBehavior(): boolean;
  46135. set useFramingBehavior(value: boolean);
  46136. private _autoRotationBehavior;
  46137. /**
  46138. * Gets the auto rotation behavior of the camera if it has been enabled.
  46139. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46140. */
  46141. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46142. /**
  46143. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46144. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46145. */
  46146. get useAutoRotationBehavior(): boolean;
  46147. set useAutoRotationBehavior(value: boolean);
  46148. /**
  46149. * Observable triggered when the mesh target has been changed on the camera.
  46150. */
  46151. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46152. /**
  46153. * Event raised when the camera is colliding with a mesh.
  46154. */
  46155. onCollide: (collidedMesh: AbstractMesh) => void;
  46156. /**
  46157. * Defines whether the camera should check collision with the objects oh the scene.
  46158. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46159. */
  46160. checkCollisions: boolean;
  46161. /**
  46162. * Defines the collision radius of the camera.
  46163. * This simulates a sphere around the camera.
  46164. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46165. */
  46166. collisionRadius: Vector3;
  46167. protected _collider: Collider;
  46168. protected _previousPosition: Vector3;
  46169. protected _collisionVelocity: Vector3;
  46170. protected _newPosition: Vector3;
  46171. protected _previousAlpha: number;
  46172. protected _previousBeta: number;
  46173. protected _previousRadius: number;
  46174. protected _collisionTriggered: boolean;
  46175. protected _targetBoundingCenter: Nullable<Vector3>;
  46176. private _computationVector;
  46177. /**
  46178. * Instantiates a new ArcRotateCamera in a given scene
  46179. * @param name Defines the name of the camera
  46180. * @param alpha Defines the camera rotation along the logitudinal axis
  46181. * @param beta Defines the camera rotation along the latitudinal axis
  46182. * @param radius Defines the camera distance from its target
  46183. * @param target Defines the camera target
  46184. * @param scene Defines the scene the camera belongs to
  46185. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46186. */
  46187. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46188. /** @hidden */
  46189. _initCache(): void;
  46190. /** @hidden */
  46191. _updateCache(ignoreParentClass?: boolean): void;
  46192. protected _getTargetPosition(): Vector3;
  46193. private _storedAlpha;
  46194. private _storedBeta;
  46195. private _storedRadius;
  46196. private _storedTarget;
  46197. private _storedTargetScreenOffset;
  46198. /**
  46199. * Stores the current state of the camera (alpha, beta, radius and target)
  46200. * @returns the camera itself
  46201. */
  46202. storeState(): Camera;
  46203. /**
  46204. * @hidden
  46205. * Restored camera state. You must call storeState() first
  46206. */
  46207. _restoreStateValues(): boolean;
  46208. /** @hidden */
  46209. _isSynchronizedViewMatrix(): boolean;
  46210. /**
  46211. * Attached controls to the current camera.
  46212. * @param element Defines the element the controls should be listened from
  46213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46214. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46215. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46216. */
  46217. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46218. /**
  46219. * Detach the current controls from the camera.
  46220. * The camera will stop reacting to inputs.
  46221. * @param element Defines the element to stop listening the inputs from
  46222. */
  46223. detachControl(element: HTMLElement): void;
  46224. /** @hidden */
  46225. _checkInputs(): void;
  46226. protected _checkLimits(): void;
  46227. /**
  46228. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46229. */
  46230. rebuildAnglesAndRadius(): void;
  46231. /**
  46232. * Use a position to define the current camera related information like alpha, beta and radius
  46233. * @param position Defines the position to set the camera at
  46234. */
  46235. setPosition(position: Vector3): void;
  46236. /**
  46237. * Defines the target the camera should look at.
  46238. * This will automatically adapt alpha beta and radius to fit within the new target.
  46239. * @param target Defines the new target as a Vector or a mesh
  46240. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46241. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46242. */
  46243. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46244. /** @hidden */
  46245. _getViewMatrix(): Matrix;
  46246. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46247. /**
  46248. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46249. * @param meshes Defines the mesh to zoom on
  46250. * @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)
  46251. */
  46252. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46253. /**
  46254. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46255. * The target will be changed but the radius
  46256. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46257. * @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)
  46258. */
  46259. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46260. min: Vector3;
  46261. max: Vector3;
  46262. distance: number;
  46263. }, doNotUpdateMaxZ?: boolean): void;
  46264. /**
  46265. * @override
  46266. * Override Camera.createRigCamera
  46267. */
  46268. createRigCamera(name: string, cameraIndex: number): Camera;
  46269. /**
  46270. * @hidden
  46271. * @override
  46272. * Override Camera._updateRigCameras
  46273. */
  46274. _updateRigCameras(): void;
  46275. /**
  46276. * Destroy the camera and release the current resources hold by it.
  46277. */
  46278. dispose(): void;
  46279. /**
  46280. * Gets the current object class name.
  46281. * @return the class name
  46282. */
  46283. getClassName(): string;
  46284. }
  46285. }
  46286. declare module BABYLON {
  46287. /**
  46288. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46289. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46290. */
  46291. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46292. /**
  46293. * Gets the name of the behavior.
  46294. */
  46295. get name(): string;
  46296. private _zoomStopsAnimation;
  46297. private _idleRotationSpeed;
  46298. private _idleRotationWaitTime;
  46299. private _idleRotationSpinupTime;
  46300. /**
  46301. * Sets the flag that indicates if user zooming should stop animation.
  46302. */
  46303. set zoomStopsAnimation(flag: boolean);
  46304. /**
  46305. * Gets the flag that indicates if user zooming should stop animation.
  46306. */
  46307. get zoomStopsAnimation(): boolean;
  46308. /**
  46309. * Sets the default speed at which the camera rotates around the model.
  46310. */
  46311. set idleRotationSpeed(speed: number);
  46312. /**
  46313. * Gets the default speed at which the camera rotates around the model.
  46314. */
  46315. get idleRotationSpeed(): number;
  46316. /**
  46317. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46318. */
  46319. set idleRotationWaitTime(time: number);
  46320. /**
  46321. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46322. */
  46323. get idleRotationWaitTime(): number;
  46324. /**
  46325. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46326. */
  46327. set idleRotationSpinupTime(time: number);
  46328. /**
  46329. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46330. */
  46331. get idleRotationSpinupTime(): number;
  46332. /**
  46333. * Gets a value indicating if the camera is currently rotating because of this behavior
  46334. */
  46335. get rotationInProgress(): boolean;
  46336. private _onPrePointerObservableObserver;
  46337. private _onAfterCheckInputsObserver;
  46338. private _attachedCamera;
  46339. private _isPointerDown;
  46340. private _lastFrameTime;
  46341. private _lastInteractionTime;
  46342. private _cameraRotationSpeed;
  46343. /**
  46344. * Initializes the behavior.
  46345. */
  46346. init(): void;
  46347. /**
  46348. * Attaches the behavior to its arc rotate camera.
  46349. * @param camera Defines the camera to attach the behavior to
  46350. */
  46351. attach(camera: ArcRotateCamera): void;
  46352. /**
  46353. * Detaches the behavior from its current arc rotate camera.
  46354. */
  46355. detach(): void;
  46356. /**
  46357. * Returns true if user is scrolling.
  46358. * @return true if user is scrolling.
  46359. */
  46360. private _userIsZooming;
  46361. private _lastFrameRadius;
  46362. private _shouldAnimationStopForInteraction;
  46363. /**
  46364. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46365. */
  46366. private _applyUserInteraction;
  46367. private _userIsMoving;
  46368. }
  46369. }
  46370. declare module BABYLON {
  46371. /**
  46372. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46373. */
  46374. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46375. private ui;
  46376. /**
  46377. * The name of the behavior
  46378. */
  46379. name: string;
  46380. /**
  46381. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46382. */
  46383. distanceAwayFromFace: number;
  46384. /**
  46385. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46386. */
  46387. distanceAwayFromBottomOfFace: number;
  46388. private _faceVectors;
  46389. private _target;
  46390. private _scene;
  46391. private _onRenderObserver;
  46392. private _tmpMatrix;
  46393. private _tmpVector;
  46394. /**
  46395. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46396. * @param ui The transform node that should be attched to the mesh
  46397. */
  46398. constructor(ui: TransformNode);
  46399. /**
  46400. * Initializes the behavior
  46401. */
  46402. init(): void;
  46403. private _closestFace;
  46404. private _zeroVector;
  46405. private _lookAtTmpMatrix;
  46406. private _lookAtToRef;
  46407. /**
  46408. * Attaches the AttachToBoxBehavior to the passed in mesh
  46409. * @param target The mesh that the specified node will be attached to
  46410. */
  46411. attach(target: Mesh): void;
  46412. /**
  46413. * Detaches the behavior from the mesh
  46414. */
  46415. detach(): void;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46421. */
  46422. export class FadeInOutBehavior implements Behavior<Mesh> {
  46423. /**
  46424. * Time in milliseconds to delay before fading in (Default: 0)
  46425. */
  46426. delay: number;
  46427. /**
  46428. * Time in milliseconds for the mesh to fade in (Default: 300)
  46429. */
  46430. fadeInTime: number;
  46431. private _millisecondsPerFrame;
  46432. private _hovered;
  46433. private _hoverValue;
  46434. private _ownerNode;
  46435. /**
  46436. * Instatiates the FadeInOutBehavior
  46437. */
  46438. constructor();
  46439. /**
  46440. * The name of the behavior
  46441. */
  46442. get name(): string;
  46443. /**
  46444. * Initializes the behavior
  46445. */
  46446. init(): void;
  46447. /**
  46448. * Attaches the fade behavior on the passed in mesh
  46449. * @param ownerNode The mesh that will be faded in/out once attached
  46450. */
  46451. attach(ownerNode: Mesh): void;
  46452. /**
  46453. * Detaches the behavior from the mesh
  46454. */
  46455. detach(): void;
  46456. /**
  46457. * Triggers the mesh to begin fading in or out
  46458. * @param value if the object should fade in or out (true to fade in)
  46459. */
  46460. fadeIn(value: boolean): void;
  46461. private _update;
  46462. private _setAllVisibility;
  46463. }
  46464. }
  46465. declare module BABYLON {
  46466. /**
  46467. * Class containing a set of static utilities functions for managing Pivots
  46468. * @hidden
  46469. */
  46470. export class PivotTools {
  46471. private static _PivotCached;
  46472. private static _OldPivotPoint;
  46473. private static _PivotTranslation;
  46474. private static _PivotTmpVector;
  46475. private static _PivotPostMultiplyPivotMatrix;
  46476. /** @hidden */
  46477. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46478. /** @hidden */
  46479. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46480. }
  46481. }
  46482. declare module BABYLON {
  46483. /**
  46484. * Class containing static functions to help procedurally build meshes
  46485. */
  46486. export class PlaneBuilder {
  46487. /**
  46488. * Creates a plane mesh
  46489. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46490. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46491. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46493. * * 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
  46494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46495. * @param name defines the name of the mesh
  46496. * @param options defines the options used to create the mesh
  46497. * @param scene defines the hosting scene
  46498. * @returns the plane mesh
  46499. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46500. */
  46501. static CreatePlane(name: string, options: {
  46502. size?: number;
  46503. width?: number;
  46504. height?: number;
  46505. sideOrientation?: number;
  46506. frontUVs?: Vector4;
  46507. backUVs?: Vector4;
  46508. updatable?: boolean;
  46509. sourcePlane?: Plane;
  46510. }, scene?: Nullable<Scene>): Mesh;
  46511. }
  46512. }
  46513. declare module BABYLON {
  46514. /**
  46515. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46516. */
  46517. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46518. private static _AnyMouseID;
  46519. /**
  46520. * Abstract mesh the behavior is set on
  46521. */
  46522. attachedNode: AbstractMesh;
  46523. private _dragPlane;
  46524. private _scene;
  46525. private _pointerObserver;
  46526. private _beforeRenderObserver;
  46527. private static _planeScene;
  46528. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46529. /**
  46530. * 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)
  46531. */
  46532. maxDragAngle: number;
  46533. /**
  46534. * @hidden
  46535. */
  46536. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46537. /**
  46538. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46539. */
  46540. currentDraggingPointerID: number;
  46541. /**
  46542. * The last position where the pointer hit the drag plane in world space
  46543. */
  46544. lastDragPosition: Vector3;
  46545. /**
  46546. * If the behavior is currently in a dragging state
  46547. */
  46548. dragging: boolean;
  46549. /**
  46550. * 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)
  46551. */
  46552. dragDeltaRatio: number;
  46553. /**
  46554. * If the drag plane orientation should be updated during the dragging (Default: true)
  46555. */
  46556. updateDragPlane: boolean;
  46557. private _debugMode;
  46558. private _moving;
  46559. /**
  46560. * Fires each time the attached mesh is dragged with the pointer
  46561. * * delta between last drag position and current drag position in world space
  46562. * * dragDistance along the drag axis
  46563. * * dragPlaneNormal normal of the current drag plane used during the drag
  46564. * * dragPlanePoint in world space where the drag intersects the drag plane
  46565. */
  46566. onDragObservable: Observable<{
  46567. delta: Vector3;
  46568. dragPlanePoint: Vector3;
  46569. dragPlaneNormal: Vector3;
  46570. dragDistance: number;
  46571. pointerId: number;
  46572. }>;
  46573. /**
  46574. * Fires each time a drag begins (eg. mouse down on mesh)
  46575. */
  46576. onDragStartObservable: Observable<{
  46577. dragPlanePoint: Vector3;
  46578. pointerId: number;
  46579. }>;
  46580. /**
  46581. * Fires each time a drag ends (eg. mouse release after drag)
  46582. */
  46583. onDragEndObservable: Observable<{
  46584. dragPlanePoint: Vector3;
  46585. pointerId: number;
  46586. }>;
  46587. /**
  46588. * If the attached mesh should be moved when dragged
  46589. */
  46590. moveAttached: boolean;
  46591. /**
  46592. * If the drag behavior will react to drag events (Default: true)
  46593. */
  46594. enabled: boolean;
  46595. /**
  46596. * If pointer events should start and release the drag (Default: true)
  46597. */
  46598. startAndReleaseDragOnPointerEvents: boolean;
  46599. /**
  46600. * If camera controls should be detached during the drag
  46601. */
  46602. detachCameraControls: boolean;
  46603. /**
  46604. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46605. */
  46606. useObjectOrientationForDragging: boolean;
  46607. private _options;
  46608. /**
  46609. * Gets the options used by the behavior
  46610. */
  46611. get options(): {
  46612. dragAxis?: Vector3;
  46613. dragPlaneNormal?: Vector3;
  46614. };
  46615. /**
  46616. * Sets the options used by the behavior
  46617. */
  46618. set options(options: {
  46619. dragAxis?: Vector3;
  46620. dragPlaneNormal?: Vector3;
  46621. });
  46622. /**
  46623. * Creates a pointer drag behavior that can be attached to a mesh
  46624. * @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)
  46625. */
  46626. constructor(options?: {
  46627. dragAxis?: Vector3;
  46628. dragPlaneNormal?: Vector3;
  46629. });
  46630. /**
  46631. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46632. */
  46633. validateDrag: (targetPosition: Vector3) => boolean;
  46634. /**
  46635. * The name of the behavior
  46636. */
  46637. get name(): string;
  46638. /**
  46639. * Initializes the behavior
  46640. */
  46641. init(): void;
  46642. private _tmpVector;
  46643. private _alternatePickedPoint;
  46644. private _worldDragAxis;
  46645. private _targetPosition;
  46646. private _attachedElement;
  46647. /**
  46648. * Attaches the drag behavior the passed in mesh
  46649. * @param ownerNode The mesh that will be dragged around once attached
  46650. * @param predicate Predicate to use for pick filtering
  46651. */
  46652. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46653. /**
  46654. * Force relase the drag action by code.
  46655. */
  46656. releaseDrag(): void;
  46657. private _startDragRay;
  46658. private _lastPointerRay;
  46659. /**
  46660. * Simulates the start of a pointer drag event on the behavior
  46661. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46662. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46663. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46664. */
  46665. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46666. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46667. private _dragDelta;
  46668. protected _moveDrag(ray: Ray): void;
  46669. private _pickWithRayOnDragPlane;
  46670. private _pointA;
  46671. private _pointC;
  46672. private _localAxis;
  46673. private _lookAt;
  46674. private _updateDragPlanePosition;
  46675. /**
  46676. * Detaches the behavior from the mesh
  46677. */
  46678. detach(): void;
  46679. }
  46680. }
  46681. declare module BABYLON {
  46682. /**
  46683. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46684. */
  46685. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46686. private _dragBehaviorA;
  46687. private _dragBehaviorB;
  46688. private _startDistance;
  46689. private _initialScale;
  46690. private _targetScale;
  46691. private _ownerNode;
  46692. private _sceneRenderObserver;
  46693. /**
  46694. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46695. */
  46696. constructor();
  46697. /**
  46698. * The name of the behavior
  46699. */
  46700. get name(): string;
  46701. /**
  46702. * Initializes the behavior
  46703. */
  46704. init(): void;
  46705. private _getCurrentDistance;
  46706. /**
  46707. * Attaches the scale behavior the passed in mesh
  46708. * @param ownerNode The mesh that will be scaled around once attached
  46709. */
  46710. attach(ownerNode: Mesh): void;
  46711. /**
  46712. * Detaches the behavior from the mesh
  46713. */
  46714. detach(): void;
  46715. }
  46716. }
  46717. declare module BABYLON {
  46718. /**
  46719. * 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
  46720. */
  46721. export class SixDofDragBehavior implements Behavior<Mesh> {
  46722. private static _virtualScene;
  46723. private _ownerNode;
  46724. private _sceneRenderObserver;
  46725. private _scene;
  46726. private _targetPosition;
  46727. private _virtualOriginMesh;
  46728. private _virtualDragMesh;
  46729. private _pointerObserver;
  46730. private _moving;
  46731. private _startingOrientation;
  46732. private _attachedElement;
  46733. /**
  46734. * 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)
  46735. */
  46736. private zDragFactor;
  46737. /**
  46738. * If the object should rotate to face the drag origin
  46739. */
  46740. rotateDraggedObject: boolean;
  46741. /**
  46742. * If the behavior is currently in a dragging state
  46743. */
  46744. dragging: boolean;
  46745. /**
  46746. * 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)
  46747. */
  46748. dragDeltaRatio: number;
  46749. /**
  46750. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46751. */
  46752. currentDraggingPointerID: number;
  46753. /**
  46754. * If camera controls should be detached during the drag
  46755. */
  46756. detachCameraControls: boolean;
  46757. /**
  46758. * Fires each time a drag starts
  46759. */
  46760. onDragStartObservable: Observable<{}>;
  46761. /**
  46762. * Fires each time a drag ends (eg. mouse release after drag)
  46763. */
  46764. onDragEndObservable: Observable<{}>;
  46765. /**
  46766. * 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
  46767. */
  46768. constructor();
  46769. /**
  46770. * The name of the behavior
  46771. */
  46772. get name(): string;
  46773. /**
  46774. * Initializes the behavior
  46775. */
  46776. init(): void;
  46777. /**
  46778. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46779. */
  46780. private get _pointerCamera();
  46781. /**
  46782. * Attaches the scale behavior the passed in mesh
  46783. * @param ownerNode The mesh that will be scaled around once attached
  46784. */
  46785. attach(ownerNode: Mesh): void;
  46786. /**
  46787. * Detaches the behavior from the mesh
  46788. */
  46789. detach(): void;
  46790. }
  46791. }
  46792. declare module BABYLON {
  46793. /**
  46794. * Class used to apply inverse kinematics to bones
  46795. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46796. */
  46797. export class BoneIKController {
  46798. private static _tmpVecs;
  46799. private static _tmpQuat;
  46800. private static _tmpMats;
  46801. /**
  46802. * Gets or sets the target mesh
  46803. */
  46804. targetMesh: AbstractMesh;
  46805. /** Gets or sets the mesh used as pole */
  46806. poleTargetMesh: AbstractMesh;
  46807. /**
  46808. * Gets or sets the bone used as pole
  46809. */
  46810. poleTargetBone: Nullable<Bone>;
  46811. /**
  46812. * Gets or sets the target position
  46813. */
  46814. targetPosition: Vector3;
  46815. /**
  46816. * Gets or sets the pole target position
  46817. */
  46818. poleTargetPosition: Vector3;
  46819. /**
  46820. * Gets or sets the pole target local offset
  46821. */
  46822. poleTargetLocalOffset: Vector3;
  46823. /**
  46824. * Gets or sets the pole angle
  46825. */
  46826. poleAngle: number;
  46827. /**
  46828. * Gets or sets the mesh associated with the controller
  46829. */
  46830. mesh: AbstractMesh;
  46831. /**
  46832. * 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)
  46833. */
  46834. slerpAmount: number;
  46835. private _bone1Quat;
  46836. private _bone1Mat;
  46837. private _bone2Ang;
  46838. private _bone1;
  46839. private _bone2;
  46840. private _bone1Length;
  46841. private _bone2Length;
  46842. private _maxAngle;
  46843. private _maxReach;
  46844. private _rightHandedSystem;
  46845. private _bendAxis;
  46846. private _slerping;
  46847. private _adjustRoll;
  46848. /**
  46849. * Gets or sets maximum allowed angle
  46850. */
  46851. get maxAngle(): number;
  46852. set maxAngle(value: number);
  46853. /**
  46854. * Creates a new BoneIKController
  46855. * @param mesh defines the mesh to control
  46856. * @param bone defines the bone to control
  46857. * @param options defines options to set up the controller
  46858. */
  46859. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46860. targetMesh?: AbstractMesh;
  46861. poleTargetMesh?: AbstractMesh;
  46862. poleTargetBone?: Bone;
  46863. poleTargetLocalOffset?: Vector3;
  46864. poleAngle?: number;
  46865. bendAxis?: Vector3;
  46866. maxAngle?: number;
  46867. slerpAmount?: number;
  46868. });
  46869. private _setMaxAngle;
  46870. /**
  46871. * Force the controller to update the bones
  46872. */
  46873. update(): void;
  46874. }
  46875. }
  46876. declare module BABYLON {
  46877. /**
  46878. * Class used to make a bone look toward a point in space
  46879. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46880. */
  46881. export class BoneLookController {
  46882. private static _tmpVecs;
  46883. private static _tmpQuat;
  46884. private static _tmpMats;
  46885. /**
  46886. * The target Vector3 that the bone will look at
  46887. */
  46888. target: Vector3;
  46889. /**
  46890. * The mesh that the bone is attached to
  46891. */
  46892. mesh: AbstractMesh;
  46893. /**
  46894. * The bone that will be looking to the target
  46895. */
  46896. bone: Bone;
  46897. /**
  46898. * The up axis of the coordinate system that is used when the bone is rotated
  46899. */
  46900. upAxis: Vector3;
  46901. /**
  46902. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46903. */
  46904. upAxisSpace: Space;
  46905. /**
  46906. * Used to make an adjustment to the yaw of the bone
  46907. */
  46908. adjustYaw: number;
  46909. /**
  46910. * Used to make an adjustment to the pitch of the bone
  46911. */
  46912. adjustPitch: number;
  46913. /**
  46914. * Used to make an adjustment to the roll of the bone
  46915. */
  46916. adjustRoll: number;
  46917. /**
  46918. * 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)
  46919. */
  46920. slerpAmount: number;
  46921. private _minYaw;
  46922. private _maxYaw;
  46923. private _minPitch;
  46924. private _maxPitch;
  46925. private _minYawSin;
  46926. private _minYawCos;
  46927. private _maxYawSin;
  46928. private _maxYawCos;
  46929. private _midYawConstraint;
  46930. private _minPitchTan;
  46931. private _maxPitchTan;
  46932. private _boneQuat;
  46933. private _slerping;
  46934. private _transformYawPitch;
  46935. private _transformYawPitchInv;
  46936. private _firstFrameSkipped;
  46937. private _yawRange;
  46938. private _fowardAxis;
  46939. /**
  46940. * Gets or sets the minimum yaw angle that the bone can look to
  46941. */
  46942. get minYaw(): number;
  46943. set minYaw(value: number);
  46944. /**
  46945. * Gets or sets the maximum yaw angle that the bone can look to
  46946. */
  46947. get maxYaw(): number;
  46948. set maxYaw(value: number);
  46949. /**
  46950. * Gets or sets the minimum pitch angle that the bone can look to
  46951. */
  46952. get minPitch(): number;
  46953. set minPitch(value: number);
  46954. /**
  46955. * Gets or sets the maximum pitch angle that the bone can look to
  46956. */
  46957. get maxPitch(): number;
  46958. set maxPitch(value: number);
  46959. /**
  46960. * Create a BoneLookController
  46961. * @param mesh the mesh that the bone belongs to
  46962. * @param bone the bone that will be looking to the target
  46963. * @param target the target Vector3 to look at
  46964. * @param options optional settings:
  46965. * * maxYaw: the maximum angle the bone will yaw to
  46966. * * minYaw: the minimum angle the bone will yaw to
  46967. * * maxPitch: the maximum angle the bone will pitch to
  46968. * * minPitch: the minimum angle the bone will yaw to
  46969. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46970. * * upAxis: the up axis of the coordinate system
  46971. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46972. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46973. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46974. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46975. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46976. * * adjustRoll: used to make an adjustment to the roll of the bone
  46977. **/
  46978. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46979. maxYaw?: number;
  46980. minYaw?: number;
  46981. maxPitch?: number;
  46982. minPitch?: number;
  46983. slerpAmount?: number;
  46984. upAxis?: Vector3;
  46985. upAxisSpace?: Space;
  46986. yawAxis?: Vector3;
  46987. pitchAxis?: Vector3;
  46988. adjustYaw?: number;
  46989. adjustPitch?: number;
  46990. adjustRoll?: number;
  46991. });
  46992. /**
  46993. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  46994. */
  46995. update(): void;
  46996. private _getAngleDiff;
  46997. private _getAngleBetween;
  46998. private _isAngleBetween;
  46999. }
  47000. }
  47001. declare module BABYLON {
  47002. /**
  47003. * Manage the gamepad inputs to control an arc rotate camera.
  47004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47005. */
  47006. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47007. /**
  47008. * Defines the camera the input is attached to.
  47009. */
  47010. camera: ArcRotateCamera;
  47011. /**
  47012. * Defines the gamepad the input is gathering event from.
  47013. */
  47014. gamepad: Nullable<Gamepad>;
  47015. /**
  47016. * Defines the gamepad rotation sensiblity.
  47017. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47018. */
  47019. gamepadRotationSensibility: number;
  47020. /**
  47021. * Defines the gamepad move sensiblity.
  47022. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47023. */
  47024. gamepadMoveSensibility: number;
  47025. private _yAxisScale;
  47026. /**
  47027. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47028. */
  47029. get invertYAxis(): boolean;
  47030. set invertYAxis(value: boolean);
  47031. private _onGamepadConnectedObserver;
  47032. private _onGamepadDisconnectedObserver;
  47033. /**
  47034. * Attach the input controls to a specific dom element to get the input from.
  47035. * @param element Defines the element the controls should be listened from
  47036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47037. */
  47038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47039. /**
  47040. * Detach the current controls from the specified dom element.
  47041. * @param element Defines the element to stop listening the inputs from
  47042. */
  47043. detachControl(element: Nullable<HTMLElement>): void;
  47044. /**
  47045. * Update the current camera state depending on the inputs that have been used this frame.
  47046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47047. */
  47048. checkInputs(): void;
  47049. /**
  47050. * Gets the class name of the current intput.
  47051. * @returns the class name
  47052. */
  47053. getClassName(): string;
  47054. /**
  47055. * Get the friendly name associated with the input class.
  47056. * @returns the input friendly name
  47057. */
  47058. getSimpleName(): string;
  47059. }
  47060. }
  47061. declare module BABYLON {
  47062. interface ArcRotateCameraInputsManager {
  47063. /**
  47064. * Add orientation input support to the input manager.
  47065. * @returns the current input manager
  47066. */
  47067. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47068. }
  47069. /**
  47070. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47072. */
  47073. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47074. /**
  47075. * Defines the camera the input is attached to.
  47076. */
  47077. camera: ArcRotateCamera;
  47078. /**
  47079. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47080. */
  47081. alphaCorrection: number;
  47082. /**
  47083. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47084. */
  47085. gammaCorrection: number;
  47086. private _alpha;
  47087. private _gamma;
  47088. private _dirty;
  47089. private _deviceOrientationHandler;
  47090. /**
  47091. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47092. */
  47093. constructor();
  47094. /**
  47095. * Attach the input controls to a specific dom element to get the input from.
  47096. * @param element Defines the element the controls should be listened from
  47097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47098. */
  47099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47100. /** @hidden */
  47101. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47102. /**
  47103. * Update the current camera state depending on the inputs that have been used this frame.
  47104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47105. */
  47106. checkInputs(): void;
  47107. /**
  47108. * Detach the current controls from the specified dom element.
  47109. * @param element Defines the element to stop listening the inputs from
  47110. */
  47111. detachControl(element: Nullable<HTMLElement>): void;
  47112. /**
  47113. * Gets the class name of the current intput.
  47114. * @returns the class name
  47115. */
  47116. getClassName(): string;
  47117. /**
  47118. * Get the friendly name associated with the input class.
  47119. * @returns the input friendly name
  47120. */
  47121. getSimpleName(): string;
  47122. }
  47123. }
  47124. declare module BABYLON {
  47125. /**
  47126. * Listen to mouse events to control the camera.
  47127. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47128. */
  47129. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47130. /**
  47131. * Defines the camera the input is attached to.
  47132. */
  47133. camera: FlyCamera;
  47134. /**
  47135. * Defines if touch is enabled. (Default is true.)
  47136. */
  47137. touchEnabled: boolean;
  47138. /**
  47139. * Defines the buttons associated with the input to handle camera rotation.
  47140. */
  47141. buttons: number[];
  47142. /**
  47143. * Assign buttons for Yaw control.
  47144. */
  47145. buttonsYaw: number[];
  47146. /**
  47147. * Assign buttons for Pitch control.
  47148. */
  47149. buttonsPitch: number[];
  47150. /**
  47151. * Assign buttons for Roll control.
  47152. */
  47153. buttonsRoll: number[];
  47154. /**
  47155. * Detect if any button is being pressed while mouse is moved.
  47156. * -1 = Mouse locked.
  47157. * 0 = Left button.
  47158. * 1 = Middle Button.
  47159. * 2 = Right Button.
  47160. */
  47161. activeButton: number;
  47162. /**
  47163. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47164. * Higher values reduce its sensitivity.
  47165. */
  47166. angularSensibility: number;
  47167. private _observer;
  47168. private _rollObserver;
  47169. private previousPosition;
  47170. private noPreventDefault;
  47171. private element;
  47172. /**
  47173. * Listen to mouse events to control the camera.
  47174. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47176. */
  47177. constructor(touchEnabled?: boolean);
  47178. /**
  47179. * Attach the mouse control to the HTML DOM element.
  47180. * @param element Defines the element that listens to the input events.
  47181. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47182. */
  47183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47184. /**
  47185. * Detach the current controls from the specified dom element.
  47186. * @param element Defines the element to stop listening the inputs from
  47187. */
  47188. detachControl(element: Nullable<HTMLElement>): void;
  47189. /**
  47190. * Gets the class name of the current input.
  47191. * @returns the class name.
  47192. */
  47193. getClassName(): string;
  47194. /**
  47195. * Get the friendly name associated with the input class.
  47196. * @returns the input's friendly name.
  47197. */
  47198. getSimpleName(): string;
  47199. private _pointerInput;
  47200. private _onMouseMove;
  47201. /**
  47202. * Rotate camera by mouse offset.
  47203. */
  47204. private rotateCamera;
  47205. }
  47206. }
  47207. declare module BABYLON {
  47208. /**
  47209. * Default Inputs manager for the FlyCamera.
  47210. * It groups all the default supported inputs for ease of use.
  47211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47212. */
  47213. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47214. /**
  47215. * Instantiates a new FlyCameraInputsManager.
  47216. * @param camera Defines the camera the inputs belong to.
  47217. */
  47218. constructor(camera: FlyCamera);
  47219. /**
  47220. * Add keyboard input support to the input manager.
  47221. * @returns the new FlyCameraKeyboardMoveInput().
  47222. */
  47223. addKeyboard(): FlyCameraInputsManager;
  47224. /**
  47225. * Add mouse input support to the input manager.
  47226. * @param touchEnabled Enable touch screen support.
  47227. * @returns the new FlyCameraMouseInput().
  47228. */
  47229. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47230. }
  47231. }
  47232. declare module BABYLON {
  47233. /**
  47234. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47235. * such as in a 3D Space Shooter or a Flight Simulator.
  47236. */
  47237. export class FlyCamera extends TargetCamera {
  47238. /**
  47239. * Define the collision ellipsoid of the camera.
  47240. * This is helpful for simulating a camera body, like a player's body.
  47241. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47242. */
  47243. ellipsoid: Vector3;
  47244. /**
  47245. * Define an offset for the position of the ellipsoid around the camera.
  47246. * This can be helpful if the camera is attached away from the player's body center,
  47247. * such as at its head.
  47248. */
  47249. ellipsoidOffset: Vector3;
  47250. /**
  47251. * Enable or disable collisions of the camera with the rest of the scene objects.
  47252. */
  47253. checkCollisions: boolean;
  47254. /**
  47255. * Enable or disable gravity on the camera.
  47256. */
  47257. applyGravity: boolean;
  47258. /**
  47259. * Define the current direction the camera is moving to.
  47260. */
  47261. cameraDirection: Vector3;
  47262. /**
  47263. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47264. * This overrides and empties cameraRotation.
  47265. */
  47266. rotationQuaternion: Quaternion;
  47267. /**
  47268. * Track Roll to maintain the wanted Rolling when looking around.
  47269. */
  47270. _trackRoll: number;
  47271. /**
  47272. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47273. */
  47274. rollCorrect: number;
  47275. /**
  47276. * Mimic a banked turn, Rolling the camera when Yawing.
  47277. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47278. */
  47279. bankedTurn: boolean;
  47280. /**
  47281. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47282. */
  47283. bankedTurnLimit: number;
  47284. /**
  47285. * Value of 0 disables the banked Roll.
  47286. * Value of 1 is equal to the Yaw angle in radians.
  47287. */
  47288. bankedTurnMultiplier: number;
  47289. /**
  47290. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47291. */
  47292. inputs: FlyCameraInputsManager;
  47293. /**
  47294. * Gets the input sensibility for mouse input.
  47295. * Higher values reduce sensitivity.
  47296. */
  47297. get angularSensibility(): number;
  47298. /**
  47299. * Sets the input sensibility for a mouse input.
  47300. * Higher values reduce sensitivity.
  47301. */
  47302. set angularSensibility(value: number);
  47303. /**
  47304. * Get the keys for camera movement forward.
  47305. */
  47306. get keysForward(): number[];
  47307. /**
  47308. * Set the keys for camera movement forward.
  47309. */
  47310. set keysForward(value: number[]);
  47311. /**
  47312. * Get the keys for camera movement backward.
  47313. */
  47314. get keysBackward(): number[];
  47315. set keysBackward(value: number[]);
  47316. /**
  47317. * Get the keys for camera movement up.
  47318. */
  47319. get keysUp(): number[];
  47320. /**
  47321. * Set the keys for camera movement up.
  47322. */
  47323. set keysUp(value: number[]);
  47324. /**
  47325. * Get the keys for camera movement down.
  47326. */
  47327. get keysDown(): number[];
  47328. /**
  47329. * Set the keys for camera movement down.
  47330. */
  47331. set keysDown(value: number[]);
  47332. /**
  47333. * Get the keys for camera movement left.
  47334. */
  47335. get keysLeft(): number[];
  47336. /**
  47337. * Set the keys for camera movement left.
  47338. */
  47339. set keysLeft(value: number[]);
  47340. /**
  47341. * Set the keys for camera movement right.
  47342. */
  47343. get keysRight(): number[];
  47344. /**
  47345. * Set the keys for camera movement right.
  47346. */
  47347. set keysRight(value: number[]);
  47348. /**
  47349. * Event raised when the camera collides with a mesh in the scene.
  47350. */
  47351. onCollide: (collidedMesh: AbstractMesh) => void;
  47352. private _collider;
  47353. private _needMoveForGravity;
  47354. private _oldPosition;
  47355. private _diffPosition;
  47356. private _newPosition;
  47357. /** @hidden */
  47358. _localDirection: Vector3;
  47359. /** @hidden */
  47360. _transformedDirection: Vector3;
  47361. /**
  47362. * Instantiates a FlyCamera.
  47363. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47364. * such as in a 3D Space Shooter or a Flight Simulator.
  47365. * @param name Define the name of the camera in the scene.
  47366. * @param position Define the starting position of the camera in the scene.
  47367. * @param scene Define the scene the camera belongs to.
  47368. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47369. */
  47370. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47371. /**
  47372. * Attach a control to the HTML DOM element.
  47373. * @param element Defines the element that listens to the input events.
  47374. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47375. */
  47376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47377. /**
  47378. * Detach a control from the HTML DOM element.
  47379. * The camera will stop reacting to that input.
  47380. * @param element Defines the element that listens to the input events.
  47381. */
  47382. detachControl(element: HTMLElement): void;
  47383. private _collisionMask;
  47384. /**
  47385. * Get the mask that the camera ignores in collision events.
  47386. */
  47387. get collisionMask(): number;
  47388. /**
  47389. * Set the mask that the camera ignores in collision events.
  47390. */
  47391. set collisionMask(mask: number);
  47392. /** @hidden */
  47393. _collideWithWorld(displacement: Vector3): void;
  47394. /** @hidden */
  47395. private _onCollisionPositionChange;
  47396. /** @hidden */
  47397. _checkInputs(): void;
  47398. /** @hidden */
  47399. _decideIfNeedsToMove(): boolean;
  47400. /** @hidden */
  47401. _updatePosition(): void;
  47402. /**
  47403. * Restore the Roll to its target value at the rate specified.
  47404. * @param rate - Higher means slower restoring.
  47405. * @hidden
  47406. */
  47407. restoreRoll(rate: number): void;
  47408. /**
  47409. * Destroy the camera and release the current resources held by it.
  47410. */
  47411. dispose(): void;
  47412. /**
  47413. * Get the current object class name.
  47414. * @returns the class name.
  47415. */
  47416. getClassName(): string;
  47417. }
  47418. }
  47419. declare module BABYLON {
  47420. /**
  47421. * Listen to keyboard events to control the camera.
  47422. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47423. */
  47424. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47425. /**
  47426. * Defines the camera the input is attached to.
  47427. */
  47428. camera: FlyCamera;
  47429. /**
  47430. * The list of keyboard keys used to control the forward move of the camera.
  47431. */
  47432. keysForward: number[];
  47433. /**
  47434. * The list of keyboard keys used to control the backward move of the camera.
  47435. */
  47436. keysBackward: number[];
  47437. /**
  47438. * The list of keyboard keys used to control the forward move of the camera.
  47439. */
  47440. keysUp: number[];
  47441. /**
  47442. * The list of keyboard keys used to control the backward move of the camera.
  47443. */
  47444. keysDown: number[];
  47445. /**
  47446. * The list of keyboard keys used to control the right strafe move of the camera.
  47447. */
  47448. keysRight: number[];
  47449. /**
  47450. * The list of keyboard keys used to control the left strafe move of the camera.
  47451. */
  47452. keysLeft: number[];
  47453. private _keys;
  47454. private _onCanvasBlurObserver;
  47455. private _onKeyboardObserver;
  47456. private _engine;
  47457. private _scene;
  47458. /**
  47459. * Attach the input controls to a specific dom element to get the input from.
  47460. * @param element Defines the element the controls should be listened from
  47461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47462. */
  47463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47464. /**
  47465. * Detach the current controls from the specified dom element.
  47466. * @param element Defines the element to stop listening the inputs from
  47467. */
  47468. detachControl(element: Nullable<HTMLElement>): void;
  47469. /**
  47470. * Gets the class name of the current intput.
  47471. * @returns the class name
  47472. */
  47473. getClassName(): string;
  47474. /** @hidden */
  47475. _onLostFocus(e: FocusEvent): void;
  47476. /**
  47477. * Get the friendly name associated with the input class.
  47478. * @returns the input friendly name
  47479. */
  47480. getSimpleName(): string;
  47481. /**
  47482. * Update the current camera state depending on the inputs that have been used this frame.
  47483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47484. */
  47485. checkInputs(): void;
  47486. }
  47487. }
  47488. declare module BABYLON {
  47489. /**
  47490. * Manage the mouse wheel inputs to control a follow camera.
  47491. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47492. */
  47493. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47494. /**
  47495. * Defines the camera the input is attached to.
  47496. */
  47497. camera: FollowCamera;
  47498. /**
  47499. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47500. */
  47501. axisControlRadius: boolean;
  47502. /**
  47503. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47504. */
  47505. axisControlHeight: boolean;
  47506. /**
  47507. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47508. */
  47509. axisControlRotation: boolean;
  47510. /**
  47511. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47512. * relation to mouseWheel events.
  47513. */
  47514. wheelPrecision: number;
  47515. /**
  47516. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47517. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47518. */
  47519. wheelDeltaPercentage: number;
  47520. private _wheel;
  47521. private _observer;
  47522. /**
  47523. * Attach the input controls to a specific dom element to get the input from.
  47524. * @param element Defines the element the controls should be listened from
  47525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47526. */
  47527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47528. /**
  47529. * Detach the current controls from the specified dom element.
  47530. * @param element Defines the element to stop listening the inputs from
  47531. */
  47532. detachControl(element: Nullable<HTMLElement>): void;
  47533. /**
  47534. * Gets the class name of the current intput.
  47535. * @returns the class name
  47536. */
  47537. getClassName(): string;
  47538. /**
  47539. * Get the friendly name associated with the input class.
  47540. * @returns the input friendly name
  47541. */
  47542. getSimpleName(): string;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. /**
  47547. * Manage the pointers inputs to control an follow camera.
  47548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47549. */
  47550. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47551. /**
  47552. * Defines the camera the input is attached to.
  47553. */
  47554. camera: FollowCamera;
  47555. /**
  47556. * Gets the class name of the current input.
  47557. * @returns the class name
  47558. */
  47559. getClassName(): string;
  47560. /**
  47561. * Defines the pointer angular sensibility along the X axis or how fast is
  47562. * the camera rotating.
  47563. * A negative number will reverse the axis direction.
  47564. */
  47565. angularSensibilityX: number;
  47566. /**
  47567. * Defines the pointer angular sensibility along the Y axis or how fast is
  47568. * the camera rotating.
  47569. * A negative number will reverse the axis direction.
  47570. */
  47571. angularSensibilityY: number;
  47572. /**
  47573. * Defines the pointer pinch precision or how fast is the camera zooming.
  47574. * A negative number will reverse the axis direction.
  47575. */
  47576. pinchPrecision: number;
  47577. /**
  47578. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47579. * from 0.
  47580. * It defines the percentage of current camera.radius to use as delta when
  47581. * pinch zoom is used.
  47582. */
  47583. pinchDeltaPercentage: number;
  47584. /**
  47585. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47586. */
  47587. axisXControlRadius: boolean;
  47588. /**
  47589. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47590. */
  47591. axisXControlHeight: boolean;
  47592. /**
  47593. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47594. */
  47595. axisXControlRotation: boolean;
  47596. /**
  47597. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47598. */
  47599. axisYControlRadius: boolean;
  47600. /**
  47601. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47602. */
  47603. axisYControlHeight: boolean;
  47604. /**
  47605. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47606. */
  47607. axisYControlRotation: boolean;
  47608. /**
  47609. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47610. */
  47611. axisPinchControlRadius: boolean;
  47612. /**
  47613. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47614. */
  47615. axisPinchControlHeight: boolean;
  47616. /**
  47617. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47618. */
  47619. axisPinchControlRotation: boolean;
  47620. /**
  47621. * Log error messages if basic misconfiguration has occurred.
  47622. */
  47623. warningEnable: boolean;
  47624. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47625. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47626. private _warningCounter;
  47627. private _warning;
  47628. }
  47629. }
  47630. declare module BABYLON {
  47631. /**
  47632. * Default Inputs manager for the FollowCamera.
  47633. * It groups all the default supported inputs for ease of use.
  47634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47635. */
  47636. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47637. /**
  47638. * Instantiates a new FollowCameraInputsManager.
  47639. * @param camera Defines the camera the inputs belong to
  47640. */
  47641. constructor(camera: FollowCamera);
  47642. /**
  47643. * Add keyboard input support to the input manager.
  47644. * @returns the current input manager
  47645. */
  47646. addKeyboard(): FollowCameraInputsManager;
  47647. /**
  47648. * Add mouse wheel input support to the input manager.
  47649. * @returns the current input manager
  47650. */
  47651. addMouseWheel(): FollowCameraInputsManager;
  47652. /**
  47653. * Add pointers input support to the input manager.
  47654. * @returns the current input manager
  47655. */
  47656. addPointers(): FollowCameraInputsManager;
  47657. /**
  47658. * Add orientation input support to the input manager.
  47659. * @returns the current input manager
  47660. */
  47661. addVRDeviceOrientation(): FollowCameraInputsManager;
  47662. }
  47663. }
  47664. declare module BABYLON {
  47665. /**
  47666. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47667. * an arc rotate version arcFollowCamera are available.
  47668. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47669. */
  47670. export class FollowCamera extends TargetCamera {
  47671. /**
  47672. * Distance the follow camera should follow an object at
  47673. */
  47674. radius: number;
  47675. /**
  47676. * Minimum allowed distance of the camera to the axis of rotation
  47677. * (The camera can not get closer).
  47678. * This can help limiting how the Camera is able to move in the scene.
  47679. */
  47680. lowerRadiusLimit: Nullable<number>;
  47681. /**
  47682. * Maximum allowed distance of the camera to the axis of rotation
  47683. * (The camera can not get further).
  47684. * This can help limiting how the Camera is able to move in the scene.
  47685. */
  47686. upperRadiusLimit: Nullable<number>;
  47687. /**
  47688. * Define a rotation offset between the camera and the object it follows
  47689. */
  47690. rotationOffset: number;
  47691. /**
  47692. * Minimum allowed angle to camera position relative to target object.
  47693. * This can help limiting how the Camera is able to move in the scene.
  47694. */
  47695. lowerRotationOffsetLimit: Nullable<number>;
  47696. /**
  47697. * Maximum allowed angle to camera position relative to target object.
  47698. * This can help limiting how the Camera is able to move in the scene.
  47699. */
  47700. upperRotationOffsetLimit: Nullable<number>;
  47701. /**
  47702. * Define a height offset between the camera and the object it follows.
  47703. * It can help following an object from the top (like a car chaing a plane)
  47704. */
  47705. heightOffset: number;
  47706. /**
  47707. * Minimum allowed height of camera position relative to target object.
  47708. * This can help limiting how the Camera is able to move in the scene.
  47709. */
  47710. lowerHeightOffsetLimit: Nullable<number>;
  47711. /**
  47712. * Maximum allowed height of camera position relative to target object.
  47713. * This can help limiting how the Camera is able to move in the scene.
  47714. */
  47715. upperHeightOffsetLimit: Nullable<number>;
  47716. /**
  47717. * Define how fast the camera can accelerate to follow it s target.
  47718. */
  47719. cameraAcceleration: number;
  47720. /**
  47721. * Define the speed limit of the camera following an object.
  47722. */
  47723. maxCameraSpeed: number;
  47724. /**
  47725. * Define the target of the camera.
  47726. */
  47727. lockedTarget: Nullable<AbstractMesh>;
  47728. /**
  47729. * Defines the input associated with the camera.
  47730. */
  47731. inputs: FollowCameraInputsManager;
  47732. /**
  47733. * Instantiates the follow camera.
  47734. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47735. * @param name Define the name of the camera in the scene
  47736. * @param position Define the position of the camera
  47737. * @param scene Define the scene the camera belong to
  47738. * @param lockedTarget Define the target of the camera
  47739. */
  47740. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47741. private _follow;
  47742. /**
  47743. * Attached controls to the current camera.
  47744. * @param element Defines the element the controls should be listened from
  47745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47746. */
  47747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47748. /**
  47749. * Detach the current controls from the camera.
  47750. * The camera will stop reacting to inputs.
  47751. * @param element Defines the element to stop listening the inputs from
  47752. */
  47753. detachControl(element: HTMLElement): void;
  47754. /** @hidden */
  47755. _checkInputs(): void;
  47756. private _checkLimits;
  47757. /**
  47758. * Gets the camera class name.
  47759. * @returns the class name
  47760. */
  47761. getClassName(): string;
  47762. }
  47763. /**
  47764. * Arc Rotate version of the follow camera.
  47765. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47766. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47767. */
  47768. export class ArcFollowCamera extends TargetCamera {
  47769. /** The longitudinal angle of the camera */
  47770. alpha: number;
  47771. /** The latitudinal angle of the camera */
  47772. beta: number;
  47773. /** The radius of the camera from its target */
  47774. radius: number;
  47775. private _cartesianCoordinates;
  47776. /** Define the camera target (the mesh it should follow) */
  47777. private _meshTarget;
  47778. /**
  47779. * Instantiates a new ArcFollowCamera
  47780. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47781. * @param name Define the name of the camera
  47782. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47783. * @param beta Define the rotation angle of the camera around the elevation axis
  47784. * @param radius Define the radius of the camera from its target point
  47785. * @param target Define the target of the camera
  47786. * @param scene Define the scene the camera belongs to
  47787. */
  47788. constructor(name: string,
  47789. /** The longitudinal angle of the camera */
  47790. alpha: number,
  47791. /** The latitudinal angle of the camera */
  47792. beta: number,
  47793. /** The radius of the camera from its target */
  47794. radius: number,
  47795. /** Define the camera target (the mesh it should follow) */
  47796. target: Nullable<AbstractMesh>, scene: Scene);
  47797. private _follow;
  47798. /** @hidden */
  47799. _checkInputs(): void;
  47800. /**
  47801. * Returns the class name of the object.
  47802. * It is mostly used internally for serialization purposes.
  47803. */
  47804. getClassName(): string;
  47805. }
  47806. }
  47807. declare module BABYLON {
  47808. /**
  47809. * Manage the keyboard inputs to control the movement of a follow camera.
  47810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47811. */
  47812. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47813. /**
  47814. * Defines the camera the input is attached to.
  47815. */
  47816. camera: FollowCamera;
  47817. /**
  47818. * Defines the list of key codes associated with the up action (increase heightOffset)
  47819. */
  47820. keysHeightOffsetIncr: number[];
  47821. /**
  47822. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47823. */
  47824. keysHeightOffsetDecr: number[];
  47825. /**
  47826. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47827. */
  47828. keysHeightOffsetModifierAlt: boolean;
  47829. /**
  47830. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47831. */
  47832. keysHeightOffsetModifierCtrl: boolean;
  47833. /**
  47834. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47835. */
  47836. keysHeightOffsetModifierShift: boolean;
  47837. /**
  47838. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47839. */
  47840. keysRotationOffsetIncr: number[];
  47841. /**
  47842. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47843. */
  47844. keysRotationOffsetDecr: number[];
  47845. /**
  47846. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47847. */
  47848. keysRotationOffsetModifierAlt: boolean;
  47849. /**
  47850. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47851. */
  47852. keysRotationOffsetModifierCtrl: boolean;
  47853. /**
  47854. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47855. */
  47856. keysRotationOffsetModifierShift: boolean;
  47857. /**
  47858. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47859. */
  47860. keysRadiusIncr: number[];
  47861. /**
  47862. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47863. */
  47864. keysRadiusDecr: number[];
  47865. /**
  47866. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47867. */
  47868. keysRadiusModifierAlt: boolean;
  47869. /**
  47870. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47871. */
  47872. keysRadiusModifierCtrl: boolean;
  47873. /**
  47874. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47875. */
  47876. keysRadiusModifierShift: boolean;
  47877. /**
  47878. * Defines the rate of change of heightOffset.
  47879. */
  47880. heightSensibility: number;
  47881. /**
  47882. * Defines the rate of change of rotationOffset.
  47883. */
  47884. rotationSensibility: number;
  47885. /**
  47886. * Defines the rate of change of radius.
  47887. */
  47888. radiusSensibility: number;
  47889. private _keys;
  47890. private _ctrlPressed;
  47891. private _altPressed;
  47892. private _shiftPressed;
  47893. private _onCanvasBlurObserver;
  47894. private _onKeyboardObserver;
  47895. private _engine;
  47896. private _scene;
  47897. /**
  47898. * Attach the input controls to a specific dom element to get the input from.
  47899. * @param element Defines the element the controls should be listened from
  47900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47901. */
  47902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47903. /**
  47904. * Detach the current controls from the specified dom element.
  47905. * @param element Defines the element to stop listening the inputs from
  47906. */
  47907. detachControl(element: Nullable<HTMLElement>): void;
  47908. /**
  47909. * Update the current camera state depending on the inputs that have been used this frame.
  47910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47911. */
  47912. checkInputs(): void;
  47913. /**
  47914. * Gets the class name of the current input.
  47915. * @returns the class name
  47916. */
  47917. getClassName(): string;
  47918. /**
  47919. * Get the friendly name associated with the input class.
  47920. * @returns the input friendly name
  47921. */
  47922. getSimpleName(): string;
  47923. /**
  47924. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47925. * allow modification of the heightOffset value.
  47926. */
  47927. private _modifierHeightOffset;
  47928. /**
  47929. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47930. * allow modification of the rotationOffset value.
  47931. */
  47932. private _modifierRotationOffset;
  47933. /**
  47934. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47935. * allow modification of the radius value.
  47936. */
  47937. private _modifierRadius;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. interface FreeCameraInputsManager {
  47942. /**
  47943. * @hidden
  47944. */
  47945. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47946. /**
  47947. * Add orientation input support to the input manager.
  47948. * @returns the current input manager
  47949. */
  47950. addDeviceOrientation(): FreeCameraInputsManager;
  47951. }
  47952. /**
  47953. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47954. * Screen rotation is taken into account.
  47955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47956. */
  47957. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47958. private _camera;
  47959. private _screenOrientationAngle;
  47960. private _constantTranform;
  47961. private _screenQuaternion;
  47962. private _alpha;
  47963. private _beta;
  47964. private _gamma;
  47965. /**
  47966. * Can be used to detect if a device orientation sensor is available on a device
  47967. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47968. * @returns a promise that will resolve on orientation change
  47969. */
  47970. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47971. /**
  47972. * @hidden
  47973. */
  47974. _onDeviceOrientationChangedObservable: Observable<void>;
  47975. /**
  47976. * Instantiates a new input
  47977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47978. */
  47979. constructor();
  47980. /**
  47981. * Define the camera controlled by the input.
  47982. */
  47983. get camera(): FreeCamera;
  47984. set camera(camera: FreeCamera);
  47985. /**
  47986. * Attach the input controls to a specific dom element to get the input from.
  47987. * @param element Defines the element the controls should be listened from
  47988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47989. */
  47990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47991. private _orientationChanged;
  47992. private _deviceOrientation;
  47993. /**
  47994. * Detach the current controls from the specified dom element.
  47995. * @param element Defines the element to stop listening the inputs from
  47996. */
  47997. detachControl(element: Nullable<HTMLElement>): void;
  47998. /**
  47999. * Update the current camera state depending on the inputs that have been used this frame.
  48000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48001. */
  48002. checkInputs(): void;
  48003. /**
  48004. * Gets the class name of the current intput.
  48005. * @returns the class name
  48006. */
  48007. getClassName(): string;
  48008. /**
  48009. * Get the friendly name associated with the input class.
  48010. * @returns the input friendly name
  48011. */
  48012. getSimpleName(): string;
  48013. }
  48014. }
  48015. declare module BABYLON {
  48016. /**
  48017. * Manage the gamepad inputs to control a free camera.
  48018. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48019. */
  48020. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48021. /**
  48022. * Define the camera the input is attached to.
  48023. */
  48024. camera: FreeCamera;
  48025. /**
  48026. * Define the Gamepad controlling the input
  48027. */
  48028. gamepad: Nullable<Gamepad>;
  48029. /**
  48030. * Defines the gamepad rotation sensiblity.
  48031. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48032. */
  48033. gamepadAngularSensibility: number;
  48034. /**
  48035. * Defines the gamepad move sensiblity.
  48036. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48037. */
  48038. gamepadMoveSensibility: number;
  48039. private _yAxisScale;
  48040. /**
  48041. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48042. */
  48043. get invertYAxis(): boolean;
  48044. set invertYAxis(value: boolean);
  48045. private _onGamepadConnectedObserver;
  48046. private _onGamepadDisconnectedObserver;
  48047. private _cameraTransform;
  48048. private _deltaTransform;
  48049. private _vector3;
  48050. private _vector2;
  48051. /**
  48052. * Attach the input controls to a specific dom element to get the input from.
  48053. * @param element Defines the element the controls should be listened from
  48054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48055. */
  48056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48057. /**
  48058. * Detach the current controls from the specified dom element.
  48059. * @param element Defines the element to stop listening the inputs from
  48060. */
  48061. detachControl(element: Nullable<HTMLElement>): void;
  48062. /**
  48063. * Update the current camera state depending on the inputs that have been used this frame.
  48064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48065. */
  48066. checkInputs(): void;
  48067. /**
  48068. * Gets the class name of the current intput.
  48069. * @returns the class name
  48070. */
  48071. getClassName(): string;
  48072. /**
  48073. * Get the friendly name associated with the input class.
  48074. * @returns the input friendly name
  48075. */
  48076. getSimpleName(): string;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Defines the potential axis of a Joystick
  48082. */
  48083. export enum JoystickAxis {
  48084. /** X axis */
  48085. X = 0,
  48086. /** Y axis */
  48087. Y = 1,
  48088. /** Z axis */
  48089. Z = 2
  48090. }
  48091. /**
  48092. * Represents the different customization options available
  48093. * for VirtualJoystick
  48094. */
  48095. interface VirtualJoystickCustomizations {
  48096. /**
  48097. * Size of the joystick's puck
  48098. */
  48099. puckSize: number;
  48100. /**
  48101. * Size of the joystick's container
  48102. */
  48103. containerSize: number;
  48104. /**
  48105. * Color of the joystick && puck
  48106. */
  48107. color: string;
  48108. /**
  48109. * Image URL for the joystick's puck
  48110. */
  48111. puckImage?: string;
  48112. /**
  48113. * Image URL for the joystick's container
  48114. */
  48115. containerImage?: string;
  48116. /**
  48117. * Defines the unmoving position of the joystick container
  48118. */
  48119. position?: {
  48120. x: number;
  48121. y: number;
  48122. };
  48123. /**
  48124. * Defines whether or not the joystick container is always visible
  48125. */
  48126. alwaysVisible: boolean;
  48127. /**
  48128. * Defines whether or not to limit the movement of the puck to the joystick's container
  48129. */
  48130. limitToContainer: boolean;
  48131. }
  48132. /**
  48133. * Class used to define virtual joystick (used in touch mode)
  48134. */
  48135. export class VirtualJoystick {
  48136. /**
  48137. * Gets or sets a boolean indicating that left and right values must be inverted
  48138. */
  48139. reverseLeftRight: boolean;
  48140. /**
  48141. * Gets or sets a boolean indicating that up and down values must be inverted
  48142. */
  48143. reverseUpDown: boolean;
  48144. /**
  48145. * Gets the offset value for the position (ie. the change of the position value)
  48146. */
  48147. deltaPosition: Vector3;
  48148. /**
  48149. * Gets a boolean indicating if the virtual joystick was pressed
  48150. */
  48151. pressed: boolean;
  48152. /**
  48153. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48154. */
  48155. static Canvas: Nullable<HTMLCanvasElement>;
  48156. /**
  48157. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48158. */
  48159. limitToContainer: boolean;
  48160. private static _globalJoystickIndex;
  48161. private static _alwaysVisibleSticks;
  48162. private static vjCanvasContext;
  48163. private static vjCanvasWidth;
  48164. private static vjCanvasHeight;
  48165. private static halfWidth;
  48166. private static _GetDefaultOptions;
  48167. private _action;
  48168. private _axisTargetedByLeftAndRight;
  48169. private _axisTargetedByUpAndDown;
  48170. private _joystickSensibility;
  48171. private _inversedSensibility;
  48172. private _joystickPointerID;
  48173. private _joystickColor;
  48174. private _joystickPointerPos;
  48175. private _joystickPreviousPointerPos;
  48176. private _joystickPointerStartPos;
  48177. private _deltaJoystickVector;
  48178. private _leftJoystick;
  48179. private _touches;
  48180. private _joystickPosition;
  48181. private _alwaysVisible;
  48182. private _puckImage;
  48183. private _containerImage;
  48184. private _joystickPuckSize;
  48185. private _joystickContainerSize;
  48186. private _clearPuckSize;
  48187. private _clearContainerSize;
  48188. private _clearPuckSizeOffset;
  48189. private _clearContainerSizeOffset;
  48190. private _onPointerDownHandlerRef;
  48191. private _onPointerMoveHandlerRef;
  48192. private _onPointerUpHandlerRef;
  48193. private _onResize;
  48194. /**
  48195. * Creates a new virtual joystick
  48196. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48197. * @param customizations Defines the options we want to customize the VirtualJoystick
  48198. */
  48199. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48200. /**
  48201. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48202. * @param newJoystickSensibility defines the new sensibility
  48203. */
  48204. setJoystickSensibility(newJoystickSensibility: number): void;
  48205. private _onPointerDown;
  48206. private _onPointerMove;
  48207. private _onPointerUp;
  48208. /**
  48209. * Change the color of the virtual joystick
  48210. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48211. */
  48212. setJoystickColor(newColor: string): void;
  48213. /**
  48214. * Size of the joystick's container
  48215. */
  48216. set containerSize(newSize: number);
  48217. get containerSize(): number;
  48218. /**
  48219. * Size of the joystick's puck
  48220. */
  48221. set puckSize(newSize: number);
  48222. get puckSize(): number;
  48223. /**
  48224. * Clears the set position of the joystick
  48225. */
  48226. clearPosition(): void;
  48227. /**
  48228. * Defines whether or not the joystick container is always visible
  48229. */
  48230. set alwaysVisible(value: boolean);
  48231. get alwaysVisible(): boolean;
  48232. /**
  48233. * Sets the constant position of the Joystick container
  48234. * @param x X axis coordinate
  48235. * @param y Y axis coordinate
  48236. */
  48237. setPosition(x: number, y: number): void;
  48238. /**
  48239. * Defines a callback to call when the joystick is touched
  48240. * @param action defines the callback
  48241. */
  48242. setActionOnTouch(action: () => any): void;
  48243. /**
  48244. * Defines which axis you'd like to control for left & right
  48245. * @param axis defines the axis to use
  48246. */
  48247. setAxisForLeftRight(axis: JoystickAxis): void;
  48248. /**
  48249. * Defines which axis you'd like to control for up & down
  48250. * @param axis defines the axis to use
  48251. */
  48252. setAxisForUpDown(axis: JoystickAxis): void;
  48253. /**
  48254. * Clears the canvas from the previous puck / container draw
  48255. */
  48256. private _clearPreviousDraw;
  48257. /**
  48258. * Loads `urlPath` to be used for the container's image
  48259. * @param urlPath defines the urlPath of an image to use
  48260. */
  48261. setContainerImage(urlPath: string): void;
  48262. /**
  48263. * Loads `urlPath` to be used for the puck's image
  48264. * @param urlPath defines the urlPath of an image to use
  48265. */
  48266. setPuckImage(urlPath: string): void;
  48267. /**
  48268. * Draws the Virtual Joystick's container
  48269. */
  48270. private _drawContainer;
  48271. /**
  48272. * Draws the Virtual Joystick's puck
  48273. */
  48274. private _drawPuck;
  48275. private _drawVirtualJoystick;
  48276. /**
  48277. * Release internal HTML canvas
  48278. */
  48279. releaseCanvas(): void;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. interface FreeCameraInputsManager {
  48284. /**
  48285. * Add virtual joystick input support to the input manager.
  48286. * @returns the current input manager
  48287. */
  48288. addVirtualJoystick(): FreeCameraInputsManager;
  48289. }
  48290. /**
  48291. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48292. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48293. */
  48294. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48295. /**
  48296. * Defines the camera the input is attached to.
  48297. */
  48298. camera: FreeCamera;
  48299. private _leftjoystick;
  48300. private _rightjoystick;
  48301. /**
  48302. * Gets the left stick of the virtual joystick.
  48303. * @returns The virtual Joystick
  48304. */
  48305. getLeftJoystick(): VirtualJoystick;
  48306. /**
  48307. * Gets the right stick of the virtual joystick.
  48308. * @returns The virtual Joystick
  48309. */
  48310. getRightJoystick(): VirtualJoystick;
  48311. /**
  48312. * Update the current camera state depending on the inputs that have been used this frame.
  48313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48314. */
  48315. checkInputs(): void;
  48316. /**
  48317. * Attach the input controls to a specific dom element to get the input from.
  48318. * @param element Defines the element the controls should be listened from
  48319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48320. */
  48321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48322. /**
  48323. * Detach the current controls from the specified dom element.
  48324. * @param element Defines the element to stop listening the inputs from
  48325. */
  48326. detachControl(element: Nullable<HTMLElement>): void;
  48327. /**
  48328. * Gets the class name of the current intput.
  48329. * @returns the class name
  48330. */
  48331. getClassName(): string;
  48332. /**
  48333. * Get the friendly name associated with the input class.
  48334. * @returns the input friendly name
  48335. */
  48336. getSimpleName(): string;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /**
  48341. * This represents a FPS type of camera controlled by touch.
  48342. * This is like a universal camera minus the Gamepad controls.
  48343. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48344. */
  48345. export class TouchCamera extends FreeCamera {
  48346. /**
  48347. * Defines the touch sensibility for rotation.
  48348. * The higher the faster.
  48349. */
  48350. get touchAngularSensibility(): number;
  48351. set touchAngularSensibility(value: number);
  48352. /**
  48353. * Defines the touch sensibility for move.
  48354. * The higher the faster.
  48355. */
  48356. get touchMoveSensibility(): number;
  48357. set touchMoveSensibility(value: number);
  48358. /**
  48359. * Instantiates a new touch camera.
  48360. * This represents a FPS type of camera controlled by touch.
  48361. * This is like a universal camera minus the Gamepad controls.
  48362. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48363. * @param name Define the name of the camera in the scene
  48364. * @param position Define the start position of the camera in the scene
  48365. * @param scene Define the scene the camera belongs to
  48366. */
  48367. constructor(name: string, position: Vector3, scene: Scene);
  48368. /**
  48369. * Gets the current object class name.
  48370. * @return the class name
  48371. */
  48372. getClassName(): string;
  48373. /** @hidden */
  48374. _setupInputs(): void;
  48375. }
  48376. }
  48377. declare module BABYLON {
  48378. /**
  48379. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48380. * being tilted forward or back and left or right.
  48381. */
  48382. export class DeviceOrientationCamera extends FreeCamera {
  48383. private _initialQuaternion;
  48384. private _quaternionCache;
  48385. private _tmpDragQuaternion;
  48386. private _disablePointerInputWhenUsingDeviceOrientation;
  48387. /**
  48388. * Creates a new device orientation camera
  48389. * @param name The name of the camera
  48390. * @param position The start position camera
  48391. * @param scene The scene the camera belongs to
  48392. */
  48393. constructor(name: string, position: Vector3, scene: Scene);
  48394. /**
  48395. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48396. */
  48397. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48398. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48399. private _dragFactor;
  48400. /**
  48401. * Enabled turning on the y axis when the orientation sensor is active
  48402. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48403. */
  48404. enableHorizontalDragging(dragFactor?: number): void;
  48405. /**
  48406. * Gets the current instance class name ("DeviceOrientationCamera").
  48407. * This helps avoiding instanceof at run time.
  48408. * @returns the class name
  48409. */
  48410. getClassName(): string;
  48411. /**
  48412. * @hidden
  48413. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48414. */
  48415. _checkInputs(): void;
  48416. /**
  48417. * Reset the camera to its default orientation on the specified axis only.
  48418. * @param axis The axis to reset
  48419. */
  48420. resetToCurrentRotation(axis?: Axis): void;
  48421. }
  48422. }
  48423. declare module BABYLON {
  48424. /**
  48425. * Defines supported buttons for XBox360 compatible gamepads
  48426. */
  48427. export enum Xbox360Button {
  48428. /** A */
  48429. A = 0,
  48430. /** B */
  48431. B = 1,
  48432. /** X */
  48433. X = 2,
  48434. /** Y */
  48435. Y = 3,
  48436. /** Left button */
  48437. LB = 4,
  48438. /** Right button */
  48439. RB = 5,
  48440. /** Back */
  48441. Back = 8,
  48442. /** Start */
  48443. Start = 9,
  48444. /** Left stick */
  48445. LeftStick = 10,
  48446. /** Right stick */
  48447. RightStick = 11
  48448. }
  48449. /** Defines values for XBox360 DPad */
  48450. export enum Xbox360Dpad {
  48451. /** Up */
  48452. Up = 12,
  48453. /** Down */
  48454. Down = 13,
  48455. /** Left */
  48456. Left = 14,
  48457. /** Right */
  48458. Right = 15
  48459. }
  48460. /**
  48461. * Defines a XBox360 gamepad
  48462. */
  48463. export class Xbox360Pad extends Gamepad {
  48464. private _leftTrigger;
  48465. private _rightTrigger;
  48466. private _onlefttriggerchanged;
  48467. private _onrighttriggerchanged;
  48468. private _onbuttondown;
  48469. private _onbuttonup;
  48470. private _ondpaddown;
  48471. private _ondpadup;
  48472. /** Observable raised when a button is pressed */
  48473. onButtonDownObservable: Observable<Xbox360Button>;
  48474. /** Observable raised when a button is released */
  48475. onButtonUpObservable: Observable<Xbox360Button>;
  48476. /** Observable raised when a pad is pressed */
  48477. onPadDownObservable: Observable<Xbox360Dpad>;
  48478. /** Observable raised when a pad is released */
  48479. onPadUpObservable: Observable<Xbox360Dpad>;
  48480. private _buttonA;
  48481. private _buttonB;
  48482. private _buttonX;
  48483. private _buttonY;
  48484. private _buttonBack;
  48485. private _buttonStart;
  48486. private _buttonLB;
  48487. private _buttonRB;
  48488. private _buttonLeftStick;
  48489. private _buttonRightStick;
  48490. private _dPadUp;
  48491. private _dPadDown;
  48492. private _dPadLeft;
  48493. private _dPadRight;
  48494. private _isXboxOnePad;
  48495. /**
  48496. * Creates a new XBox360 gamepad object
  48497. * @param id defines the id of this gamepad
  48498. * @param index defines its index
  48499. * @param gamepad defines the internal HTML gamepad object
  48500. * @param xboxOne defines if it is a XBox One gamepad
  48501. */
  48502. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48503. /**
  48504. * Defines the callback to call when left trigger is pressed
  48505. * @param callback defines the callback to use
  48506. */
  48507. onlefttriggerchanged(callback: (value: number) => void): void;
  48508. /**
  48509. * Defines the callback to call when right trigger is pressed
  48510. * @param callback defines the callback to use
  48511. */
  48512. onrighttriggerchanged(callback: (value: number) => void): void;
  48513. /**
  48514. * Gets the left trigger value
  48515. */
  48516. get leftTrigger(): number;
  48517. /**
  48518. * Sets the left trigger value
  48519. */
  48520. set leftTrigger(newValue: number);
  48521. /**
  48522. * Gets the right trigger value
  48523. */
  48524. get rightTrigger(): number;
  48525. /**
  48526. * Sets the right trigger value
  48527. */
  48528. set rightTrigger(newValue: number);
  48529. /**
  48530. * Defines the callback to call when a button is pressed
  48531. * @param callback defines the callback to use
  48532. */
  48533. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48534. /**
  48535. * Defines the callback to call when a button is released
  48536. * @param callback defines the callback to use
  48537. */
  48538. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48539. /**
  48540. * Defines the callback to call when a pad is pressed
  48541. * @param callback defines the callback to use
  48542. */
  48543. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48544. /**
  48545. * Defines the callback to call when a pad is released
  48546. * @param callback defines the callback to use
  48547. */
  48548. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48549. private _setButtonValue;
  48550. private _setDPadValue;
  48551. /**
  48552. * Gets the value of the `A` button
  48553. */
  48554. get buttonA(): number;
  48555. /**
  48556. * Sets the value of the `A` button
  48557. */
  48558. set buttonA(value: number);
  48559. /**
  48560. * Gets the value of the `B` button
  48561. */
  48562. get buttonB(): number;
  48563. /**
  48564. * Sets the value of the `B` button
  48565. */
  48566. set buttonB(value: number);
  48567. /**
  48568. * Gets the value of the `X` button
  48569. */
  48570. get buttonX(): number;
  48571. /**
  48572. * Sets the value of the `X` button
  48573. */
  48574. set buttonX(value: number);
  48575. /**
  48576. * Gets the value of the `Y` button
  48577. */
  48578. get buttonY(): number;
  48579. /**
  48580. * Sets the value of the `Y` button
  48581. */
  48582. set buttonY(value: number);
  48583. /**
  48584. * Gets the value of the `Start` button
  48585. */
  48586. get buttonStart(): number;
  48587. /**
  48588. * Sets the value of the `Start` button
  48589. */
  48590. set buttonStart(value: number);
  48591. /**
  48592. * Gets the value of the `Back` button
  48593. */
  48594. get buttonBack(): number;
  48595. /**
  48596. * Sets the value of the `Back` button
  48597. */
  48598. set buttonBack(value: number);
  48599. /**
  48600. * Gets the value of the `Left` button
  48601. */
  48602. get buttonLB(): number;
  48603. /**
  48604. * Sets the value of the `Left` button
  48605. */
  48606. set buttonLB(value: number);
  48607. /**
  48608. * Gets the value of the `Right` button
  48609. */
  48610. get buttonRB(): number;
  48611. /**
  48612. * Sets the value of the `Right` button
  48613. */
  48614. set buttonRB(value: number);
  48615. /**
  48616. * Gets the value of the Left joystick
  48617. */
  48618. get buttonLeftStick(): number;
  48619. /**
  48620. * Sets the value of the Left joystick
  48621. */
  48622. set buttonLeftStick(value: number);
  48623. /**
  48624. * Gets the value of the Right joystick
  48625. */
  48626. get buttonRightStick(): number;
  48627. /**
  48628. * Sets the value of the Right joystick
  48629. */
  48630. set buttonRightStick(value: number);
  48631. /**
  48632. * Gets the value of D-pad up
  48633. */
  48634. get dPadUp(): number;
  48635. /**
  48636. * Sets the value of D-pad up
  48637. */
  48638. set dPadUp(value: number);
  48639. /**
  48640. * Gets the value of D-pad down
  48641. */
  48642. get dPadDown(): number;
  48643. /**
  48644. * Sets the value of D-pad down
  48645. */
  48646. set dPadDown(value: number);
  48647. /**
  48648. * Gets the value of D-pad left
  48649. */
  48650. get dPadLeft(): number;
  48651. /**
  48652. * Sets the value of D-pad left
  48653. */
  48654. set dPadLeft(value: number);
  48655. /**
  48656. * Gets the value of D-pad right
  48657. */
  48658. get dPadRight(): number;
  48659. /**
  48660. * Sets the value of D-pad right
  48661. */
  48662. set dPadRight(value: number);
  48663. /**
  48664. * Force the gamepad to synchronize with device values
  48665. */
  48666. update(): void;
  48667. /**
  48668. * Disposes the gamepad
  48669. */
  48670. dispose(): void;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /**
  48675. * Defines supported buttons for DualShock compatible gamepads
  48676. */
  48677. export enum DualShockButton {
  48678. /** Cross */
  48679. Cross = 0,
  48680. /** Circle */
  48681. Circle = 1,
  48682. /** Square */
  48683. Square = 2,
  48684. /** Triangle */
  48685. Triangle = 3,
  48686. /** L1 */
  48687. L1 = 4,
  48688. /** R1 */
  48689. R1 = 5,
  48690. /** Share */
  48691. Share = 8,
  48692. /** Options */
  48693. Options = 9,
  48694. /** Left stick */
  48695. LeftStick = 10,
  48696. /** Right stick */
  48697. RightStick = 11
  48698. }
  48699. /** Defines values for DualShock DPad */
  48700. export enum DualShockDpad {
  48701. /** Up */
  48702. Up = 12,
  48703. /** Down */
  48704. Down = 13,
  48705. /** Left */
  48706. Left = 14,
  48707. /** Right */
  48708. Right = 15
  48709. }
  48710. /**
  48711. * Defines a DualShock gamepad
  48712. */
  48713. export class DualShockPad extends Gamepad {
  48714. private _leftTrigger;
  48715. private _rightTrigger;
  48716. private _onlefttriggerchanged;
  48717. private _onrighttriggerchanged;
  48718. private _onbuttondown;
  48719. private _onbuttonup;
  48720. private _ondpaddown;
  48721. private _ondpadup;
  48722. /** Observable raised when a button is pressed */
  48723. onButtonDownObservable: Observable<DualShockButton>;
  48724. /** Observable raised when a button is released */
  48725. onButtonUpObservable: Observable<DualShockButton>;
  48726. /** Observable raised when a pad is pressed */
  48727. onPadDownObservable: Observable<DualShockDpad>;
  48728. /** Observable raised when a pad is released */
  48729. onPadUpObservable: Observable<DualShockDpad>;
  48730. private _buttonCross;
  48731. private _buttonCircle;
  48732. private _buttonSquare;
  48733. private _buttonTriangle;
  48734. private _buttonShare;
  48735. private _buttonOptions;
  48736. private _buttonL1;
  48737. private _buttonR1;
  48738. private _buttonLeftStick;
  48739. private _buttonRightStick;
  48740. private _dPadUp;
  48741. private _dPadDown;
  48742. private _dPadLeft;
  48743. private _dPadRight;
  48744. /**
  48745. * Creates a new DualShock gamepad object
  48746. * @param id defines the id of this gamepad
  48747. * @param index defines its index
  48748. * @param gamepad defines the internal HTML gamepad object
  48749. */
  48750. constructor(id: string, index: number, gamepad: any);
  48751. /**
  48752. * Defines the callback to call when left trigger is pressed
  48753. * @param callback defines the callback to use
  48754. */
  48755. onlefttriggerchanged(callback: (value: number) => void): void;
  48756. /**
  48757. * Defines the callback to call when right trigger is pressed
  48758. * @param callback defines the callback to use
  48759. */
  48760. onrighttriggerchanged(callback: (value: number) => void): void;
  48761. /**
  48762. * Gets the left trigger value
  48763. */
  48764. get leftTrigger(): number;
  48765. /**
  48766. * Sets the left trigger value
  48767. */
  48768. set leftTrigger(newValue: number);
  48769. /**
  48770. * Gets the right trigger value
  48771. */
  48772. get rightTrigger(): number;
  48773. /**
  48774. * Sets the right trigger value
  48775. */
  48776. set rightTrigger(newValue: number);
  48777. /**
  48778. * Defines the callback to call when a button is pressed
  48779. * @param callback defines the callback to use
  48780. */
  48781. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48782. /**
  48783. * Defines the callback to call when a button is released
  48784. * @param callback defines the callback to use
  48785. */
  48786. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48787. /**
  48788. * Defines the callback to call when a pad is pressed
  48789. * @param callback defines the callback to use
  48790. */
  48791. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48792. /**
  48793. * Defines the callback to call when a pad is released
  48794. * @param callback defines the callback to use
  48795. */
  48796. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48797. private _setButtonValue;
  48798. private _setDPadValue;
  48799. /**
  48800. * Gets the value of the `Cross` button
  48801. */
  48802. get buttonCross(): number;
  48803. /**
  48804. * Sets the value of the `Cross` button
  48805. */
  48806. set buttonCross(value: number);
  48807. /**
  48808. * Gets the value of the `Circle` button
  48809. */
  48810. get buttonCircle(): number;
  48811. /**
  48812. * Sets the value of the `Circle` button
  48813. */
  48814. set buttonCircle(value: number);
  48815. /**
  48816. * Gets the value of the `Square` button
  48817. */
  48818. get buttonSquare(): number;
  48819. /**
  48820. * Sets the value of the `Square` button
  48821. */
  48822. set buttonSquare(value: number);
  48823. /**
  48824. * Gets the value of the `Triangle` button
  48825. */
  48826. get buttonTriangle(): number;
  48827. /**
  48828. * Sets the value of the `Triangle` button
  48829. */
  48830. set buttonTriangle(value: number);
  48831. /**
  48832. * Gets the value of the `Options` button
  48833. */
  48834. get buttonOptions(): number;
  48835. /**
  48836. * Sets the value of the `Options` button
  48837. */
  48838. set buttonOptions(value: number);
  48839. /**
  48840. * Gets the value of the `Share` button
  48841. */
  48842. get buttonShare(): number;
  48843. /**
  48844. * Sets the value of the `Share` button
  48845. */
  48846. set buttonShare(value: number);
  48847. /**
  48848. * Gets the value of the `L1` button
  48849. */
  48850. get buttonL1(): number;
  48851. /**
  48852. * Sets the value of the `L1` button
  48853. */
  48854. set buttonL1(value: number);
  48855. /**
  48856. * Gets the value of the `R1` button
  48857. */
  48858. get buttonR1(): number;
  48859. /**
  48860. * Sets the value of the `R1` button
  48861. */
  48862. set buttonR1(value: number);
  48863. /**
  48864. * Gets the value of the Left joystick
  48865. */
  48866. get buttonLeftStick(): number;
  48867. /**
  48868. * Sets the value of the Left joystick
  48869. */
  48870. set buttonLeftStick(value: number);
  48871. /**
  48872. * Gets the value of the Right joystick
  48873. */
  48874. get buttonRightStick(): number;
  48875. /**
  48876. * Sets the value of the Right joystick
  48877. */
  48878. set buttonRightStick(value: number);
  48879. /**
  48880. * Gets the value of D-pad up
  48881. */
  48882. get dPadUp(): number;
  48883. /**
  48884. * Sets the value of D-pad up
  48885. */
  48886. set dPadUp(value: number);
  48887. /**
  48888. * Gets the value of D-pad down
  48889. */
  48890. get dPadDown(): number;
  48891. /**
  48892. * Sets the value of D-pad down
  48893. */
  48894. set dPadDown(value: number);
  48895. /**
  48896. * Gets the value of D-pad left
  48897. */
  48898. get dPadLeft(): number;
  48899. /**
  48900. * Sets the value of D-pad left
  48901. */
  48902. set dPadLeft(value: number);
  48903. /**
  48904. * Gets the value of D-pad right
  48905. */
  48906. get dPadRight(): number;
  48907. /**
  48908. * Sets the value of D-pad right
  48909. */
  48910. set dPadRight(value: number);
  48911. /**
  48912. * Force the gamepad to synchronize with device values
  48913. */
  48914. update(): void;
  48915. /**
  48916. * Disposes the gamepad
  48917. */
  48918. dispose(): void;
  48919. }
  48920. }
  48921. declare module BABYLON {
  48922. /**
  48923. * Manager for handling gamepads
  48924. */
  48925. export class GamepadManager {
  48926. private _scene?;
  48927. private _babylonGamepads;
  48928. private _oneGamepadConnected;
  48929. /** @hidden */
  48930. _isMonitoring: boolean;
  48931. private _gamepadEventSupported;
  48932. private _gamepadSupport?;
  48933. /**
  48934. * observable to be triggered when the gamepad controller has been connected
  48935. */
  48936. onGamepadConnectedObservable: Observable<Gamepad>;
  48937. /**
  48938. * observable to be triggered when the gamepad controller has been disconnected
  48939. */
  48940. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48941. private _onGamepadConnectedEvent;
  48942. private _onGamepadDisconnectedEvent;
  48943. /**
  48944. * Initializes the gamepad manager
  48945. * @param _scene BabylonJS scene
  48946. */
  48947. constructor(_scene?: Scene | undefined);
  48948. /**
  48949. * The gamepads in the game pad manager
  48950. */
  48951. get gamepads(): Gamepad[];
  48952. /**
  48953. * Get the gamepad controllers based on type
  48954. * @param type The type of gamepad controller
  48955. * @returns Nullable gamepad
  48956. */
  48957. getGamepadByType(type?: number): Nullable<Gamepad>;
  48958. /**
  48959. * Disposes the gamepad manager
  48960. */
  48961. dispose(): void;
  48962. private _addNewGamepad;
  48963. private _startMonitoringGamepads;
  48964. private _stopMonitoringGamepads;
  48965. /** @hidden */
  48966. _checkGamepadsStatus(): void;
  48967. private _updateGamepadObjects;
  48968. }
  48969. }
  48970. declare module BABYLON {
  48971. interface Scene {
  48972. /** @hidden */
  48973. _gamepadManager: Nullable<GamepadManager>;
  48974. /**
  48975. * Gets the gamepad manager associated with the scene
  48976. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48977. */
  48978. gamepadManager: GamepadManager;
  48979. }
  48980. /**
  48981. * Interface representing a free camera inputs manager
  48982. */
  48983. interface FreeCameraInputsManager {
  48984. /**
  48985. * Adds gamepad input support to the FreeCameraInputsManager.
  48986. * @returns the FreeCameraInputsManager
  48987. */
  48988. addGamepad(): FreeCameraInputsManager;
  48989. }
  48990. /**
  48991. * Interface representing an arc rotate camera inputs manager
  48992. */
  48993. interface ArcRotateCameraInputsManager {
  48994. /**
  48995. * Adds gamepad input support to the ArcRotateCamera InputManager.
  48996. * @returns the camera inputs manager
  48997. */
  48998. addGamepad(): ArcRotateCameraInputsManager;
  48999. }
  49000. /**
  49001. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49002. */
  49003. export class GamepadSystemSceneComponent implements ISceneComponent {
  49004. /**
  49005. * The component name helpfull to identify the component in the list of scene components.
  49006. */
  49007. readonly name: string;
  49008. /**
  49009. * The scene the component belongs to.
  49010. */
  49011. scene: Scene;
  49012. /**
  49013. * Creates a new instance of the component for the given scene
  49014. * @param scene Defines the scene to register the component in
  49015. */
  49016. constructor(scene: Scene);
  49017. /**
  49018. * Registers the component in a given scene
  49019. */
  49020. register(): void;
  49021. /**
  49022. * Rebuilds the elements related to this component in case of
  49023. * context lost for instance.
  49024. */
  49025. rebuild(): void;
  49026. /**
  49027. * Disposes the component and the associated ressources
  49028. */
  49029. dispose(): void;
  49030. private _beforeCameraUpdate;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * 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,
  49036. * which still works and will still be found in many Playgrounds.
  49037. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49038. */
  49039. export class UniversalCamera extends TouchCamera {
  49040. /**
  49041. * Defines the gamepad rotation sensiblity.
  49042. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49043. */
  49044. get gamepadAngularSensibility(): number;
  49045. set gamepadAngularSensibility(value: number);
  49046. /**
  49047. * Defines the gamepad move sensiblity.
  49048. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49049. */
  49050. get gamepadMoveSensibility(): number;
  49051. set gamepadMoveSensibility(value: number);
  49052. /**
  49053. * 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,
  49054. * which still works and will still be found in many Playgrounds.
  49055. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49056. * @param name Define the name of the camera in the scene
  49057. * @param position Define the start position of the camera in the scene
  49058. * @param scene Define the scene the camera belongs to
  49059. */
  49060. constructor(name: string, position: Vector3, scene: Scene);
  49061. /**
  49062. * Gets the current object class name.
  49063. * @return the class name
  49064. */
  49065. getClassName(): string;
  49066. }
  49067. }
  49068. declare module BABYLON {
  49069. /**
  49070. * This represents a FPS type of camera. This is only here for back compat purpose.
  49071. * Please use the UniversalCamera instead as both are identical.
  49072. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49073. */
  49074. export class GamepadCamera extends UniversalCamera {
  49075. /**
  49076. * Instantiates a new Gamepad Camera
  49077. * This represents a FPS type of camera. This is only here for back compat purpose.
  49078. * Please use the UniversalCamera instead as both are identical.
  49079. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49080. * @param name Define the name of the camera in the scene
  49081. * @param position Define the start position of the camera in the scene
  49082. * @param scene Define the scene the camera belongs to
  49083. */
  49084. constructor(name: string, position: Vector3, scene: Scene);
  49085. /**
  49086. * Gets the current object class name.
  49087. * @return the class name
  49088. */
  49089. getClassName(): string;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /** @hidden */
  49094. export var passPixelShader: {
  49095. name: string;
  49096. shader: string;
  49097. };
  49098. }
  49099. declare module BABYLON {
  49100. /** @hidden */
  49101. export var passCubePixelShader: {
  49102. name: string;
  49103. shader: string;
  49104. };
  49105. }
  49106. declare module BABYLON {
  49107. /**
  49108. * PassPostProcess which produces an output the same as it's input
  49109. */
  49110. export class PassPostProcess extends PostProcess {
  49111. /**
  49112. * Gets a string identifying the name of the class
  49113. * @returns "PassPostProcess" string
  49114. */
  49115. getClassName(): string;
  49116. /**
  49117. * Creates the PassPostProcess
  49118. * @param name The name of the effect.
  49119. * @param options The required width/height ratio to downsize to before computing the render pass.
  49120. * @param camera The camera to apply the render pass to.
  49121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49122. * @param engine The engine which the post process will be applied. (default: current engine)
  49123. * @param reusable If the post process can be reused on the same frame. (default: false)
  49124. * @param textureType The type of texture to be used when performing the post processing.
  49125. * @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)
  49126. */
  49127. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49128. /** @hidden */
  49129. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49130. }
  49131. /**
  49132. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49133. */
  49134. export class PassCubePostProcess extends PostProcess {
  49135. private _face;
  49136. /**
  49137. * Gets or sets the cube face to display.
  49138. * * 0 is +X
  49139. * * 1 is -X
  49140. * * 2 is +Y
  49141. * * 3 is -Y
  49142. * * 4 is +Z
  49143. * * 5 is -Z
  49144. */
  49145. get face(): number;
  49146. set face(value: number);
  49147. /**
  49148. * Gets a string identifying the name of the class
  49149. * @returns "PassCubePostProcess" string
  49150. */
  49151. getClassName(): string;
  49152. /**
  49153. * Creates the PassCubePostProcess
  49154. * @param name The name of the effect.
  49155. * @param options The required width/height ratio to downsize to before computing the render pass.
  49156. * @param camera The camera to apply the render pass to.
  49157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49158. * @param engine The engine which the post process will be applied. (default: current engine)
  49159. * @param reusable If the post process can be reused on the same frame. (default: false)
  49160. * @param textureType The type of texture to be used when performing the post processing.
  49161. * @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)
  49162. */
  49163. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49164. /** @hidden */
  49165. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. /** @hidden */
  49170. export var anaglyphPixelShader: {
  49171. name: string;
  49172. shader: string;
  49173. };
  49174. }
  49175. declare module BABYLON {
  49176. /**
  49177. * Postprocess used to generate anaglyphic rendering
  49178. */
  49179. export class AnaglyphPostProcess extends PostProcess {
  49180. private _passedProcess;
  49181. /**
  49182. * Gets a string identifying the name of the class
  49183. * @returns "AnaglyphPostProcess" string
  49184. */
  49185. getClassName(): string;
  49186. /**
  49187. * Creates a new AnaglyphPostProcess
  49188. * @param name defines postprocess name
  49189. * @param options defines creation options or target ratio scale
  49190. * @param rigCameras defines cameras using this postprocess
  49191. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49192. * @param engine defines hosting engine
  49193. * @param reusable defines if the postprocess will be reused multiple times per frame
  49194. */
  49195. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49196. }
  49197. }
  49198. declare module BABYLON {
  49199. /**
  49200. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49201. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49202. */
  49203. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49204. /**
  49205. * Creates a new AnaglyphArcRotateCamera
  49206. * @param name defines camera name
  49207. * @param alpha defines alpha angle (in radians)
  49208. * @param beta defines beta angle (in radians)
  49209. * @param radius defines radius
  49210. * @param target defines camera target
  49211. * @param interaxialDistance defines distance between each color axis
  49212. * @param scene defines the hosting scene
  49213. */
  49214. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49215. /**
  49216. * Gets camera class name
  49217. * @returns AnaglyphArcRotateCamera
  49218. */
  49219. getClassName(): string;
  49220. }
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49225. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49226. */
  49227. export class AnaglyphFreeCamera extends FreeCamera {
  49228. /**
  49229. * Creates a new AnaglyphFreeCamera
  49230. * @param name defines camera name
  49231. * @param position defines initial position
  49232. * @param interaxialDistance defines distance between each color axis
  49233. * @param scene defines the hosting scene
  49234. */
  49235. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49236. /**
  49237. * Gets camera class name
  49238. * @returns AnaglyphFreeCamera
  49239. */
  49240. getClassName(): string;
  49241. }
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49246. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49247. */
  49248. export class AnaglyphGamepadCamera extends GamepadCamera {
  49249. /**
  49250. * Creates a new AnaglyphGamepadCamera
  49251. * @param name defines camera name
  49252. * @param position defines initial position
  49253. * @param interaxialDistance defines distance between each color axis
  49254. * @param scene defines the hosting scene
  49255. */
  49256. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49257. /**
  49258. * Gets camera class name
  49259. * @returns AnaglyphGamepadCamera
  49260. */
  49261. getClassName(): string;
  49262. }
  49263. }
  49264. declare module BABYLON {
  49265. /**
  49266. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49267. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49268. */
  49269. export class AnaglyphUniversalCamera extends UniversalCamera {
  49270. /**
  49271. * Creates a new AnaglyphUniversalCamera
  49272. * @param name defines camera name
  49273. * @param position defines initial position
  49274. * @param interaxialDistance defines distance between each color axis
  49275. * @param scene defines the hosting scene
  49276. */
  49277. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49278. /**
  49279. * Gets camera class name
  49280. * @returns AnaglyphUniversalCamera
  49281. */
  49282. getClassName(): string;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49288. * @see https://doc.babylonjs.com/features/cameras
  49289. */
  49290. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49291. /**
  49292. * Creates a new StereoscopicArcRotateCamera
  49293. * @param name defines camera name
  49294. * @param alpha defines alpha angle (in radians)
  49295. * @param beta defines beta angle (in radians)
  49296. * @param radius defines radius
  49297. * @param target defines camera target
  49298. * @param interaxialDistance defines distance between each color axis
  49299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49300. * @param scene defines the hosting scene
  49301. */
  49302. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49303. /**
  49304. * Gets camera class name
  49305. * @returns StereoscopicArcRotateCamera
  49306. */
  49307. getClassName(): string;
  49308. }
  49309. }
  49310. declare module BABYLON {
  49311. /**
  49312. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49313. * @see https://doc.babylonjs.com/features/cameras
  49314. */
  49315. export class StereoscopicFreeCamera extends FreeCamera {
  49316. /**
  49317. * Creates a new StereoscopicFreeCamera
  49318. * @param name defines camera name
  49319. * @param position defines initial position
  49320. * @param interaxialDistance defines distance between each color axis
  49321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49322. * @param scene defines the hosting scene
  49323. */
  49324. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49325. /**
  49326. * Gets camera class name
  49327. * @returns StereoscopicFreeCamera
  49328. */
  49329. getClassName(): string;
  49330. }
  49331. }
  49332. declare module BABYLON {
  49333. /**
  49334. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49335. * @see https://doc.babylonjs.com/features/cameras
  49336. */
  49337. export class StereoscopicGamepadCamera extends GamepadCamera {
  49338. /**
  49339. * Creates a new StereoscopicGamepadCamera
  49340. * @param name defines camera name
  49341. * @param position defines initial position
  49342. * @param interaxialDistance defines distance between each color axis
  49343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49344. * @param scene defines the hosting scene
  49345. */
  49346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49347. /**
  49348. * Gets camera class name
  49349. * @returns StereoscopicGamepadCamera
  49350. */
  49351. getClassName(): string;
  49352. }
  49353. }
  49354. declare module BABYLON {
  49355. /**
  49356. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49357. * @see https://doc.babylonjs.com/features/cameras
  49358. */
  49359. export class StereoscopicUniversalCamera extends UniversalCamera {
  49360. /**
  49361. * Creates a new StereoscopicUniversalCamera
  49362. * @param name defines camera name
  49363. * @param position defines initial position
  49364. * @param interaxialDistance defines distance between each color axis
  49365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49366. * @param scene defines the hosting scene
  49367. */
  49368. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49369. /**
  49370. * Gets camera class name
  49371. * @returns StereoscopicUniversalCamera
  49372. */
  49373. getClassName(): string;
  49374. }
  49375. }
  49376. declare module BABYLON {
  49377. /**
  49378. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49379. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49380. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49381. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49382. */
  49383. export class VirtualJoysticksCamera extends FreeCamera {
  49384. /**
  49385. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49386. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49387. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49388. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49389. * @param name Define the name of the camera in the scene
  49390. * @param position Define the start position of the camera in the scene
  49391. * @param scene Define the scene the camera belongs to
  49392. */
  49393. constructor(name: string, position: Vector3, scene: Scene);
  49394. /**
  49395. * Gets the current object class name.
  49396. * @return the class name
  49397. */
  49398. getClassName(): string;
  49399. }
  49400. }
  49401. declare module BABYLON {
  49402. /**
  49403. * This represents all the required metrics to create a VR camera.
  49404. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49405. */
  49406. export class VRCameraMetrics {
  49407. /**
  49408. * Define the horizontal resolution off the screen.
  49409. */
  49410. hResolution: number;
  49411. /**
  49412. * Define the vertical resolution off the screen.
  49413. */
  49414. vResolution: number;
  49415. /**
  49416. * Define the horizontal screen size.
  49417. */
  49418. hScreenSize: number;
  49419. /**
  49420. * Define the vertical screen size.
  49421. */
  49422. vScreenSize: number;
  49423. /**
  49424. * Define the vertical screen center position.
  49425. */
  49426. vScreenCenter: number;
  49427. /**
  49428. * Define the distance of the eyes to the screen.
  49429. */
  49430. eyeToScreenDistance: number;
  49431. /**
  49432. * Define the distance between both lenses
  49433. */
  49434. lensSeparationDistance: number;
  49435. /**
  49436. * Define the distance between both viewer's eyes.
  49437. */
  49438. interpupillaryDistance: number;
  49439. /**
  49440. * Define the distortion factor of the VR postprocess.
  49441. * Please, touch with care.
  49442. */
  49443. distortionK: number[];
  49444. /**
  49445. * Define the chromatic aberration correction factors for the VR post process.
  49446. */
  49447. chromaAbCorrection: number[];
  49448. /**
  49449. * Define the scale factor of the post process.
  49450. * The smaller the better but the slower.
  49451. */
  49452. postProcessScaleFactor: number;
  49453. /**
  49454. * Define an offset for the lens center.
  49455. */
  49456. lensCenterOffset: number;
  49457. /**
  49458. * Define if the current vr camera should compensate the distortion of the lense or not.
  49459. */
  49460. compensateDistortion: boolean;
  49461. /**
  49462. * Defines if multiview should be enabled when rendering (Default: false)
  49463. */
  49464. multiviewEnabled: boolean;
  49465. /**
  49466. * Gets the rendering aspect ratio based on the provided resolutions.
  49467. */
  49468. get aspectRatio(): number;
  49469. /**
  49470. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49471. */
  49472. get aspectRatioFov(): number;
  49473. /**
  49474. * @hidden
  49475. */
  49476. get leftHMatrix(): Matrix;
  49477. /**
  49478. * @hidden
  49479. */
  49480. get rightHMatrix(): Matrix;
  49481. /**
  49482. * @hidden
  49483. */
  49484. get leftPreViewMatrix(): Matrix;
  49485. /**
  49486. * @hidden
  49487. */
  49488. get rightPreViewMatrix(): Matrix;
  49489. /**
  49490. * Get the default VRMetrics based on the most generic setup.
  49491. * @returns the default vr metrics
  49492. */
  49493. static GetDefault(): VRCameraMetrics;
  49494. }
  49495. }
  49496. declare module BABYLON {
  49497. /** @hidden */
  49498. export var vrDistortionCorrectionPixelShader: {
  49499. name: string;
  49500. shader: string;
  49501. };
  49502. }
  49503. declare module BABYLON {
  49504. /**
  49505. * VRDistortionCorrectionPostProcess used for mobile VR
  49506. */
  49507. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49508. private _isRightEye;
  49509. private _distortionFactors;
  49510. private _postProcessScaleFactor;
  49511. private _lensCenterOffset;
  49512. private _scaleIn;
  49513. private _scaleFactor;
  49514. private _lensCenter;
  49515. /**
  49516. * Gets a string identifying the name of the class
  49517. * @returns "VRDistortionCorrectionPostProcess" string
  49518. */
  49519. getClassName(): string;
  49520. /**
  49521. * Initializes the VRDistortionCorrectionPostProcess
  49522. * @param name The name of the effect.
  49523. * @param camera The camera to apply the render pass to.
  49524. * @param isRightEye If this is for the right eye distortion
  49525. * @param vrMetrics All the required metrics for the VR camera
  49526. */
  49527. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49528. }
  49529. }
  49530. declare module BABYLON {
  49531. /**
  49532. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49533. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49534. */
  49535. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49536. /**
  49537. * Creates a new VRDeviceOrientationArcRotateCamera
  49538. * @param name defines camera name
  49539. * @param alpha defines the camera rotation along the logitudinal axis
  49540. * @param beta defines the camera rotation along the latitudinal axis
  49541. * @param radius defines the camera distance from its target
  49542. * @param target defines the camera target
  49543. * @param scene defines the scene the camera belongs to
  49544. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49545. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49546. */
  49547. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49548. /**
  49549. * Gets camera class name
  49550. * @returns VRDeviceOrientationArcRotateCamera
  49551. */
  49552. getClassName(): string;
  49553. }
  49554. }
  49555. declare module BABYLON {
  49556. /**
  49557. * Camera used to simulate VR rendering (based on FreeCamera)
  49558. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49559. */
  49560. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49561. /**
  49562. * Creates a new VRDeviceOrientationFreeCamera
  49563. * @param name defines camera name
  49564. * @param position defines the start position of the camera
  49565. * @param scene defines the scene the camera belongs to
  49566. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49567. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49568. */
  49569. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49570. /**
  49571. * Gets camera class name
  49572. * @returns VRDeviceOrientationFreeCamera
  49573. */
  49574. getClassName(): string;
  49575. }
  49576. }
  49577. declare module BABYLON {
  49578. /**
  49579. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49580. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49581. */
  49582. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49583. /**
  49584. * Creates a new VRDeviceOrientationGamepadCamera
  49585. * @param name defines camera name
  49586. * @param position defines the start position of the camera
  49587. * @param scene defines the scene the camera belongs to
  49588. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49589. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49590. */
  49591. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49592. /**
  49593. * Gets camera class name
  49594. * @returns VRDeviceOrientationGamepadCamera
  49595. */
  49596. getClassName(): string;
  49597. }
  49598. }
  49599. declare module BABYLON {
  49600. /**
  49601. * A class extending Texture allowing drawing on a texture
  49602. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49603. */
  49604. export class DynamicTexture extends Texture {
  49605. private _generateMipMaps;
  49606. private _canvas;
  49607. private _context;
  49608. /**
  49609. * Creates a DynamicTexture
  49610. * @param name defines the name of the texture
  49611. * @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
  49612. * @param scene defines the scene where you want the texture
  49613. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49614. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49615. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49616. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49617. */
  49618. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49619. /**
  49620. * Get the current class name of the texture useful for serialization or dynamic coding.
  49621. * @returns "DynamicTexture"
  49622. */
  49623. getClassName(): string;
  49624. /**
  49625. * Gets the current state of canRescale
  49626. */
  49627. get canRescale(): boolean;
  49628. private _recreate;
  49629. /**
  49630. * Scales the texture
  49631. * @param ratio the scale factor to apply to both width and height
  49632. */
  49633. scale(ratio: number): void;
  49634. /**
  49635. * Resizes the texture
  49636. * @param width the new width
  49637. * @param height the new height
  49638. */
  49639. scaleTo(width: number, height: number): void;
  49640. /**
  49641. * Gets the context of the canvas used by the texture
  49642. * @returns the canvas context of the dynamic texture
  49643. */
  49644. getContext(): CanvasRenderingContext2D;
  49645. /**
  49646. * Clears the texture
  49647. */
  49648. clear(): void;
  49649. /**
  49650. * Updates the texture
  49651. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49652. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49653. */
  49654. update(invertY?: boolean, premulAlpha?: boolean): void;
  49655. /**
  49656. * Draws text onto the texture
  49657. * @param text defines the text to be drawn
  49658. * @param x defines the placement of the text from the left
  49659. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49660. * @param font defines the font to be used with font-style, font-size, font-name
  49661. * @param color defines the color used for the text
  49662. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49663. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49664. * @param update defines whether texture is immediately update (default is true)
  49665. */
  49666. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49667. /**
  49668. * Clones the texture
  49669. * @returns the clone of the texture.
  49670. */
  49671. clone(): DynamicTexture;
  49672. /**
  49673. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49674. * @returns a serialized dynamic texture object
  49675. */
  49676. serialize(): any;
  49677. private _IsCanvasElement;
  49678. /** @hidden */
  49679. _rebuild(): void;
  49680. }
  49681. }
  49682. declare module BABYLON {
  49683. /**
  49684. * Class containing static functions to help procedurally build meshes
  49685. */
  49686. export class GroundBuilder {
  49687. /**
  49688. * Creates a ground mesh
  49689. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49690. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49692. * @param name defines the name of the mesh
  49693. * @param options defines the options used to create the mesh
  49694. * @param scene defines the hosting scene
  49695. * @returns the ground mesh
  49696. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49697. */
  49698. static CreateGround(name: string, options: {
  49699. width?: number;
  49700. height?: number;
  49701. subdivisions?: number;
  49702. subdivisionsX?: number;
  49703. subdivisionsY?: number;
  49704. updatable?: boolean;
  49705. }, scene: any): Mesh;
  49706. /**
  49707. * Creates a tiled ground mesh
  49708. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49709. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49710. * * 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
  49711. * * 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
  49712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49713. * @param name defines the name of the mesh
  49714. * @param options defines the options used to create the mesh
  49715. * @param scene defines the hosting scene
  49716. * @returns the tiled ground mesh
  49717. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49718. */
  49719. static CreateTiledGround(name: string, options: {
  49720. xmin: number;
  49721. zmin: number;
  49722. xmax: number;
  49723. zmax: number;
  49724. subdivisions?: {
  49725. w: number;
  49726. h: number;
  49727. };
  49728. precision?: {
  49729. w: number;
  49730. h: number;
  49731. };
  49732. updatable?: boolean;
  49733. }, scene?: Nullable<Scene>): Mesh;
  49734. /**
  49735. * Creates a ground mesh from a height map
  49736. * * The parameter `url` sets the URL of the height map image resource.
  49737. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49738. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49739. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49740. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49741. * * 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.
  49742. * * 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).
  49743. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49745. * @param name defines the name of the mesh
  49746. * @param url defines the url to the height map
  49747. * @param options defines the options used to create the mesh
  49748. * @param scene defines the hosting scene
  49749. * @returns the ground mesh
  49750. * @see https://doc.babylonjs.com/babylon101/height_map
  49751. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49752. */
  49753. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49754. width?: number;
  49755. height?: number;
  49756. subdivisions?: number;
  49757. minHeight?: number;
  49758. maxHeight?: number;
  49759. colorFilter?: Color3;
  49760. alphaFilter?: number;
  49761. updatable?: boolean;
  49762. onReady?: (mesh: GroundMesh) => void;
  49763. }, scene?: Nullable<Scene>): GroundMesh;
  49764. }
  49765. }
  49766. declare module BABYLON {
  49767. /**
  49768. * Class containing static functions to help procedurally build meshes
  49769. */
  49770. export class TorusBuilder {
  49771. /**
  49772. * Creates a torus mesh
  49773. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49774. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49775. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49777. * * 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
  49778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49779. * @param name defines the name of the mesh
  49780. * @param options defines the options used to create the mesh
  49781. * @param scene defines the hosting scene
  49782. * @returns the torus mesh
  49783. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49784. */
  49785. static CreateTorus(name: string, options: {
  49786. diameter?: number;
  49787. thickness?: number;
  49788. tessellation?: number;
  49789. updatable?: boolean;
  49790. sideOrientation?: number;
  49791. frontUVs?: Vector4;
  49792. backUVs?: Vector4;
  49793. }, scene: any): Mesh;
  49794. }
  49795. }
  49796. declare module BABYLON {
  49797. /**
  49798. * Class containing static functions to help procedurally build meshes
  49799. */
  49800. export class CylinderBuilder {
  49801. /**
  49802. * Creates a cylinder or a cone mesh
  49803. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49804. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49805. * * 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.
  49806. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49807. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49808. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49809. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49810. * * 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).
  49811. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49812. * * 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).
  49813. * * 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
  49814. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49815. * * 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
  49816. * * 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.
  49817. * * If `enclose` is false, a ring surface is one element.
  49818. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49819. * * 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
  49820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49821. * * 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
  49822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49823. * @param name defines the name of the mesh
  49824. * @param options defines the options used to create the mesh
  49825. * @param scene defines the hosting scene
  49826. * @returns the cylinder mesh
  49827. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49828. */
  49829. static CreateCylinder(name: string, options: {
  49830. height?: number;
  49831. diameterTop?: number;
  49832. diameterBottom?: number;
  49833. diameter?: number;
  49834. tessellation?: number;
  49835. subdivisions?: number;
  49836. arc?: number;
  49837. faceColors?: Color4[];
  49838. faceUV?: Vector4[];
  49839. updatable?: boolean;
  49840. hasRings?: boolean;
  49841. enclose?: boolean;
  49842. cap?: number;
  49843. sideOrientation?: number;
  49844. frontUVs?: Vector4;
  49845. backUVs?: Vector4;
  49846. }, scene: any): Mesh;
  49847. }
  49848. }
  49849. declare module BABYLON {
  49850. /**
  49851. * States of the webXR experience
  49852. */
  49853. export enum WebXRState {
  49854. /**
  49855. * Transitioning to being in XR mode
  49856. */
  49857. ENTERING_XR = 0,
  49858. /**
  49859. * Transitioning to non XR mode
  49860. */
  49861. EXITING_XR = 1,
  49862. /**
  49863. * In XR mode and presenting
  49864. */
  49865. IN_XR = 2,
  49866. /**
  49867. * Not entered XR mode
  49868. */
  49869. NOT_IN_XR = 3
  49870. }
  49871. /**
  49872. * The state of the XR camera's tracking
  49873. */
  49874. export enum WebXRTrackingState {
  49875. /**
  49876. * No transformation received, device is not being tracked
  49877. */
  49878. NOT_TRACKING = 0,
  49879. /**
  49880. * Tracking lost - using emulated position
  49881. */
  49882. TRACKING_LOST = 1,
  49883. /**
  49884. * Transformation tracking works normally
  49885. */
  49886. TRACKING = 2
  49887. }
  49888. /**
  49889. * Abstraction of the XR render target
  49890. */
  49891. export interface WebXRRenderTarget extends IDisposable {
  49892. /**
  49893. * xrpresent context of the canvas which can be used to display/mirror xr content
  49894. */
  49895. canvasContext: WebGLRenderingContext;
  49896. /**
  49897. * xr layer for the canvas
  49898. */
  49899. xrLayer: Nullable<XRWebGLLayer>;
  49900. /**
  49901. * Initializes the xr layer for the session
  49902. * @param xrSession xr session
  49903. * @returns a promise that will resolve once the XR Layer has been created
  49904. */
  49905. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49906. }
  49907. }
  49908. declare module BABYLON {
  49909. /**
  49910. * COnfiguration object for WebXR output canvas
  49911. */
  49912. export class WebXRManagedOutputCanvasOptions {
  49913. /**
  49914. * An optional canvas in case you wish to create it yourself and provide it here.
  49915. * If not provided, a new canvas will be created
  49916. */
  49917. canvasElement?: HTMLCanvasElement;
  49918. /**
  49919. * Options for this XR Layer output
  49920. */
  49921. canvasOptions?: XRWebGLLayerOptions;
  49922. /**
  49923. * CSS styling for a newly created canvas (if not provided)
  49924. */
  49925. newCanvasCssStyle?: string;
  49926. /**
  49927. * Get the default values of the configuration object
  49928. * @param engine defines the engine to use (can be null)
  49929. * @returns default values of this configuration object
  49930. */
  49931. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49932. }
  49933. /**
  49934. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49935. */
  49936. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49937. private _options;
  49938. private _canvas;
  49939. private _engine;
  49940. private _originalCanvasSize;
  49941. /**
  49942. * Rendering context of the canvas which can be used to display/mirror xr content
  49943. */
  49944. canvasContext: WebGLRenderingContext;
  49945. /**
  49946. * xr layer for the canvas
  49947. */
  49948. xrLayer: Nullable<XRWebGLLayer>;
  49949. /**
  49950. * Obseervers registered here will be triggered when the xr layer was initialized
  49951. */
  49952. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49953. /**
  49954. * Initializes the canvas to be added/removed upon entering/exiting xr
  49955. * @param _xrSessionManager The XR Session manager
  49956. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49957. */
  49958. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49959. /**
  49960. * Disposes of the object
  49961. */
  49962. dispose(): void;
  49963. /**
  49964. * Initializes the xr layer for the session
  49965. * @param xrSession xr session
  49966. * @returns a promise that will resolve once the XR Layer has been created
  49967. */
  49968. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49969. private _addCanvas;
  49970. private _removeCanvas;
  49971. private _setCanvasSize;
  49972. private _setManagedOutputCanvas;
  49973. }
  49974. }
  49975. declare module BABYLON {
  49976. /**
  49977. * Manages an XRSession to work with Babylon's engine
  49978. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49979. */
  49980. export class WebXRSessionManager implements IDisposable {
  49981. /** The scene which the session should be created for */
  49982. scene: Scene;
  49983. private _referenceSpace;
  49984. private _rttProvider;
  49985. private _sessionEnded;
  49986. private _xrNavigator;
  49987. private baseLayer;
  49988. /**
  49989. * The base reference space from which the session started. good if you want to reset your
  49990. * reference space
  49991. */
  49992. baseReferenceSpace: XRReferenceSpace;
  49993. /**
  49994. * Current XR frame
  49995. */
  49996. currentFrame: Nullable<XRFrame>;
  49997. /** WebXR timestamp updated every frame */
  49998. currentTimestamp: number;
  49999. /**
  50000. * Used just in case of a failure to initialize an immersive session.
  50001. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50002. */
  50003. defaultHeightCompensation: number;
  50004. /**
  50005. * Fires every time a new xrFrame arrives which can be used to update the camera
  50006. */
  50007. onXRFrameObservable: Observable<XRFrame>;
  50008. /**
  50009. * Fires when the reference space changed
  50010. */
  50011. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50012. /**
  50013. * Fires when the xr session is ended either by the device or manually done
  50014. */
  50015. onXRSessionEnded: Observable<any>;
  50016. /**
  50017. * Fires when the xr session is ended either by the device or manually done
  50018. */
  50019. onXRSessionInit: Observable<XRSession>;
  50020. /**
  50021. * Underlying xr session
  50022. */
  50023. session: XRSession;
  50024. /**
  50025. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50026. * or get the offset the player is currently at.
  50027. */
  50028. viewerReferenceSpace: XRReferenceSpace;
  50029. /**
  50030. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50031. * @param scene The scene which the session should be created for
  50032. */
  50033. constructor(
  50034. /** The scene which the session should be created for */
  50035. scene: Scene);
  50036. /**
  50037. * The current reference space used in this session. This reference space can constantly change!
  50038. * It is mainly used to offset the camera's position.
  50039. */
  50040. get referenceSpace(): XRReferenceSpace;
  50041. /**
  50042. * Set a new reference space and triggers the observable
  50043. */
  50044. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50045. /**
  50046. * Disposes of the session manager
  50047. */
  50048. dispose(): void;
  50049. /**
  50050. * Stops the xrSession and restores the render loop
  50051. * @returns Promise which resolves after it exits XR
  50052. */
  50053. exitXRAsync(): Promise<void>;
  50054. /**
  50055. * Gets the correct render target texture to be rendered this frame for this eye
  50056. * @param eye the eye for which to get the render target
  50057. * @returns the render target for the specified eye
  50058. */
  50059. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50060. /**
  50061. * Creates a WebXRRenderTarget object for the XR session
  50062. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50063. * @param options optional options to provide when creating a new render target
  50064. * @returns a WebXR render target to which the session can render
  50065. */
  50066. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50067. /**
  50068. * Initializes the manager
  50069. * After initialization enterXR can be called to start an XR session
  50070. * @returns Promise which resolves after it is initialized
  50071. */
  50072. initializeAsync(): Promise<void>;
  50073. /**
  50074. * Initializes an xr session
  50075. * @param xrSessionMode mode to initialize
  50076. * @param xrSessionInit defines optional and required values to pass to the session builder
  50077. * @returns a promise which will resolve once the session has been initialized
  50078. */
  50079. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50080. /**
  50081. * Checks if a session would be supported for the creation options specified
  50082. * @param sessionMode session mode to check if supported eg. immersive-vr
  50083. * @returns A Promise that resolves to true if supported and false if not
  50084. */
  50085. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50086. /**
  50087. * Resets the reference space to the one started the session
  50088. */
  50089. resetReferenceSpace(): void;
  50090. /**
  50091. * Starts rendering to the xr layer
  50092. */
  50093. runXRRenderLoop(): void;
  50094. /**
  50095. * Sets the reference space on the xr session
  50096. * @param referenceSpaceType space to set
  50097. * @returns a promise that will resolve once the reference space has been set
  50098. */
  50099. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50100. /**
  50101. * Updates the render state of the session
  50102. * @param state state to set
  50103. * @returns a promise that resolves once the render state has been updated
  50104. */
  50105. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50106. /**
  50107. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50108. * @param sessionMode defines the session to test
  50109. * @returns a promise with boolean as final value
  50110. */
  50111. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50112. private _createRenderTargetTexture;
  50113. }
  50114. }
  50115. declare module BABYLON {
  50116. /**
  50117. * WebXR Camera which holds the views for the xrSession
  50118. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50119. */
  50120. export class WebXRCamera extends FreeCamera {
  50121. private _xrSessionManager;
  50122. private _firstFrame;
  50123. private _referenceQuaternion;
  50124. private _referencedPosition;
  50125. private _xrInvPositionCache;
  50126. private _xrInvQuaternionCache;
  50127. private _trackingState;
  50128. /**
  50129. * Observable raised before camera teleportation
  50130. */
  50131. onBeforeCameraTeleport: Observable<Vector3>;
  50132. /**
  50133. * Observable raised after camera teleportation
  50134. */
  50135. onAfterCameraTeleport: Observable<Vector3>;
  50136. /**
  50137. * Notifies when the camera's tracking state has changed.
  50138. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50139. */
  50140. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50141. /**
  50142. * Should position compensation execute on first frame.
  50143. * This is used when copying the position from a native (non XR) camera
  50144. */
  50145. compensateOnFirstFrame: boolean;
  50146. /**
  50147. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50148. * @param name the name of the camera
  50149. * @param scene the scene to add the camera to
  50150. * @param _xrSessionManager a constructed xr session manager
  50151. */
  50152. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50153. /**
  50154. * Get the current XR tracking state of the camera
  50155. */
  50156. get trackingState(): WebXRTrackingState;
  50157. private _setTrackingState;
  50158. /**
  50159. * Return the user's height, unrelated to the current ground.
  50160. * This will be the y position of this camera, when ground level is 0.
  50161. */
  50162. get realWorldHeight(): number;
  50163. /** @hidden */
  50164. _updateForDualEyeDebugging(): void;
  50165. /**
  50166. * Sets this camera's transformation based on a non-vr camera
  50167. * @param otherCamera the non-vr camera to copy the transformation from
  50168. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50169. */
  50170. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50171. /**
  50172. * Gets the current instance class name ("WebXRCamera").
  50173. * @returns the class name
  50174. */
  50175. getClassName(): string;
  50176. private _rotate180;
  50177. private _updateFromXRSession;
  50178. private _updateNumberOfRigCameras;
  50179. private _updateReferenceSpace;
  50180. private _updateReferenceSpaceOffset;
  50181. }
  50182. }
  50183. declare module BABYLON {
  50184. /**
  50185. * Defining the interface required for a (webxr) feature
  50186. */
  50187. export interface IWebXRFeature extends IDisposable {
  50188. /**
  50189. * Is this feature attached
  50190. */
  50191. attached: boolean;
  50192. /**
  50193. * Should auto-attach be disabled?
  50194. */
  50195. disableAutoAttach: boolean;
  50196. /**
  50197. * Attach the feature to the session
  50198. * Will usually be called by the features manager
  50199. *
  50200. * @param force should attachment be forced (even when already attached)
  50201. * @returns true if successful.
  50202. */
  50203. attach(force?: boolean): boolean;
  50204. /**
  50205. * Detach the feature from the session
  50206. * Will usually be called by the features manager
  50207. *
  50208. * @returns true if successful.
  50209. */
  50210. detach(): boolean;
  50211. /**
  50212. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50213. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50214. *
  50215. * @returns whether or not the feature is compatible in this environment
  50216. */
  50217. isCompatible(): boolean;
  50218. /**
  50219. * Was this feature disposed;
  50220. */
  50221. isDisposed: boolean;
  50222. /**
  50223. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50224. */
  50225. xrNativeFeatureName?: string;
  50226. /**
  50227. * A list of (Babylon WebXR) features this feature depends on
  50228. */
  50229. dependsOn?: string[];
  50230. }
  50231. /**
  50232. * A list of the currently available features without referencing them
  50233. */
  50234. export class WebXRFeatureName {
  50235. /**
  50236. * The name of the anchor system feature
  50237. */
  50238. static readonly ANCHOR_SYSTEM: string;
  50239. /**
  50240. * The name of the background remover feature
  50241. */
  50242. static readonly BACKGROUND_REMOVER: string;
  50243. /**
  50244. * The name of the hit test feature
  50245. */
  50246. static readonly HIT_TEST: string;
  50247. /**
  50248. * physics impostors for xr controllers feature
  50249. */
  50250. static readonly PHYSICS_CONTROLLERS: string;
  50251. /**
  50252. * The name of the plane detection feature
  50253. */
  50254. static readonly PLANE_DETECTION: string;
  50255. /**
  50256. * The name of the pointer selection feature
  50257. */
  50258. static readonly POINTER_SELECTION: string;
  50259. /**
  50260. * The name of the teleportation feature
  50261. */
  50262. static readonly TELEPORTATION: string;
  50263. /**
  50264. * The name of the feature points feature.
  50265. */
  50266. static readonly FEATURE_POINTS: string;
  50267. /**
  50268. * The name of the hand tracking feature.
  50269. */
  50270. static readonly HAND_TRACKING: string;
  50271. }
  50272. /**
  50273. * Defining the constructor of a feature. Used to register the modules.
  50274. */
  50275. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50276. /**
  50277. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50278. * It is mainly used in AR sessions.
  50279. *
  50280. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50281. */
  50282. export class WebXRFeaturesManager implements IDisposable {
  50283. private _xrSessionManager;
  50284. private static readonly _AvailableFeatures;
  50285. private _features;
  50286. /**
  50287. * constructs a new features manages.
  50288. *
  50289. * @param _xrSessionManager an instance of WebXRSessionManager
  50290. */
  50291. constructor(_xrSessionManager: WebXRSessionManager);
  50292. /**
  50293. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50294. * Mainly used internally.
  50295. *
  50296. * @param featureName the name of the feature to register
  50297. * @param constructorFunction the function used to construct the module
  50298. * @param version the (babylon) version of the module
  50299. * @param stable is that a stable version of this module
  50300. */
  50301. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50302. /**
  50303. * Returns a constructor of a specific feature.
  50304. *
  50305. * @param featureName the name of the feature to construct
  50306. * @param version the version of the feature to load
  50307. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50308. * @param options optional options provided to the module.
  50309. * @returns a function that, when called, will return a new instance of this feature
  50310. */
  50311. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50312. /**
  50313. * Can be used to return the list of features currently registered
  50314. *
  50315. * @returns an Array of available features
  50316. */
  50317. static GetAvailableFeatures(): string[];
  50318. /**
  50319. * Gets the versions available for a specific feature
  50320. * @param featureName the name of the feature
  50321. * @returns an array with the available versions
  50322. */
  50323. static GetAvailableVersions(featureName: string): string[];
  50324. /**
  50325. * Return the latest unstable version of this feature
  50326. * @param featureName the name of the feature to search
  50327. * @returns the version number. if not found will return -1
  50328. */
  50329. static GetLatestVersionOfFeature(featureName: string): number;
  50330. /**
  50331. * Return the latest stable version of this feature
  50332. * @param featureName the name of the feature to search
  50333. * @returns the version number. if not found will return -1
  50334. */
  50335. static GetStableVersionOfFeature(featureName: string): number;
  50336. /**
  50337. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50338. * Can be used during a session to start a feature
  50339. * @param featureName the name of feature to attach
  50340. */
  50341. attachFeature(featureName: string): void;
  50342. /**
  50343. * Can be used inside a session or when the session ends to detach a specific feature
  50344. * @param featureName the name of the feature to detach
  50345. */
  50346. detachFeature(featureName: string): void;
  50347. /**
  50348. * Used to disable an already-enabled feature
  50349. * The feature will be disposed and will be recreated once enabled.
  50350. * @param featureName the feature to disable
  50351. * @returns true if disable was successful
  50352. */
  50353. disableFeature(featureName: string | {
  50354. Name: string;
  50355. }): boolean;
  50356. /**
  50357. * dispose this features manager
  50358. */
  50359. dispose(): void;
  50360. /**
  50361. * 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.
  50362. * 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.
  50363. *
  50364. * @param featureName the name of the feature to load or the class of the feature
  50365. * @param version optional version to load. if not provided the latest version will be enabled
  50366. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50367. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50368. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50369. * @returns a new constructed feature or throws an error if feature not found.
  50370. */
  50371. enableFeature(featureName: string | {
  50372. Name: string;
  50373. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50374. /**
  50375. * get the implementation of an enabled feature.
  50376. * @param featureName the name of the feature to load
  50377. * @returns the feature class, if found
  50378. */
  50379. getEnabledFeature(featureName: string): IWebXRFeature;
  50380. /**
  50381. * Get the list of enabled features
  50382. * @returns an array of enabled features
  50383. */
  50384. getEnabledFeatures(): string[];
  50385. /**
  50386. * This function will exten the session creation configuration object with enabled features.
  50387. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50388. * according to the defined "required" variable, provided during enableFeature call
  50389. * @param xrSessionInit the xr Session init object to extend
  50390. *
  50391. * @returns an extended XRSessionInit object
  50392. */
  50393. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50394. }
  50395. }
  50396. declare module BABYLON {
  50397. /**
  50398. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50399. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50400. */
  50401. export class WebXRExperienceHelper implements IDisposable {
  50402. private scene;
  50403. private _nonVRCamera;
  50404. private _originalSceneAutoClear;
  50405. private _supported;
  50406. /**
  50407. * Camera used to render xr content
  50408. */
  50409. camera: WebXRCamera;
  50410. /** A features manager for this xr session */
  50411. featuresManager: WebXRFeaturesManager;
  50412. /**
  50413. * Observers registered here will be triggered after the camera's initial transformation is set
  50414. * This can be used to set a different ground level or an extra rotation.
  50415. *
  50416. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50417. * to the position set after this observable is done executing.
  50418. */
  50419. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50420. /**
  50421. * Fires when the state of the experience helper has changed
  50422. */
  50423. onStateChangedObservable: Observable<WebXRState>;
  50424. /** Session manager used to keep track of xr session */
  50425. sessionManager: WebXRSessionManager;
  50426. /**
  50427. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50428. */
  50429. state: WebXRState;
  50430. /**
  50431. * Creates a WebXRExperienceHelper
  50432. * @param scene The scene the helper should be created in
  50433. */
  50434. private constructor();
  50435. /**
  50436. * Creates the experience helper
  50437. * @param scene the scene to attach the experience helper to
  50438. * @returns a promise for the experience helper
  50439. */
  50440. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50441. /**
  50442. * Disposes of the experience helper
  50443. */
  50444. dispose(): void;
  50445. /**
  50446. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50447. * @param sessionMode options for the XR session
  50448. * @param referenceSpaceType frame of reference of the XR session
  50449. * @param renderTarget the output canvas that will be used to enter XR mode
  50450. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50451. * @returns promise that resolves after xr mode has entered
  50452. */
  50453. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50454. /**
  50455. * Exits XR mode and returns the scene to its original state
  50456. * @returns promise that resolves after xr mode has exited
  50457. */
  50458. exitXRAsync(): Promise<void>;
  50459. private _nonXRToXRCamera;
  50460. private _setState;
  50461. }
  50462. }
  50463. declare module BABYLON {
  50464. /**
  50465. * X-Y values for axes in WebXR
  50466. */
  50467. export interface IWebXRMotionControllerAxesValue {
  50468. /**
  50469. * The value of the x axis
  50470. */
  50471. x: number;
  50472. /**
  50473. * The value of the y-axis
  50474. */
  50475. y: number;
  50476. }
  50477. /**
  50478. * changed / previous values for the values of this component
  50479. */
  50480. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50481. /**
  50482. * current (this frame) value
  50483. */
  50484. current: T;
  50485. /**
  50486. * previous (last change) value
  50487. */
  50488. previous: T;
  50489. }
  50490. /**
  50491. * Represents changes in the component between current frame and last values recorded
  50492. */
  50493. export interface IWebXRMotionControllerComponentChanges {
  50494. /**
  50495. * will be populated with previous and current values if axes changed
  50496. */
  50497. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50498. /**
  50499. * will be populated with previous and current values if pressed changed
  50500. */
  50501. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50502. /**
  50503. * will be populated with previous and current values if touched changed
  50504. */
  50505. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50506. /**
  50507. * will be populated with previous and current values if value changed
  50508. */
  50509. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50510. }
  50511. /**
  50512. * This class represents a single component (for example button or thumbstick) of a motion controller
  50513. */
  50514. export class WebXRControllerComponent implements IDisposable {
  50515. /**
  50516. * the id of this component
  50517. */
  50518. id: string;
  50519. /**
  50520. * the type of the component
  50521. */
  50522. type: MotionControllerComponentType;
  50523. private _buttonIndex;
  50524. private _axesIndices;
  50525. private _axes;
  50526. private _changes;
  50527. private _currentValue;
  50528. private _hasChanges;
  50529. private _pressed;
  50530. private _touched;
  50531. /**
  50532. * button component type
  50533. */
  50534. static BUTTON_TYPE: MotionControllerComponentType;
  50535. /**
  50536. * squeeze component type
  50537. */
  50538. static SQUEEZE_TYPE: MotionControllerComponentType;
  50539. /**
  50540. * Thumbstick component type
  50541. */
  50542. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50543. /**
  50544. * Touchpad component type
  50545. */
  50546. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50547. /**
  50548. * trigger component type
  50549. */
  50550. static TRIGGER_TYPE: MotionControllerComponentType;
  50551. /**
  50552. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50553. * the axes data changes
  50554. */
  50555. onAxisValueChangedObservable: Observable<{
  50556. x: number;
  50557. y: number;
  50558. }>;
  50559. /**
  50560. * Observers registered here will be triggered when the state of a button changes
  50561. * State change is either pressed / touched / value
  50562. */
  50563. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50564. /**
  50565. * Creates a new component for a motion controller.
  50566. * It is created by the motion controller itself
  50567. *
  50568. * @param id the id of this component
  50569. * @param type the type of the component
  50570. * @param _buttonIndex index in the buttons array of the gamepad
  50571. * @param _axesIndices indices of the values in the axes array of the gamepad
  50572. */
  50573. constructor(
  50574. /**
  50575. * the id of this component
  50576. */
  50577. id: string,
  50578. /**
  50579. * the type of the component
  50580. */
  50581. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50582. /**
  50583. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50584. */
  50585. get axes(): IWebXRMotionControllerAxesValue;
  50586. /**
  50587. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50588. */
  50589. get changes(): IWebXRMotionControllerComponentChanges;
  50590. /**
  50591. * Return whether or not the component changed the last frame
  50592. */
  50593. get hasChanges(): boolean;
  50594. /**
  50595. * is the button currently pressed
  50596. */
  50597. get pressed(): boolean;
  50598. /**
  50599. * is the button currently touched
  50600. */
  50601. get touched(): boolean;
  50602. /**
  50603. * Get the current value of this component
  50604. */
  50605. get value(): number;
  50606. /**
  50607. * Dispose this component
  50608. */
  50609. dispose(): void;
  50610. /**
  50611. * Are there axes correlating to this component
  50612. * @return true is axes data is available
  50613. */
  50614. isAxes(): boolean;
  50615. /**
  50616. * Is this component a button (hence - pressable)
  50617. * @returns true if can be pressed
  50618. */
  50619. isButton(): boolean;
  50620. /**
  50621. * update this component using the gamepad object it is in. Called on every frame
  50622. * @param nativeController the native gamepad controller object
  50623. */
  50624. update(nativeController: IMinimalMotionControllerObject): void;
  50625. }
  50626. }
  50627. declare module BABYLON {
  50628. /**
  50629. * Interface used to represent data loading progression
  50630. */
  50631. export interface ISceneLoaderProgressEvent {
  50632. /**
  50633. * Defines if data length to load can be evaluated
  50634. */
  50635. readonly lengthComputable: boolean;
  50636. /**
  50637. * Defines the loaded data length
  50638. */
  50639. readonly loaded: number;
  50640. /**
  50641. * Defines the data length to load
  50642. */
  50643. readonly total: number;
  50644. }
  50645. /**
  50646. * Interface used by SceneLoader plugins to define supported file extensions
  50647. */
  50648. export interface ISceneLoaderPluginExtensions {
  50649. /**
  50650. * Defines the list of supported extensions
  50651. */
  50652. [extension: string]: {
  50653. isBinary: boolean;
  50654. };
  50655. }
  50656. /**
  50657. * Interface used by SceneLoader plugin factory
  50658. */
  50659. export interface ISceneLoaderPluginFactory {
  50660. /**
  50661. * Defines the name of the factory
  50662. */
  50663. name: string;
  50664. /**
  50665. * Function called to create a new plugin
  50666. * @return the new plugin
  50667. */
  50668. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50669. /**
  50670. * The callback that returns true if the data can be directly loaded.
  50671. * @param data string containing the file data
  50672. * @returns if the data can be loaded directly
  50673. */
  50674. canDirectLoad?(data: string): boolean;
  50675. }
  50676. /**
  50677. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50678. */
  50679. export interface ISceneLoaderPluginBase {
  50680. /**
  50681. * The friendly name of this plugin.
  50682. */
  50683. name: string;
  50684. /**
  50685. * The file extensions supported by this plugin.
  50686. */
  50687. extensions: string | ISceneLoaderPluginExtensions;
  50688. /**
  50689. * The callback called when loading from a url.
  50690. * @param scene scene loading this url
  50691. * @param url url to load
  50692. * @param onSuccess callback called when the file successfully loads
  50693. * @param onProgress callback called while file is loading (if the server supports this mode)
  50694. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50695. * @param onError callback called when the file fails to load
  50696. * @returns a file request object
  50697. */
  50698. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50699. /**
  50700. * The callback called when loading from a file object.
  50701. * @param scene scene loading this file
  50702. * @param file defines the file to load
  50703. * @param onSuccess defines the callback to call when data is loaded
  50704. * @param onProgress defines the callback to call during loading process
  50705. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50706. * @param onError defines the callback to call when an error occurs
  50707. * @returns a file request object
  50708. */
  50709. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50710. /**
  50711. * The callback that returns true if the data can be directly loaded.
  50712. * @param data string containing the file data
  50713. * @returns if the data can be loaded directly
  50714. */
  50715. canDirectLoad?(data: string): boolean;
  50716. /**
  50717. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50718. * @param scene scene loading this data
  50719. * @param data string containing the data
  50720. * @returns data to pass to the plugin
  50721. */
  50722. directLoad?(scene: Scene, data: string): any;
  50723. /**
  50724. * The callback that allows custom handling of the root url based on the response url.
  50725. * @param rootUrl the original root url
  50726. * @param responseURL the response url if available
  50727. * @returns the new root url
  50728. */
  50729. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50730. }
  50731. /**
  50732. * Interface used to define a SceneLoader plugin
  50733. */
  50734. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50735. /**
  50736. * Import meshes into a scene.
  50737. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50738. * @param scene The scene to import into
  50739. * @param data The data to import
  50740. * @param rootUrl The root url for scene and resources
  50741. * @param meshes The meshes array to import into
  50742. * @param particleSystems The particle systems array to import into
  50743. * @param skeletons The skeletons array to import into
  50744. * @param onError The callback when import fails
  50745. * @returns True if successful or false otherwise
  50746. */
  50747. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50748. /**
  50749. * Load into a scene.
  50750. * @param scene The scene to load into
  50751. * @param data The data to import
  50752. * @param rootUrl The root url for scene and resources
  50753. * @param onError The callback when import fails
  50754. * @returns True if successful or false otherwise
  50755. */
  50756. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50757. /**
  50758. * Load into an asset container.
  50759. * @param scene The scene to load into
  50760. * @param data The data to import
  50761. * @param rootUrl The root url for scene and resources
  50762. * @param onError The callback when import fails
  50763. * @returns The loaded asset container
  50764. */
  50765. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50766. }
  50767. /**
  50768. * Interface used to define an async SceneLoader plugin
  50769. */
  50770. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50771. /**
  50772. * Import meshes into a scene.
  50773. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50774. * @param scene The scene to import into
  50775. * @param data The data to import
  50776. * @param rootUrl The root url for scene and resources
  50777. * @param onProgress The callback when the load progresses
  50778. * @param fileName Defines the name of the file to load
  50779. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50780. */
  50781. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50782. meshes: AbstractMesh[];
  50783. particleSystems: IParticleSystem[];
  50784. skeletons: Skeleton[];
  50785. animationGroups: AnimationGroup[];
  50786. }>;
  50787. /**
  50788. * Load into a scene.
  50789. * @param scene The scene to load into
  50790. * @param data The data to import
  50791. * @param rootUrl The root url for scene and resources
  50792. * @param onProgress The callback when the load progresses
  50793. * @param fileName Defines the name of the file to load
  50794. * @returns Nothing
  50795. */
  50796. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50797. /**
  50798. * Load into an asset container.
  50799. * @param scene The scene to load into
  50800. * @param data The data to import
  50801. * @param rootUrl The root url for scene and resources
  50802. * @param onProgress The callback when the load progresses
  50803. * @param fileName Defines the name of the file to load
  50804. * @returns The loaded asset container
  50805. */
  50806. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50807. }
  50808. /**
  50809. * Mode that determines how to handle old animation groups before loading new ones.
  50810. */
  50811. export enum SceneLoaderAnimationGroupLoadingMode {
  50812. /**
  50813. * Reset all old animations to initial state then dispose them.
  50814. */
  50815. Clean = 0,
  50816. /**
  50817. * Stop all old animations.
  50818. */
  50819. Stop = 1,
  50820. /**
  50821. * Restart old animations from first frame.
  50822. */
  50823. Sync = 2,
  50824. /**
  50825. * Old animations remains untouched.
  50826. */
  50827. NoSync = 3
  50828. }
  50829. /**
  50830. * Defines a plugin registered by the SceneLoader
  50831. */
  50832. interface IRegisteredPlugin {
  50833. /**
  50834. * Defines the plugin to use
  50835. */
  50836. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50837. /**
  50838. * Defines if the plugin supports binary data
  50839. */
  50840. isBinary: boolean;
  50841. }
  50842. /**
  50843. * Class used to load scene from various file formats using registered plugins
  50844. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50845. */
  50846. export class SceneLoader {
  50847. /**
  50848. * No logging while loading
  50849. */
  50850. static readonly NO_LOGGING: number;
  50851. /**
  50852. * Minimal logging while loading
  50853. */
  50854. static readonly MINIMAL_LOGGING: number;
  50855. /**
  50856. * Summary logging while loading
  50857. */
  50858. static readonly SUMMARY_LOGGING: number;
  50859. /**
  50860. * Detailled logging while loading
  50861. */
  50862. static readonly DETAILED_LOGGING: number;
  50863. /**
  50864. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50865. */
  50866. static get ForceFullSceneLoadingForIncremental(): boolean;
  50867. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50868. /**
  50869. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50870. */
  50871. static get ShowLoadingScreen(): boolean;
  50872. static set ShowLoadingScreen(value: boolean);
  50873. /**
  50874. * Defines the current logging level (while loading the scene)
  50875. * @ignorenaming
  50876. */
  50877. static get loggingLevel(): number;
  50878. static set loggingLevel(value: number);
  50879. /**
  50880. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50881. */
  50882. static get CleanBoneMatrixWeights(): boolean;
  50883. static set CleanBoneMatrixWeights(value: boolean);
  50884. /**
  50885. * Event raised when a plugin is used to load a scene
  50886. */
  50887. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50888. private static _registeredPlugins;
  50889. private static _showingLoadingScreen;
  50890. /**
  50891. * Gets the default plugin (used to load Babylon files)
  50892. * @returns the .babylon plugin
  50893. */
  50894. static GetDefaultPlugin(): IRegisteredPlugin;
  50895. private static _GetPluginForExtension;
  50896. private static _GetPluginForDirectLoad;
  50897. private static _GetPluginForFilename;
  50898. private static _GetDirectLoad;
  50899. private static _LoadData;
  50900. private static _GetFileInfo;
  50901. /**
  50902. * Gets a plugin that can load the given extension
  50903. * @param extension defines the extension to load
  50904. * @returns a plugin or null if none works
  50905. */
  50906. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50907. /**
  50908. * Gets a boolean indicating that the given extension can be loaded
  50909. * @param extension defines the extension to load
  50910. * @returns true if the extension is supported
  50911. */
  50912. static IsPluginForExtensionAvailable(extension: string): boolean;
  50913. /**
  50914. * Adds a new plugin to the list of registered plugins
  50915. * @param plugin defines the plugin to add
  50916. */
  50917. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50918. /**
  50919. * Import meshes into a scene
  50920. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50921. * @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)
  50922. * @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)
  50923. * @param scene the instance of BABYLON.Scene to append to
  50924. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50925. * @param onProgress a callback with a progress event for each file being loaded
  50926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50927. * @param pluginExtension the extension used to determine the plugin
  50928. * @returns The loaded plugin
  50929. */
  50930. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50931. /**
  50932. * Import meshes into a scene
  50933. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50934. * @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)
  50935. * @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)
  50936. * @param scene the instance of BABYLON.Scene to append to
  50937. * @param onProgress a callback with a progress event for each file being loaded
  50938. * @param pluginExtension the extension used to determine the plugin
  50939. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50940. */
  50941. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50942. meshes: AbstractMesh[];
  50943. particleSystems: IParticleSystem[];
  50944. skeletons: Skeleton[];
  50945. animationGroups: AnimationGroup[];
  50946. }>;
  50947. /**
  50948. * Load a scene
  50949. * @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)
  50950. * @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)
  50951. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50952. * @param onSuccess a callback with the scene when import succeeds
  50953. * @param onProgress a callback with a progress event for each file being loaded
  50954. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50955. * @param pluginExtension the extension used to determine the plugin
  50956. * @returns The loaded plugin
  50957. */
  50958. 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>;
  50959. /**
  50960. * Load a scene
  50961. * @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)
  50962. * @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)
  50963. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50964. * @param onProgress a callback with a progress event for each file being loaded
  50965. * @param pluginExtension the extension used to determine the plugin
  50966. * @returns The loaded scene
  50967. */
  50968. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50969. /**
  50970. * Append a scene
  50971. * @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)
  50972. * @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)
  50973. * @param scene is the instance of BABYLON.Scene to append to
  50974. * @param onSuccess a callback with the scene when import succeeds
  50975. * @param onProgress a callback with a progress event for each file being loaded
  50976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50977. * @param pluginExtension the extension used to determine the plugin
  50978. * @returns The loaded plugin
  50979. */
  50980. 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>;
  50981. /**
  50982. * Append a scene
  50983. * @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)
  50984. * @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)
  50985. * @param scene is the instance of BABYLON.Scene to append to
  50986. * @param onProgress a callback with a progress event for each file being loaded
  50987. * @param pluginExtension the extension used to determine the plugin
  50988. * @returns The given scene
  50989. */
  50990. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50991. /**
  50992. * Load a scene into an asset container
  50993. * @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)
  50994. * @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)
  50995. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50996. * @param onSuccess a callback with the scene when import succeeds
  50997. * @param onProgress a callback with a progress event for each file being loaded
  50998. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50999. * @param pluginExtension the extension used to determine the plugin
  51000. * @returns The loaded plugin
  51001. */
  51002. 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>;
  51003. /**
  51004. * Load a scene into an asset container
  51005. * @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)
  51006. * @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)
  51007. * @param scene is the instance of Scene to append to
  51008. * @param onProgress a callback with a progress event for each file being loaded
  51009. * @param pluginExtension the extension used to determine the plugin
  51010. * @returns The loaded asset container
  51011. */
  51012. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51013. /**
  51014. * Import animations from a file into a scene
  51015. * @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)
  51016. * @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)
  51017. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51018. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51019. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51020. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51021. * @param onSuccess a callback with the scene when import succeeds
  51022. * @param onProgress a callback with a progress event for each file being loaded
  51023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51024. * @param pluginExtension the extension used to determine the plugin
  51025. */
  51026. 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;
  51027. /**
  51028. * Import animations from a file into a scene
  51029. * @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)
  51030. * @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)
  51031. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51032. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51033. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51034. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51035. * @param onSuccess a callback with the scene when import succeeds
  51036. * @param onProgress a callback with a progress event for each file being loaded
  51037. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51038. * @param pluginExtension the extension used to determine the plugin
  51039. * @returns the updated scene with imported animations
  51040. */
  51041. 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>;
  51042. }
  51043. }
  51044. declare module BABYLON {
  51045. /**
  51046. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51047. */
  51048. export type MotionControllerHandedness = "none" | "left" | "right";
  51049. /**
  51050. * The type of components available in motion controllers.
  51051. * This is not the name of the component.
  51052. */
  51053. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51054. /**
  51055. * The state of a controller component
  51056. */
  51057. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51058. /**
  51059. * The schema of motion controller layout.
  51060. * No object will be initialized using this interface
  51061. * This is used just to define the profile.
  51062. */
  51063. export interface IMotionControllerLayout {
  51064. /**
  51065. * Path to load the assets. Usually relative to the base path
  51066. */
  51067. assetPath: string;
  51068. /**
  51069. * Available components (unsorted)
  51070. */
  51071. components: {
  51072. /**
  51073. * A map of component Ids
  51074. */
  51075. [componentId: string]: {
  51076. /**
  51077. * The type of input the component outputs
  51078. */
  51079. type: MotionControllerComponentType;
  51080. /**
  51081. * The indices of this component in the gamepad object
  51082. */
  51083. gamepadIndices: {
  51084. /**
  51085. * Index of button
  51086. */
  51087. button?: number;
  51088. /**
  51089. * If available, index of x-axis
  51090. */
  51091. xAxis?: number;
  51092. /**
  51093. * If available, index of y-axis
  51094. */
  51095. yAxis?: number;
  51096. };
  51097. /**
  51098. * The mesh's root node name
  51099. */
  51100. rootNodeName: string;
  51101. /**
  51102. * Animation definitions for this model
  51103. */
  51104. visualResponses: {
  51105. [stateKey: string]: {
  51106. /**
  51107. * What property will be animated
  51108. */
  51109. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51110. /**
  51111. * What states influence this visual response
  51112. */
  51113. states: MotionControllerComponentStateType[];
  51114. /**
  51115. * Type of animation - movement or visibility
  51116. */
  51117. valueNodeProperty: "transform" | "visibility";
  51118. /**
  51119. * Base node name to move. Its position will be calculated according to the min and max nodes
  51120. */
  51121. valueNodeName?: string;
  51122. /**
  51123. * Minimum movement node
  51124. */
  51125. minNodeName?: string;
  51126. /**
  51127. * Max movement node
  51128. */
  51129. maxNodeName?: string;
  51130. };
  51131. };
  51132. /**
  51133. * If touch enabled, what is the name of node to display user feedback
  51134. */
  51135. touchPointNodeName?: string;
  51136. };
  51137. };
  51138. /**
  51139. * Is it xr standard mapping or not
  51140. */
  51141. gamepadMapping: "" | "xr-standard";
  51142. /**
  51143. * Base root node of this entire model
  51144. */
  51145. rootNodeName: string;
  51146. /**
  51147. * Defines the main button component id
  51148. */
  51149. selectComponentId: string;
  51150. }
  51151. /**
  51152. * A definition for the layout map in the input profile
  51153. */
  51154. export interface IMotionControllerLayoutMap {
  51155. /**
  51156. * Layouts with handedness type as a key
  51157. */
  51158. [handedness: string]: IMotionControllerLayout;
  51159. }
  51160. /**
  51161. * The XR Input profile schema
  51162. * Profiles can be found here:
  51163. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51164. */
  51165. export interface IMotionControllerProfile {
  51166. /**
  51167. * fallback profiles for this profileId
  51168. */
  51169. fallbackProfileIds: string[];
  51170. /**
  51171. * The layout map, with handedness as key
  51172. */
  51173. layouts: IMotionControllerLayoutMap;
  51174. /**
  51175. * The id of this profile
  51176. * correlates to the profile(s) in the xrInput.profiles array
  51177. */
  51178. profileId: string;
  51179. }
  51180. /**
  51181. * A helper-interface for the 3 meshes needed for controller button animation
  51182. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51183. */
  51184. export interface IMotionControllerButtonMeshMap {
  51185. /**
  51186. * the mesh that defines the pressed value mesh position.
  51187. * This is used to find the max-position of this button
  51188. */
  51189. pressedMesh: AbstractMesh;
  51190. /**
  51191. * the mesh that defines the unpressed value mesh position.
  51192. * This is used to find the min (or initial) position of this button
  51193. */
  51194. unpressedMesh: AbstractMesh;
  51195. /**
  51196. * The mesh that will be changed when value changes
  51197. */
  51198. valueMesh: AbstractMesh;
  51199. }
  51200. /**
  51201. * A helper-interface for the 3 meshes needed for controller axis animation.
  51202. * This will be expanded when touchpad animations are fully supported
  51203. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51204. */
  51205. export interface IMotionControllerMeshMap {
  51206. /**
  51207. * the mesh that defines the maximum value mesh position.
  51208. */
  51209. maxMesh?: AbstractMesh;
  51210. /**
  51211. * the mesh that defines the minimum value mesh position.
  51212. */
  51213. minMesh?: AbstractMesh;
  51214. /**
  51215. * The mesh that will be changed when axis value changes
  51216. */
  51217. valueMesh?: AbstractMesh;
  51218. }
  51219. /**
  51220. * The elements needed for change-detection of the gamepad objects in motion controllers
  51221. */
  51222. export interface IMinimalMotionControllerObject {
  51223. /**
  51224. * Available axes of this controller
  51225. */
  51226. axes: number[];
  51227. /**
  51228. * An array of available buttons
  51229. */
  51230. buttons: Array<{
  51231. /**
  51232. * Value of the button/trigger
  51233. */
  51234. value: number;
  51235. /**
  51236. * If the button/trigger is currently touched
  51237. */
  51238. touched: boolean;
  51239. /**
  51240. * If the button/trigger is currently pressed
  51241. */
  51242. pressed: boolean;
  51243. }>;
  51244. /**
  51245. * EXPERIMENTAL haptic support.
  51246. */
  51247. hapticActuators?: Array<{
  51248. pulse: (value: number, duration: number) => Promise<boolean>;
  51249. }>;
  51250. }
  51251. /**
  51252. * An Abstract Motion controller
  51253. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51254. * Each component has an observable to check for changes in value and state
  51255. */
  51256. export abstract class WebXRAbstractMotionController implements IDisposable {
  51257. protected scene: Scene;
  51258. protected layout: IMotionControllerLayout;
  51259. /**
  51260. * The gamepad object correlating to this controller
  51261. */
  51262. gamepadObject: IMinimalMotionControllerObject;
  51263. /**
  51264. * handedness (left/right/none) of this controller
  51265. */
  51266. handedness: MotionControllerHandedness;
  51267. private _initComponent;
  51268. private _modelReady;
  51269. /**
  51270. * A map of components (WebXRControllerComponent) in this motion controller
  51271. * Components have a ComponentType and can also have both button and axis definitions
  51272. */
  51273. readonly components: {
  51274. [id: string]: WebXRControllerComponent;
  51275. };
  51276. /**
  51277. * Disable the model's animation. Can be set at any time.
  51278. */
  51279. disableAnimation: boolean;
  51280. /**
  51281. * Observers registered here will be triggered when the model of this controller is done loading
  51282. */
  51283. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51284. /**
  51285. * The profile id of this motion controller
  51286. */
  51287. abstract profileId: string;
  51288. /**
  51289. * The root mesh of the model. It is null if the model was not yet initialized
  51290. */
  51291. rootMesh: Nullable<AbstractMesh>;
  51292. /**
  51293. * constructs a new abstract motion controller
  51294. * @param scene the scene to which the model of the controller will be added
  51295. * @param layout The profile layout to load
  51296. * @param gamepadObject The gamepad object correlating to this controller
  51297. * @param handedness handedness (left/right/none) of this controller
  51298. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51299. */
  51300. constructor(scene: Scene, layout: IMotionControllerLayout,
  51301. /**
  51302. * The gamepad object correlating to this controller
  51303. */
  51304. gamepadObject: IMinimalMotionControllerObject,
  51305. /**
  51306. * handedness (left/right/none) of this controller
  51307. */
  51308. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51309. /**
  51310. * Dispose this controller, the model mesh and all its components
  51311. */
  51312. dispose(): void;
  51313. /**
  51314. * Returns all components of specific type
  51315. * @param type the type to search for
  51316. * @return an array of components with this type
  51317. */
  51318. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51319. /**
  51320. * get a component based an its component id as defined in layout.components
  51321. * @param id the id of the component
  51322. * @returns the component correlates to the id or undefined if not found
  51323. */
  51324. getComponent(id: string): WebXRControllerComponent;
  51325. /**
  51326. * Get the list of components available in this motion controller
  51327. * @returns an array of strings correlating to available components
  51328. */
  51329. getComponentIds(): string[];
  51330. /**
  51331. * Get the first component of specific type
  51332. * @param type type of component to find
  51333. * @return a controller component or null if not found
  51334. */
  51335. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51336. /**
  51337. * Get the main (Select) component of this controller as defined in the layout
  51338. * @returns the main component of this controller
  51339. */
  51340. getMainComponent(): WebXRControllerComponent;
  51341. /**
  51342. * Loads the model correlating to this controller
  51343. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51344. * @returns A promise fulfilled with the result of the model loading
  51345. */
  51346. loadModel(): Promise<boolean>;
  51347. /**
  51348. * Update this model using the current XRFrame
  51349. * @param xrFrame the current xr frame to use and update the model
  51350. */
  51351. updateFromXRFrame(xrFrame: XRFrame): void;
  51352. /**
  51353. * Backwards compatibility due to a deeply-integrated typo
  51354. */
  51355. get handness(): XREye;
  51356. /**
  51357. * Pulse (vibrate) this controller
  51358. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51359. * Consecutive calls to this function will cancel the last pulse call
  51360. *
  51361. * @param value the strength of the pulse in 0.0...1.0 range
  51362. * @param duration Duration of the pulse in milliseconds
  51363. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51364. * @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
  51365. */
  51366. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51367. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51368. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51369. /**
  51370. * Moves the axis on the controller mesh based on its current state
  51371. * @param axis the index of the axis
  51372. * @param axisValue the value of the axis which determines the meshes new position
  51373. * @hidden
  51374. */
  51375. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51376. /**
  51377. * Update the model itself with the current frame data
  51378. * @param xrFrame the frame to use for updating the model mesh
  51379. */
  51380. protected updateModel(xrFrame: XRFrame): void;
  51381. /**
  51382. * Get the filename and path for this controller's model
  51383. * @returns a map of filename and path
  51384. */
  51385. protected abstract _getFilenameAndPath(): {
  51386. filename: string;
  51387. path: string;
  51388. };
  51389. /**
  51390. * This function is called before the mesh is loaded. It checks for loading constraints.
  51391. * For example, this function can check if the GLB loader is available
  51392. * If this function returns false, the generic controller will be loaded instead
  51393. * @returns Is the client ready to load the mesh
  51394. */
  51395. protected abstract _getModelLoadingConstraints(): boolean;
  51396. /**
  51397. * This function will be called after the model was successfully loaded and can be used
  51398. * for mesh transformations before it is available for the user
  51399. * @param meshes the loaded meshes
  51400. */
  51401. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51402. /**
  51403. * Set the root mesh for this controller. Important for the WebXR controller class
  51404. * @param meshes the loaded meshes
  51405. */
  51406. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51407. /**
  51408. * A function executed each frame that updates the mesh (if needed)
  51409. * @param xrFrame the current xrFrame
  51410. */
  51411. protected abstract _updateModel(xrFrame: XRFrame): void;
  51412. private _getGenericFilenameAndPath;
  51413. private _getGenericParentMesh;
  51414. }
  51415. }
  51416. declare module BABYLON {
  51417. /**
  51418. * A generic trigger-only motion controller for WebXR
  51419. */
  51420. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51421. /**
  51422. * Static version of the profile id of this controller
  51423. */
  51424. static ProfileId: string;
  51425. profileId: string;
  51426. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51427. protected _getFilenameAndPath(): {
  51428. filename: string;
  51429. path: string;
  51430. };
  51431. protected _getModelLoadingConstraints(): boolean;
  51432. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51433. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51434. protected _updateModel(): void;
  51435. }
  51436. }
  51437. declare module BABYLON {
  51438. /**
  51439. * Class containing static functions to help procedurally build meshes
  51440. */
  51441. export class SphereBuilder {
  51442. /**
  51443. * Creates a sphere mesh
  51444. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51445. * * 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`)
  51446. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51447. * * 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
  51448. * * 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)
  51449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51450. * * 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
  51451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51452. * @param name defines the name of the mesh
  51453. * @param options defines the options used to create the mesh
  51454. * @param scene defines the hosting scene
  51455. * @returns the sphere mesh
  51456. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51457. */
  51458. static CreateSphere(name: string, options: {
  51459. segments?: number;
  51460. diameter?: number;
  51461. diameterX?: number;
  51462. diameterY?: number;
  51463. diameterZ?: number;
  51464. arc?: number;
  51465. slice?: number;
  51466. sideOrientation?: number;
  51467. frontUVs?: Vector4;
  51468. backUVs?: Vector4;
  51469. updatable?: boolean;
  51470. }, scene?: Nullable<Scene>): Mesh;
  51471. }
  51472. }
  51473. declare module BABYLON {
  51474. /**
  51475. * A profiled motion controller has its profile loaded from an online repository.
  51476. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51477. */
  51478. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51479. private _repositoryUrl;
  51480. private _buttonMeshMapping;
  51481. private _touchDots;
  51482. /**
  51483. * The profile ID of this controller. Will be populated when the controller initializes.
  51484. */
  51485. profileId: string;
  51486. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51487. dispose(): void;
  51488. protected _getFilenameAndPath(): {
  51489. filename: string;
  51490. path: string;
  51491. };
  51492. protected _getModelLoadingConstraints(): boolean;
  51493. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51494. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51495. protected _updateModel(_xrFrame: XRFrame): void;
  51496. }
  51497. }
  51498. declare module BABYLON {
  51499. /**
  51500. * A construction function type to create a new controller based on an xrInput object
  51501. */
  51502. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51503. /**
  51504. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51505. *
  51506. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51507. * it should be replaced with auto-loaded controllers.
  51508. *
  51509. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51510. */
  51511. export class WebXRMotionControllerManager {
  51512. private static _AvailableControllers;
  51513. private static _Fallbacks;
  51514. private static _ProfileLoadingPromises;
  51515. private static _ProfilesList;
  51516. /**
  51517. * The base URL of the online controller repository. Can be changed at any time.
  51518. */
  51519. static BaseRepositoryUrl: string;
  51520. /**
  51521. * Which repository gets priority - local or online
  51522. */
  51523. static PrioritizeOnlineRepository: boolean;
  51524. /**
  51525. * Use the online repository, or use only locally-defined controllers
  51526. */
  51527. static UseOnlineRepository: boolean;
  51528. /**
  51529. * Clear the cache used for profile loading and reload when requested again
  51530. */
  51531. static ClearProfilesCache(): void;
  51532. /**
  51533. * Register the default fallbacks.
  51534. * This function is called automatically when this file is imported.
  51535. */
  51536. static DefaultFallbacks(): void;
  51537. /**
  51538. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51539. * @param profileId the profile to which a fallback needs to be found
  51540. * @return an array with corresponding fallback profiles
  51541. */
  51542. static FindFallbackWithProfileId(profileId: string): string[];
  51543. /**
  51544. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51545. * The order of search:
  51546. *
  51547. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51548. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51549. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51550. * 4) return the generic trigger controller if none were found
  51551. *
  51552. * @param xrInput the xrInput to which a new controller is initialized
  51553. * @param scene the scene to which the model will be added
  51554. * @param forceProfile force a certain profile for this controller
  51555. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51556. */
  51557. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51558. /**
  51559. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51560. *
  51561. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51562. *
  51563. * @param type the profile type to register
  51564. * @param constructFunction the function to be called when loading this profile
  51565. */
  51566. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51567. /**
  51568. * Register a fallback to a specific profile.
  51569. * @param profileId the profileId that will receive the fallbacks
  51570. * @param fallbacks A list of fallback profiles
  51571. */
  51572. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51573. /**
  51574. * Will update the list of profiles available in the repository
  51575. * @return a promise that resolves to a map of profiles available online
  51576. */
  51577. static UpdateProfilesList(): Promise<{
  51578. [profile: string]: string;
  51579. }>;
  51580. private static _LoadProfileFromRepository;
  51581. private static _LoadProfilesFromAvailableControllers;
  51582. }
  51583. }
  51584. declare module BABYLON {
  51585. /**
  51586. * Configuration options for the WebXR controller creation
  51587. */
  51588. export interface IWebXRControllerOptions {
  51589. /**
  51590. * Should the controller mesh be animated when a user interacts with it
  51591. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51592. */
  51593. disableMotionControllerAnimation?: boolean;
  51594. /**
  51595. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51596. */
  51597. doNotLoadControllerMesh?: boolean;
  51598. /**
  51599. * Force a specific controller type for this controller.
  51600. * This can be used when creating your own profile or when testing different controllers
  51601. */
  51602. forceControllerProfile?: string;
  51603. /**
  51604. * Defines a rendering group ID for meshes that will be loaded.
  51605. * This is for the default controllers only.
  51606. */
  51607. renderingGroupId?: number;
  51608. }
  51609. /**
  51610. * Represents an XR controller
  51611. */
  51612. export class WebXRInputSource {
  51613. private _scene;
  51614. /** The underlying input source for the controller */
  51615. inputSource: XRInputSource;
  51616. private _options;
  51617. private _tmpVector;
  51618. private _uniqueId;
  51619. private _disposed;
  51620. /**
  51621. * 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
  51622. */
  51623. grip?: AbstractMesh;
  51624. /**
  51625. * If available, this is the gamepad object related to this controller.
  51626. * Using this object it is possible to get click events and trackpad changes of the
  51627. * webxr controller that is currently being used.
  51628. */
  51629. motionController?: WebXRAbstractMotionController;
  51630. /**
  51631. * Event that fires when the controller is removed/disposed.
  51632. * The object provided as event data is this controller, after associated assets were disposed.
  51633. * uniqueId is still available.
  51634. */
  51635. onDisposeObservable: Observable<WebXRInputSource>;
  51636. /**
  51637. * Will be triggered when the mesh associated with the motion controller is done loading.
  51638. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51639. * A shortened version of controller -> motion controller -> on mesh loaded.
  51640. */
  51641. onMeshLoadedObservable: Observable<AbstractMesh>;
  51642. /**
  51643. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51644. */
  51645. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51646. /**
  51647. * Pointer which can be used to select objects or attach a visible laser to
  51648. */
  51649. pointer: AbstractMesh;
  51650. /**
  51651. * Creates the input source object
  51652. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51653. * @param _scene the scene which the controller should be associated to
  51654. * @param inputSource the underlying input source for the controller
  51655. * @param _options options for this controller creation
  51656. */
  51657. constructor(_scene: Scene,
  51658. /** The underlying input source for the controller */
  51659. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51660. /**
  51661. * Get this controllers unique id
  51662. */
  51663. get uniqueId(): string;
  51664. /**
  51665. * Disposes of the object
  51666. */
  51667. dispose(): void;
  51668. /**
  51669. * Gets a world space ray coming from the pointer or grip
  51670. * @param result the resulting ray
  51671. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51672. */
  51673. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51674. /**
  51675. * Updates the controller pose based on the given XRFrame
  51676. * @param xrFrame xr frame to update the pose with
  51677. * @param referenceSpace reference space to use
  51678. */
  51679. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51680. }
  51681. }
  51682. declare module BABYLON {
  51683. /**
  51684. * The schema for initialization options of the XR Input class
  51685. */
  51686. export interface IWebXRInputOptions {
  51687. /**
  51688. * If set to true no model will be automatically loaded
  51689. */
  51690. doNotLoadControllerMeshes?: boolean;
  51691. /**
  51692. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51693. * If not found, the xr input profile data will be used.
  51694. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51695. */
  51696. forceInputProfile?: string;
  51697. /**
  51698. * Do not send a request to the controller repository to load the profile.
  51699. *
  51700. * Instead, use the controllers available in babylon itself.
  51701. */
  51702. disableOnlineControllerRepository?: boolean;
  51703. /**
  51704. * A custom URL for the controllers repository
  51705. */
  51706. customControllersRepositoryURL?: string;
  51707. /**
  51708. * Should the controller model's components not move according to the user input
  51709. */
  51710. disableControllerAnimation?: boolean;
  51711. /**
  51712. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51713. */
  51714. controllerOptions?: IWebXRControllerOptions;
  51715. }
  51716. /**
  51717. * XR input used to track XR inputs such as controllers/rays
  51718. */
  51719. export class WebXRInput implements IDisposable {
  51720. /**
  51721. * the xr session manager for this session
  51722. */
  51723. xrSessionManager: WebXRSessionManager;
  51724. /**
  51725. * the WebXR camera for this session. Mainly used for teleportation
  51726. */
  51727. xrCamera: WebXRCamera;
  51728. private readonly options;
  51729. /**
  51730. * XR controllers being tracked
  51731. */
  51732. controllers: Array<WebXRInputSource>;
  51733. private _frameObserver;
  51734. private _sessionEndedObserver;
  51735. private _sessionInitObserver;
  51736. /**
  51737. * Event when a controller has been connected/added
  51738. */
  51739. onControllerAddedObservable: Observable<WebXRInputSource>;
  51740. /**
  51741. * Event when a controller has been removed/disconnected
  51742. */
  51743. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51744. /**
  51745. * Initializes the WebXRInput
  51746. * @param xrSessionManager the xr session manager for this session
  51747. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51748. * @param options = initialization options for this xr input
  51749. */
  51750. constructor(
  51751. /**
  51752. * the xr session manager for this session
  51753. */
  51754. xrSessionManager: WebXRSessionManager,
  51755. /**
  51756. * the WebXR camera for this session. Mainly used for teleportation
  51757. */
  51758. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51759. private _onInputSourcesChange;
  51760. private _addAndRemoveControllers;
  51761. /**
  51762. * Disposes of the object
  51763. */
  51764. dispose(): void;
  51765. }
  51766. }
  51767. declare module BABYLON {
  51768. /**
  51769. * This is the base class for all WebXR features.
  51770. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51771. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51772. */
  51773. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51774. protected _xrSessionManager: WebXRSessionManager;
  51775. private _attached;
  51776. private _removeOnDetach;
  51777. /**
  51778. * Is this feature disposed?
  51779. */
  51780. isDisposed: boolean;
  51781. /**
  51782. * Should auto-attach be disabled?
  51783. */
  51784. disableAutoAttach: boolean;
  51785. /**
  51786. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51787. */
  51788. xrNativeFeatureName: string;
  51789. /**
  51790. * Construct a new (abstract) WebXR feature
  51791. * @param _xrSessionManager the xr session manager for this feature
  51792. */
  51793. constructor(_xrSessionManager: WebXRSessionManager);
  51794. /**
  51795. * Is this feature attached
  51796. */
  51797. get attached(): boolean;
  51798. /**
  51799. * attach this feature
  51800. *
  51801. * @param force should attachment be forced (even when already attached)
  51802. * @returns true if successful, false is failed or already attached
  51803. */
  51804. attach(force?: boolean): boolean;
  51805. /**
  51806. * detach this feature.
  51807. *
  51808. * @returns true if successful, false if failed or already detached
  51809. */
  51810. detach(): boolean;
  51811. /**
  51812. * Dispose this feature and all of the resources attached
  51813. */
  51814. dispose(): void;
  51815. /**
  51816. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51817. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51818. *
  51819. * @returns whether or not the feature is compatible in this environment
  51820. */
  51821. isCompatible(): boolean;
  51822. /**
  51823. * This is used to register callbacks that will automatically be removed when detach is called.
  51824. * @param observable the observable to which the observer will be attached
  51825. * @param callback the callback to register
  51826. */
  51827. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51828. /**
  51829. * Code in this function will be executed on each xrFrame received from the browser.
  51830. * This function will not execute after the feature is detached.
  51831. * @param _xrFrame the current frame
  51832. */
  51833. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51834. }
  51835. }
  51836. declare module BABYLON {
  51837. /**
  51838. * Renders a layer on top of an existing scene
  51839. */
  51840. export class UtilityLayerRenderer implements IDisposable {
  51841. /** the original scene that will be rendered on top of */
  51842. originalScene: Scene;
  51843. private _pointerCaptures;
  51844. private _lastPointerEvents;
  51845. private static _DefaultUtilityLayer;
  51846. private static _DefaultKeepDepthUtilityLayer;
  51847. private _sharedGizmoLight;
  51848. private _renderCamera;
  51849. /**
  51850. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51851. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51852. * @returns the camera that is used when rendering the utility layer
  51853. */
  51854. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51855. /**
  51856. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51857. * @param cam the camera that should be used when rendering the utility layer
  51858. */
  51859. setRenderCamera(cam: Nullable<Camera>): void;
  51860. /**
  51861. * @hidden
  51862. * Light which used by gizmos to get light shading
  51863. */
  51864. _getSharedGizmoLight(): HemisphericLight;
  51865. /**
  51866. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51867. */
  51868. pickUtilitySceneFirst: boolean;
  51869. /**
  51870. * 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)
  51871. */
  51872. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51873. /**
  51874. * 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)
  51875. */
  51876. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51877. /**
  51878. * The scene that is rendered on top of the original scene
  51879. */
  51880. utilityLayerScene: Scene;
  51881. /**
  51882. * If the utility layer should automatically be rendered on top of existing scene
  51883. */
  51884. shouldRender: boolean;
  51885. /**
  51886. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51887. */
  51888. onlyCheckPointerDownEvents: boolean;
  51889. /**
  51890. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51891. */
  51892. processAllEvents: boolean;
  51893. /**
  51894. * Observable raised when the pointer move from the utility layer scene to the main scene
  51895. */
  51896. onPointerOutObservable: Observable<number>;
  51897. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51898. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51899. private _afterRenderObserver;
  51900. private _sceneDisposeObserver;
  51901. private _originalPointerObserver;
  51902. /**
  51903. * Instantiates a UtilityLayerRenderer
  51904. * @param originalScene the original scene that will be rendered on top of
  51905. * @param handleEvents boolean indicating if the utility layer should handle events
  51906. */
  51907. constructor(
  51908. /** the original scene that will be rendered on top of */
  51909. originalScene: Scene, handleEvents?: boolean);
  51910. private _notifyObservers;
  51911. /**
  51912. * Renders the utility layers scene on top of the original scene
  51913. */
  51914. render(): void;
  51915. /**
  51916. * Disposes of the renderer
  51917. */
  51918. dispose(): void;
  51919. private _updateCamera;
  51920. }
  51921. }
  51922. declare module BABYLON {
  51923. /**
  51924. * Options interface for the pointer selection module
  51925. */
  51926. export interface IWebXRControllerPointerSelectionOptions {
  51927. /**
  51928. * if provided, this scene will be used to render meshes.
  51929. */
  51930. customUtilityLayerScene?: Scene;
  51931. /**
  51932. * 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)
  51933. * If not disabled, the last picked point will be used to execute a pointer up event
  51934. * If disabled, pointer up event will be triggered right after the pointer down event.
  51935. * Used in screen and gaze target ray mode only
  51936. */
  51937. disablePointerUpOnTouchOut: boolean;
  51938. /**
  51939. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51940. */
  51941. forceGazeMode: boolean;
  51942. /**
  51943. * 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
  51944. * to start a new countdown to the pointer down event.
  51945. * Defaults to 1.
  51946. */
  51947. gazeModePointerMovedFactor?: number;
  51948. /**
  51949. * Different button type to use instead of the main component
  51950. */
  51951. overrideButtonId?: string;
  51952. /**
  51953. * use this rendering group id for the meshes (optional)
  51954. */
  51955. renderingGroupId?: number;
  51956. /**
  51957. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51958. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51959. * 3000 means 3 seconds between pointing at something and selecting it
  51960. */
  51961. timeToSelect?: number;
  51962. /**
  51963. * Should meshes created here be added to a utility layer or the main scene
  51964. */
  51965. useUtilityLayer?: boolean;
  51966. /**
  51967. * Optional WebXR camera to be used for gaze selection
  51968. */
  51969. gazeCamera?: WebXRCamera;
  51970. /**
  51971. * the xr input to use with this pointer selection
  51972. */
  51973. xrInput: WebXRInput;
  51974. /**
  51975. * Should the scene pointerX and pointerY update be disabled
  51976. * This is required for fullscreen AR GUI, but might slow down other experiences.
  51977. * Disable in VR, if not needed.
  51978. * The first rig camera (left eye) will be used to calculate the projection
  51979. */
  51980. disableScenePointerVectorUpdate: boolean;
  51981. }
  51982. /**
  51983. * A module that will enable pointer selection for motion controllers of XR Input Sources
  51984. */
  51985. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  51986. private readonly _options;
  51987. private static _idCounter;
  51988. private _attachController;
  51989. private _controllers;
  51990. private _scene;
  51991. private _tmpVectorForPickCompare;
  51992. /**
  51993. * The module's name
  51994. */
  51995. static readonly Name: string;
  51996. /**
  51997. * The (Babylon) version of this module.
  51998. * This is an integer representing the implementation version.
  51999. * This number does not correspond to the WebXR specs version
  52000. */
  52001. static readonly Version: number;
  52002. /**
  52003. * Disable lighting on the laser pointer (so it will always be visible)
  52004. */
  52005. disablePointerLighting: boolean;
  52006. /**
  52007. * Disable lighting on the selection mesh (so it will always be visible)
  52008. */
  52009. disableSelectionMeshLighting: boolean;
  52010. /**
  52011. * Should the laser pointer be displayed
  52012. */
  52013. displayLaserPointer: boolean;
  52014. /**
  52015. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52016. */
  52017. displaySelectionMesh: boolean;
  52018. /**
  52019. * This color will be set to the laser pointer when selection is triggered
  52020. */
  52021. laserPointerPickedColor: Color3;
  52022. /**
  52023. * Default color of the laser pointer
  52024. */
  52025. laserPointerDefaultColor: Color3;
  52026. /**
  52027. * default color of the selection ring
  52028. */
  52029. selectionMeshDefaultColor: Color3;
  52030. /**
  52031. * This color will be applied to the selection ring when selection is triggered
  52032. */
  52033. selectionMeshPickedColor: Color3;
  52034. /**
  52035. * Optional filter to be used for ray selection. This predicate shares behavior with
  52036. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52037. */
  52038. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52039. /**
  52040. * constructs a new background remover module
  52041. * @param _xrSessionManager the session manager for this module
  52042. * @param _options read-only options to be used in this module
  52043. */
  52044. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52045. /**
  52046. * attach this feature
  52047. * Will usually be called by the features manager
  52048. *
  52049. * @returns true if successful.
  52050. */
  52051. attach(): boolean;
  52052. /**
  52053. * detach this feature.
  52054. * Will usually be called by the features manager
  52055. *
  52056. * @returns true if successful.
  52057. */
  52058. detach(): boolean;
  52059. /**
  52060. * Will get the mesh under a specific pointer.
  52061. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52062. * @param controllerId the controllerId to check
  52063. * @returns The mesh under pointer or null if no mesh is under the pointer
  52064. */
  52065. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52066. /**
  52067. * Get the xr controller that correlates to the pointer id in the pointer event
  52068. *
  52069. * @param id the pointer id to search for
  52070. * @returns the controller that correlates to this id or null if not found
  52071. */
  52072. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52073. private _identityMatrix;
  52074. private _screenCoordinatesRef;
  52075. private _viewportRef;
  52076. protected _onXRFrame(_xrFrame: XRFrame): void;
  52077. private _attachGazeMode;
  52078. private _attachScreenRayMode;
  52079. private _attachTrackedPointerRayMode;
  52080. private _convertNormalToDirectionOfRay;
  52081. private _detachController;
  52082. private _generateNewMeshPair;
  52083. private _pickingMoved;
  52084. private _updatePointerDistance;
  52085. /** @hidden */
  52086. get lasterPointerDefaultColor(): Color3;
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * Button which can be used to enter a different mode of XR
  52092. */
  52093. export class WebXREnterExitUIButton {
  52094. /** button element */
  52095. element: HTMLElement;
  52096. /** XR initialization options for the button */
  52097. sessionMode: XRSessionMode;
  52098. /** Reference space type */
  52099. referenceSpaceType: XRReferenceSpaceType;
  52100. /**
  52101. * Creates a WebXREnterExitUIButton
  52102. * @param element button element
  52103. * @param sessionMode XR initialization session mode
  52104. * @param referenceSpaceType the type of reference space to be used
  52105. */
  52106. constructor(
  52107. /** button element */
  52108. element: HTMLElement,
  52109. /** XR initialization options for the button */
  52110. sessionMode: XRSessionMode,
  52111. /** Reference space type */
  52112. referenceSpaceType: XRReferenceSpaceType);
  52113. /**
  52114. * Extendable function which can be used to update the button's visuals when the state changes
  52115. * @param activeButton the current active button in the UI
  52116. */
  52117. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52118. }
  52119. /**
  52120. * Options to create the webXR UI
  52121. */
  52122. export class WebXREnterExitUIOptions {
  52123. /**
  52124. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52125. */
  52126. customButtons?: Array<WebXREnterExitUIButton>;
  52127. /**
  52128. * A reference space type to use when creating the default button.
  52129. * Default is local-floor
  52130. */
  52131. referenceSpaceType?: XRReferenceSpaceType;
  52132. /**
  52133. * Context to enter xr with
  52134. */
  52135. renderTarget?: Nullable<WebXRRenderTarget>;
  52136. /**
  52137. * A session mode to use when creating the default button.
  52138. * Default is immersive-vr
  52139. */
  52140. sessionMode?: XRSessionMode;
  52141. /**
  52142. * A list of optional features to init the session with
  52143. */
  52144. optionalFeatures?: string[];
  52145. /**
  52146. * A list of optional features to init the session with
  52147. */
  52148. requiredFeatures?: string[];
  52149. }
  52150. /**
  52151. * UI to allow the user to enter/exit XR mode
  52152. */
  52153. export class WebXREnterExitUI implements IDisposable {
  52154. private scene;
  52155. /** version of the options passed to this UI */
  52156. options: WebXREnterExitUIOptions;
  52157. private _activeButton;
  52158. private _buttons;
  52159. /**
  52160. * The HTML Div Element to which buttons are added.
  52161. */
  52162. readonly overlay: HTMLDivElement;
  52163. /**
  52164. * Fired every time the active button is changed.
  52165. *
  52166. * When xr is entered via a button that launches xr that button will be the callback parameter
  52167. *
  52168. * When exiting xr the callback parameter will be null)
  52169. */
  52170. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52171. /**
  52172. *
  52173. * @param scene babylon scene object to use
  52174. * @param options (read-only) version of the options passed to this UI
  52175. */
  52176. private constructor();
  52177. /**
  52178. * Creates UI to allow the user to enter/exit XR mode
  52179. * @param scene the scene to add the ui to
  52180. * @param helper the xr experience helper to enter/exit xr with
  52181. * @param options options to configure the UI
  52182. * @returns the created ui
  52183. */
  52184. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52185. /**
  52186. * Disposes of the XR UI component
  52187. */
  52188. dispose(): void;
  52189. private _updateButtons;
  52190. }
  52191. }
  52192. declare module BABYLON {
  52193. /**
  52194. * Class containing static functions to help procedurally build meshes
  52195. */
  52196. export class LinesBuilder {
  52197. /**
  52198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52199. * * 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
  52200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52205. * * 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
  52206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52209. * @param name defines the name of the new line system
  52210. * @param options defines the options used to create the line system
  52211. * @param scene defines the hosting scene
  52212. * @returns a new line system mesh
  52213. */
  52214. static CreateLineSystem(name: string, options: {
  52215. lines: Vector3[][];
  52216. updatable?: boolean;
  52217. instance?: Nullable<LinesMesh>;
  52218. colors?: Nullable<Color4[][]>;
  52219. useVertexAlpha?: boolean;
  52220. }, scene: Nullable<Scene>): LinesMesh;
  52221. /**
  52222. * Creates a line mesh
  52223. * 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
  52224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52225. * * The parameter `points` is an array successive Vector3
  52226. * * 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
  52227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52229. * * When updating an instance, remember that only point positions can change, not the number of points
  52230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52232. * @param name defines the name of the new line system
  52233. * @param options defines the options used to create the line system
  52234. * @param scene defines the hosting scene
  52235. * @returns a new line mesh
  52236. */
  52237. static CreateLines(name: string, options: {
  52238. points: Vector3[];
  52239. updatable?: boolean;
  52240. instance?: Nullable<LinesMesh>;
  52241. colors?: Color4[];
  52242. useVertexAlpha?: boolean;
  52243. }, scene?: Nullable<Scene>): LinesMesh;
  52244. /**
  52245. * Creates a dashed line mesh
  52246. * * 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
  52247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52248. * * The parameter `points` is an array successive Vector3
  52249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52252. * * 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
  52253. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52254. * * When updating an instance, remember that only point positions can change, not the number of points
  52255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52256. * @param name defines the name of the mesh
  52257. * @param options defines the options used to create the mesh
  52258. * @param scene defines the hosting scene
  52259. * @returns the dashed line mesh
  52260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52261. */
  52262. static CreateDashedLines(name: string, options: {
  52263. points: Vector3[];
  52264. dashSize?: number;
  52265. gapSize?: number;
  52266. dashNb?: number;
  52267. updatable?: boolean;
  52268. instance?: LinesMesh;
  52269. useVertexAlpha?: boolean;
  52270. }, scene?: Nullable<Scene>): LinesMesh;
  52271. }
  52272. }
  52273. declare module BABYLON {
  52274. /**
  52275. * Construction options for a timer
  52276. */
  52277. export interface ITimerOptions<T> {
  52278. /**
  52279. * Time-to-end
  52280. */
  52281. timeout: number;
  52282. /**
  52283. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52284. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52285. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52286. */
  52287. contextObservable: Observable<T>;
  52288. /**
  52289. * Optional parameters when adding an observer to the observable
  52290. */
  52291. observableParameters?: {
  52292. mask?: number;
  52293. insertFirst?: boolean;
  52294. scope?: any;
  52295. };
  52296. /**
  52297. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52298. */
  52299. breakCondition?: (data?: ITimerData<T>) => boolean;
  52300. /**
  52301. * Will be triggered when the time condition has met
  52302. */
  52303. onEnded?: (data: ITimerData<any>) => void;
  52304. /**
  52305. * Will be triggered when the break condition has met (prematurely ended)
  52306. */
  52307. onAborted?: (data: ITimerData<any>) => void;
  52308. /**
  52309. * Optional function to execute on each tick (or count)
  52310. */
  52311. onTick?: (data: ITimerData<any>) => void;
  52312. }
  52313. /**
  52314. * An interface defining the data sent by the timer
  52315. */
  52316. export interface ITimerData<T> {
  52317. /**
  52318. * When did it start
  52319. */
  52320. startTime: number;
  52321. /**
  52322. * Time now
  52323. */
  52324. currentTime: number;
  52325. /**
  52326. * Time passed since started
  52327. */
  52328. deltaTime: number;
  52329. /**
  52330. * How much is completed, in [0.0...1.0].
  52331. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52332. */
  52333. completeRate: number;
  52334. /**
  52335. * What the registered observable sent in the last count
  52336. */
  52337. payload: T;
  52338. }
  52339. /**
  52340. * The current state of the timer
  52341. */
  52342. export enum TimerState {
  52343. /**
  52344. * Timer initialized, not yet started
  52345. */
  52346. INIT = 0,
  52347. /**
  52348. * Timer started and counting
  52349. */
  52350. STARTED = 1,
  52351. /**
  52352. * Timer ended (whether aborted or time reached)
  52353. */
  52354. ENDED = 2
  52355. }
  52356. /**
  52357. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52358. *
  52359. * @param options options with which to initialize this timer
  52360. */
  52361. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52362. /**
  52363. * An advanced implementation of a timer class
  52364. */
  52365. export class AdvancedTimer<T = any> implements IDisposable {
  52366. /**
  52367. * Will notify each time the timer calculates the remaining time
  52368. */
  52369. onEachCountObservable: Observable<ITimerData<T>>;
  52370. /**
  52371. * Will trigger when the timer was aborted due to the break condition
  52372. */
  52373. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52374. /**
  52375. * Will trigger when the timer ended successfully
  52376. */
  52377. onTimerEndedObservable: Observable<ITimerData<T>>;
  52378. /**
  52379. * Will trigger when the timer state has changed
  52380. */
  52381. onStateChangedObservable: Observable<TimerState>;
  52382. private _observer;
  52383. private _contextObservable;
  52384. private _observableParameters;
  52385. private _startTime;
  52386. private _timer;
  52387. private _state;
  52388. private _breakCondition;
  52389. private _timeToEnd;
  52390. private _breakOnNextTick;
  52391. /**
  52392. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52393. * @param options construction options for this advanced timer
  52394. */
  52395. constructor(options: ITimerOptions<T>);
  52396. /**
  52397. * set a breaking condition for this timer. Default is to never break during count
  52398. * @param predicate the new break condition. Returns true to break, false otherwise
  52399. */
  52400. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52401. /**
  52402. * Reset ALL associated observables in this advanced timer
  52403. */
  52404. clearObservables(): void;
  52405. /**
  52406. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52407. *
  52408. * @param timeToEnd how much time to measure until timer ended
  52409. */
  52410. start(timeToEnd?: number): void;
  52411. /**
  52412. * Will force a stop on the next tick.
  52413. */
  52414. stop(): void;
  52415. /**
  52416. * Dispose this timer, clearing all resources
  52417. */
  52418. dispose(): void;
  52419. private _setState;
  52420. private _tick;
  52421. private _stop;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * The options container for the teleportation module
  52427. */
  52428. export interface IWebXRTeleportationOptions {
  52429. /**
  52430. * if provided, this scene will be used to render meshes.
  52431. */
  52432. customUtilityLayerScene?: Scene;
  52433. /**
  52434. * Values to configure the default target mesh
  52435. */
  52436. defaultTargetMeshOptions?: {
  52437. /**
  52438. * Fill color of the teleportation area
  52439. */
  52440. teleportationFillColor?: string;
  52441. /**
  52442. * Border color for the teleportation area
  52443. */
  52444. teleportationBorderColor?: string;
  52445. /**
  52446. * Disable the mesh's animation sequence
  52447. */
  52448. disableAnimation?: boolean;
  52449. /**
  52450. * Disable lighting on the material or the ring and arrow
  52451. */
  52452. disableLighting?: boolean;
  52453. /**
  52454. * Override the default material of the torus and arrow
  52455. */
  52456. torusArrowMaterial?: Material;
  52457. };
  52458. /**
  52459. * A list of meshes to use as floor meshes.
  52460. * Meshes can be added and removed after initializing the feature using the
  52461. * addFloorMesh and removeFloorMesh functions
  52462. * If empty, rotation will still work
  52463. */
  52464. floorMeshes?: AbstractMesh[];
  52465. /**
  52466. * use this rendering group id for the meshes (optional)
  52467. */
  52468. renderingGroupId?: number;
  52469. /**
  52470. * Should teleportation move only to snap points
  52471. */
  52472. snapPointsOnly?: boolean;
  52473. /**
  52474. * An array of points to which the teleportation will snap to.
  52475. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52476. */
  52477. snapPositions?: Vector3[];
  52478. /**
  52479. * How close should the teleportation ray be in order to snap to position.
  52480. * Default to 0.8 units (meters)
  52481. */
  52482. snapToPositionRadius?: number;
  52483. /**
  52484. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52485. * If you want to support rotation, make sure your mesh has a direction indicator.
  52486. *
  52487. * When left untouched, the default mesh will be initialized.
  52488. */
  52489. teleportationTargetMesh?: AbstractMesh;
  52490. /**
  52491. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52492. */
  52493. timeToTeleport?: number;
  52494. /**
  52495. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52496. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52497. */
  52498. useMainComponentOnly?: boolean;
  52499. /**
  52500. * Should meshes created here be added to a utility layer or the main scene
  52501. */
  52502. useUtilityLayer?: boolean;
  52503. /**
  52504. * Babylon XR Input class for controller
  52505. */
  52506. xrInput: WebXRInput;
  52507. /**
  52508. * Meshes that the teleportation ray cannot go through
  52509. */
  52510. pickBlockerMeshes?: AbstractMesh[];
  52511. }
  52512. /**
  52513. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52514. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52515. * the input of the attached controllers.
  52516. */
  52517. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52518. private _options;
  52519. private _controllers;
  52520. private _currentTeleportationControllerId;
  52521. private _floorMeshes;
  52522. private _quadraticBezierCurve;
  52523. private _selectionFeature;
  52524. private _snapToPositions;
  52525. private _snappedToPoint;
  52526. private _teleportationRingMaterial?;
  52527. private _tmpRay;
  52528. private _tmpVector;
  52529. private _tmpQuaternion;
  52530. /**
  52531. * The module's name
  52532. */
  52533. static readonly Name: string;
  52534. /**
  52535. * The (Babylon) version of this module.
  52536. * This is an integer representing the implementation version.
  52537. * This number does not correspond to the webxr specs version
  52538. */
  52539. static readonly Version: number;
  52540. /**
  52541. * Is movement backwards enabled
  52542. */
  52543. backwardsMovementEnabled: boolean;
  52544. /**
  52545. * Distance to travel when moving backwards
  52546. */
  52547. backwardsTeleportationDistance: number;
  52548. /**
  52549. * The distance from the user to the inspection point in the direction of the controller
  52550. * A higher number will allow the user to move further
  52551. * defaults to 5 (meters, in xr units)
  52552. */
  52553. parabolicCheckRadius: number;
  52554. /**
  52555. * Should the module support parabolic ray on top of direct ray
  52556. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52557. * Very helpful when moving between floors / different heights
  52558. */
  52559. parabolicRayEnabled: boolean;
  52560. /**
  52561. * How much rotation should be applied when rotating right and left
  52562. */
  52563. rotationAngle: number;
  52564. /**
  52565. * Is rotation enabled when moving forward?
  52566. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52567. */
  52568. rotationEnabled: boolean;
  52569. /**
  52570. * constructs a new anchor system
  52571. * @param _xrSessionManager an instance of WebXRSessionManager
  52572. * @param _options configuration object for this feature
  52573. */
  52574. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52575. /**
  52576. * Get the snapPointsOnly flag
  52577. */
  52578. get snapPointsOnly(): boolean;
  52579. /**
  52580. * Sets the snapPointsOnly flag
  52581. * @param snapToPoints should teleportation be exclusively to snap points
  52582. */
  52583. set snapPointsOnly(snapToPoints: boolean);
  52584. /**
  52585. * Add a new mesh to the floor meshes array
  52586. * @param mesh the mesh to use as floor mesh
  52587. */
  52588. addFloorMesh(mesh: AbstractMesh): void;
  52589. /**
  52590. * Add a new snap-to point to fix teleportation to this position
  52591. * @param newSnapPoint The new Snap-To point
  52592. */
  52593. addSnapPoint(newSnapPoint: Vector3): void;
  52594. attach(): boolean;
  52595. detach(): boolean;
  52596. dispose(): void;
  52597. /**
  52598. * Remove a mesh from the floor meshes array
  52599. * @param mesh the mesh to remove
  52600. */
  52601. removeFloorMesh(mesh: AbstractMesh): void;
  52602. /**
  52603. * Remove a mesh from the floor meshes array using its name
  52604. * @param name the mesh name to remove
  52605. */
  52606. removeFloorMeshByName(name: string): void;
  52607. /**
  52608. * 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
  52609. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52610. * @returns was the point found and removed or not
  52611. */
  52612. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52613. /**
  52614. * This function sets a selection feature that will be disabled when
  52615. * the forward ray is shown and will be reattached when hidden.
  52616. * This is used to remove the selection rays when moving.
  52617. * @param selectionFeature the feature to disable when forward movement is enabled
  52618. */
  52619. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52620. protected _onXRFrame(_xrFrame: XRFrame): void;
  52621. private _attachController;
  52622. private _createDefaultTargetMesh;
  52623. private _detachController;
  52624. private _findClosestSnapPointWithRadius;
  52625. private _setTargetMeshPosition;
  52626. private _setTargetMeshVisibility;
  52627. private _showParabolicPath;
  52628. private _teleportForward;
  52629. }
  52630. }
  52631. declare module BABYLON {
  52632. /**
  52633. * Options for the default xr helper
  52634. */
  52635. export class WebXRDefaultExperienceOptions {
  52636. /**
  52637. * Enable or disable default UI to enter XR
  52638. */
  52639. disableDefaultUI?: boolean;
  52640. /**
  52641. * Should teleportation not initialize. defaults to false.
  52642. */
  52643. disableTeleportation?: boolean;
  52644. /**
  52645. * Floor meshes that will be used for teleport
  52646. */
  52647. floorMeshes?: Array<AbstractMesh>;
  52648. /**
  52649. * If set to true, the first frame will not be used to reset position
  52650. * The first frame is mainly used when copying transformation from the old camera
  52651. * Mainly used in AR
  52652. */
  52653. ignoreNativeCameraTransformation?: boolean;
  52654. /**
  52655. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52656. */
  52657. inputOptions?: IWebXRInputOptions;
  52658. /**
  52659. * optional configuration for the output canvas
  52660. */
  52661. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52662. /**
  52663. * optional UI options. This can be used among other to change session mode and reference space type
  52664. */
  52665. uiOptions?: WebXREnterExitUIOptions;
  52666. /**
  52667. * When loading teleportation and pointer select, use stable versions instead of latest.
  52668. */
  52669. useStablePlugins?: boolean;
  52670. /**
  52671. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52672. */
  52673. renderingGroupId?: number;
  52674. /**
  52675. * A list of optional features to init the session with
  52676. * If set to true, all features we support will be added
  52677. */
  52678. optionalFeatures?: boolean | string[];
  52679. }
  52680. /**
  52681. * Default experience which provides a similar setup to the previous webVRExperience
  52682. */
  52683. export class WebXRDefaultExperience {
  52684. /**
  52685. * Base experience
  52686. */
  52687. baseExperience: WebXRExperienceHelper;
  52688. /**
  52689. * Enables ui for entering/exiting xr
  52690. */
  52691. enterExitUI: WebXREnterExitUI;
  52692. /**
  52693. * Input experience extension
  52694. */
  52695. input: WebXRInput;
  52696. /**
  52697. * Enables laser pointer and selection
  52698. */
  52699. pointerSelection: WebXRControllerPointerSelection;
  52700. /**
  52701. * Default target xr should render to
  52702. */
  52703. renderTarget: WebXRRenderTarget;
  52704. /**
  52705. * Enables teleportation
  52706. */
  52707. teleportation: WebXRMotionControllerTeleportation;
  52708. private constructor();
  52709. /**
  52710. * Creates the default xr experience
  52711. * @param scene scene
  52712. * @param options options for basic configuration
  52713. * @returns resulting WebXRDefaultExperience
  52714. */
  52715. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52716. /**
  52717. * DIsposes of the experience helper
  52718. */
  52719. dispose(): void;
  52720. }
  52721. }
  52722. declare module BABYLON {
  52723. /**
  52724. * Options to modify the vr teleportation behavior.
  52725. */
  52726. export interface VRTeleportationOptions {
  52727. /**
  52728. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52729. */
  52730. floorMeshName?: string;
  52731. /**
  52732. * A list of meshes to be used as the teleportation floor. (default: empty)
  52733. */
  52734. floorMeshes?: Mesh[];
  52735. /**
  52736. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52737. */
  52738. teleportationMode?: number;
  52739. /**
  52740. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52741. */
  52742. teleportationTime?: number;
  52743. /**
  52744. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52745. */
  52746. teleportationSpeed?: number;
  52747. /**
  52748. * The easing function used in the animation or null for Linear. (default CircleEase)
  52749. */
  52750. easingFunction?: EasingFunction;
  52751. }
  52752. /**
  52753. * Options to modify the vr experience helper's behavior.
  52754. */
  52755. export interface VRExperienceHelperOptions extends WebVROptions {
  52756. /**
  52757. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52758. */
  52759. createDeviceOrientationCamera?: boolean;
  52760. /**
  52761. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52762. */
  52763. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52764. /**
  52765. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52766. */
  52767. laserToggle?: boolean;
  52768. /**
  52769. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52770. */
  52771. floorMeshes?: Mesh[];
  52772. /**
  52773. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52774. */
  52775. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52776. /**
  52777. * Defines if WebXR should be used instead of WebVR (if available)
  52778. */
  52779. useXR?: boolean;
  52780. }
  52781. /**
  52782. * Event containing information after VR has been entered
  52783. */
  52784. export class OnAfterEnteringVRObservableEvent {
  52785. /**
  52786. * If entering vr was successful
  52787. */
  52788. success: boolean;
  52789. }
  52790. /**
  52791. * Helps to quickly add VR support to an existing scene.
  52792. * See https://doc.babylonjs.com/how_to/webvr_helper
  52793. */
  52794. export class VRExperienceHelper {
  52795. /** Options to modify the vr experience helper's behavior. */
  52796. webVROptions: VRExperienceHelperOptions;
  52797. private _scene;
  52798. private _position;
  52799. private _btnVR;
  52800. private _btnVRDisplayed;
  52801. private _webVRsupported;
  52802. private _webVRready;
  52803. private _webVRrequesting;
  52804. private _webVRpresenting;
  52805. private _hasEnteredVR;
  52806. private _fullscreenVRpresenting;
  52807. private _inputElement;
  52808. private _webVRCamera;
  52809. private _vrDeviceOrientationCamera;
  52810. private _deviceOrientationCamera;
  52811. private _existingCamera;
  52812. private _onKeyDown;
  52813. private _onVrDisplayPresentChange;
  52814. private _onVRDisplayChanged;
  52815. private _onVRRequestPresentStart;
  52816. private _onVRRequestPresentComplete;
  52817. /**
  52818. * 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)
  52819. */
  52820. enableGazeEvenWhenNoPointerLock: boolean;
  52821. /**
  52822. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52823. */
  52824. exitVROnDoubleTap: boolean;
  52825. /**
  52826. * Observable raised right before entering VR.
  52827. */
  52828. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52829. /**
  52830. * Observable raised when entering VR has completed.
  52831. */
  52832. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52833. /**
  52834. * Observable raised when exiting VR.
  52835. */
  52836. onExitingVRObservable: Observable<VRExperienceHelper>;
  52837. /**
  52838. * Observable raised when controller mesh is loaded.
  52839. */
  52840. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52841. /** Return this.onEnteringVRObservable
  52842. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52843. */
  52844. get onEnteringVR(): Observable<VRExperienceHelper>;
  52845. /** Return this.onExitingVRObservable
  52846. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52847. */
  52848. get onExitingVR(): Observable<VRExperienceHelper>;
  52849. /** Return this.onControllerMeshLoadedObservable
  52850. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52851. */
  52852. get onControllerMeshLoaded(): Observable<WebVRController>;
  52853. private _rayLength;
  52854. private _useCustomVRButton;
  52855. private _teleportationRequested;
  52856. private _teleportActive;
  52857. private _floorMeshName;
  52858. private _floorMeshesCollection;
  52859. private _teleportationMode;
  52860. private _teleportationTime;
  52861. private _teleportationSpeed;
  52862. private _teleportationEasing;
  52863. private _rotationAllowed;
  52864. private _teleportBackwardsVector;
  52865. private _teleportationTarget;
  52866. private _isDefaultTeleportationTarget;
  52867. private _postProcessMove;
  52868. private _teleportationFillColor;
  52869. private _teleportationBorderColor;
  52870. private _rotationAngle;
  52871. private _haloCenter;
  52872. private _cameraGazer;
  52873. private _padSensibilityUp;
  52874. private _padSensibilityDown;
  52875. private _leftController;
  52876. private _rightController;
  52877. private _gazeColor;
  52878. private _laserColor;
  52879. private _pickedLaserColor;
  52880. private _pickedGazeColor;
  52881. /**
  52882. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52883. */
  52884. onNewMeshSelected: Observable<AbstractMesh>;
  52885. /**
  52886. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52887. * This observable will provide the mesh and the controller used to select the mesh
  52888. */
  52889. onMeshSelectedWithController: Observable<{
  52890. mesh: AbstractMesh;
  52891. controller: WebVRController;
  52892. }>;
  52893. /**
  52894. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52895. */
  52896. onNewMeshPicked: Observable<PickingInfo>;
  52897. private _circleEase;
  52898. /**
  52899. * Observable raised before camera teleportation
  52900. */
  52901. onBeforeCameraTeleport: Observable<Vector3>;
  52902. /**
  52903. * Observable raised after camera teleportation
  52904. */
  52905. onAfterCameraTeleport: Observable<Vector3>;
  52906. /**
  52907. * Observable raised when current selected mesh gets unselected
  52908. */
  52909. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52910. private _raySelectionPredicate;
  52911. /**
  52912. * To be optionaly changed by user to define custom ray selection
  52913. */
  52914. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52915. /**
  52916. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52917. */
  52918. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52919. /**
  52920. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52921. */
  52922. teleportationEnabled: boolean;
  52923. private _defaultHeight;
  52924. private _teleportationInitialized;
  52925. private _interactionsEnabled;
  52926. private _interactionsRequested;
  52927. private _displayGaze;
  52928. private _displayLaserPointer;
  52929. /**
  52930. * The mesh used to display where the user is going to teleport.
  52931. */
  52932. get teleportationTarget(): Mesh;
  52933. /**
  52934. * Sets the mesh to be used to display where the user is going to teleport.
  52935. */
  52936. set teleportationTarget(value: Mesh);
  52937. /**
  52938. * 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
  52939. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52940. * See https://doc.babylonjs.com/resources/baking_transformations
  52941. */
  52942. get gazeTrackerMesh(): Mesh;
  52943. set gazeTrackerMesh(value: Mesh);
  52944. /**
  52945. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52946. */
  52947. updateGazeTrackerScale: boolean;
  52948. /**
  52949. * If the gaze trackers color should be updated when selecting meshes
  52950. */
  52951. updateGazeTrackerColor: boolean;
  52952. /**
  52953. * If the controller laser color should be updated when selecting meshes
  52954. */
  52955. updateControllerLaserColor: boolean;
  52956. /**
  52957. * The gaze tracking mesh corresponding to the left controller
  52958. */
  52959. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52960. /**
  52961. * The gaze tracking mesh corresponding to the right controller
  52962. */
  52963. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52964. /**
  52965. * If the ray of the gaze should be displayed.
  52966. */
  52967. get displayGaze(): boolean;
  52968. /**
  52969. * Sets if the ray of the gaze should be displayed.
  52970. */
  52971. set displayGaze(value: boolean);
  52972. /**
  52973. * If the ray of the LaserPointer should be displayed.
  52974. */
  52975. get displayLaserPointer(): boolean;
  52976. /**
  52977. * Sets if the ray of the LaserPointer should be displayed.
  52978. */
  52979. set displayLaserPointer(value: boolean);
  52980. /**
  52981. * The deviceOrientationCamera used as the camera when not in VR.
  52982. */
  52983. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52984. /**
  52985. * Based on the current WebVR support, returns the current VR camera used.
  52986. */
  52987. get currentVRCamera(): Nullable<Camera>;
  52988. /**
  52989. * The webVRCamera which is used when in VR.
  52990. */
  52991. get webVRCamera(): WebVRFreeCamera;
  52992. /**
  52993. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52994. */
  52995. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52996. /**
  52997. * The html button that is used to trigger entering into VR.
  52998. */
  52999. get vrButton(): Nullable<HTMLButtonElement>;
  53000. private get _teleportationRequestInitiated();
  53001. /**
  53002. * Defines whether or not Pointer lock should be requested when switching to
  53003. * full screen.
  53004. */
  53005. requestPointerLockOnFullScreen: boolean;
  53006. /**
  53007. * If asking to force XR, this will be populated with the default xr experience
  53008. */
  53009. xr: WebXRDefaultExperience;
  53010. /**
  53011. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53012. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53013. */
  53014. xrTestDone: boolean;
  53015. /**
  53016. * Instantiates a VRExperienceHelper.
  53017. * Helps to quickly add VR support to an existing scene.
  53018. * @param scene The scene the VRExperienceHelper belongs to.
  53019. * @param webVROptions Options to modify the vr experience helper's behavior.
  53020. */
  53021. constructor(scene: Scene,
  53022. /** Options to modify the vr experience helper's behavior. */
  53023. webVROptions?: VRExperienceHelperOptions);
  53024. private completeVRInit;
  53025. private _onDefaultMeshLoaded;
  53026. private _onResize;
  53027. private _onFullscreenChange;
  53028. /**
  53029. * Gets a value indicating if we are currently in VR mode.
  53030. */
  53031. get isInVRMode(): boolean;
  53032. private onVrDisplayPresentChange;
  53033. private onVRDisplayChanged;
  53034. private moveButtonToBottomRight;
  53035. private displayVRButton;
  53036. private updateButtonVisibility;
  53037. private _cachedAngularSensibility;
  53038. /**
  53039. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53040. * Otherwise, will use the fullscreen API.
  53041. */
  53042. enterVR(): void;
  53043. /**
  53044. * Attempt to exit VR, or fullscreen.
  53045. */
  53046. exitVR(): void;
  53047. /**
  53048. * The position of the vr experience helper.
  53049. */
  53050. get position(): Vector3;
  53051. /**
  53052. * Sets the position of the vr experience helper.
  53053. */
  53054. set position(value: Vector3);
  53055. /**
  53056. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53057. */
  53058. enableInteractions(): void;
  53059. private get _noControllerIsActive();
  53060. private beforeRender;
  53061. private _isTeleportationFloor;
  53062. /**
  53063. * Adds a floor mesh to be used for teleportation.
  53064. * @param floorMesh the mesh to be used for teleportation.
  53065. */
  53066. addFloorMesh(floorMesh: Mesh): void;
  53067. /**
  53068. * Removes a floor mesh from being used for teleportation.
  53069. * @param floorMesh the mesh to be removed.
  53070. */
  53071. removeFloorMesh(floorMesh: Mesh): void;
  53072. /**
  53073. * Enables interactions and teleportation using the VR controllers and gaze.
  53074. * @param vrTeleportationOptions options to modify teleportation behavior.
  53075. */
  53076. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53077. private _onNewGamepadConnected;
  53078. private _tryEnableInteractionOnController;
  53079. private _onNewGamepadDisconnected;
  53080. private _enableInteractionOnController;
  53081. private _checkTeleportWithRay;
  53082. private _checkRotate;
  53083. private _checkTeleportBackwards;
  53084. private _enableTeleportationOnController;
  53085. private _createTeleportationCircles;
  53086. private _displayTeleportationTarget;
  53087. private _hideTeleportationTarget;
  53088. private _rotateCamera;
  53089. private _moveTeleportationSelectorTo;
  53090. private _workingVector;
  53091. private _workingQuaternion;
  53092. private _workingMatrix;
  53093. /**
  53094. * Time Constant Teleportation Mode
  53095. */
  53096. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53097. /**
  53098. * Speed Constant Teleportation Mode
  53099. */
  53100. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53101. /**
  53102. * Teleports the users feet to the desired location
  53103. * @param location The location where the user's feet should be placed
  53104. */
  53105. teleportCamera(location: Vector3): void;
  53106. private _convertNormalToDirectionOfRay;
  53107. private _castRayAndSelectObject;
  53108. private _notifySelectedMeshUnselected;
  53109. /**
  53110. * Permanently set new colors for the laser pointer
  53111. * @param color the new laser color
  53112. * @param pickedColor the new laser color when picked mesh detected
  53113. */
  53114. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53115. /**
  53116. * Set lighting enabled / disabled on the laser pointer of both controllers
  53117. * @param enabled should the lighting be enabled on the laser pointer
  53118. */
  53119. setLaserLightingState(enabled?: boolean): void;
  53120. /**
  53121. * Permanently set new colors for the gaze pointer
  53122. * @param color the new gaze color
  53123. * @param pickedColor the new gaze color when picked mesh detected
  53124. */
  53125. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53126. /**
  53127. * Sets the color of the laser ray from the vr controllers.
  53128. * @param color new color for the ray.
  53129. */
  53130. changeLaserColor(color: Color3): void;
  53131. /**
  53132. * Sets the color of the ray from the vr headsets gaze.
  53133. * @param color new color for the ray.
  53134. */
  53135. changeGazeColor(color: Color3): void;
  53136. /**
  53137. * Exits VR and disposes of the vr experience helper
  53138. */
  53139. dispose(): void;
  53140. /**
  53141. * Gets the name of the VRExperienceHelper class
  53142. * @returns "VRExperienceHelper"
  53143. */
  53144. getClassName(): string;
  53145. }
  53146. }
  53147. declare module BABYLON {
  53148. /**
  53149. * Contains an array of blocks representing the octree
  53150. */
  53151. export interface IOctreeContainer<T> {
  53152. /**
  53153. * Blocks within the octree
  53154. */
  53155. blocks: Array<OctreeBlock<T>>;
  53156. }
  53157. /**
  53158. * Class used to store a cell in an octree
  53159. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53160. */
  53161. export class OctreeBlock<T> {
  53162. /**
  53163. * Gets the content of the current block
  53164. */
  53165. entries: T[];
  53166. /**
  53167. * Gets the list of block children
  53168. */
  53169. blocks: Array<OctreeBlock<T>>;
  53170. private _depth;
  53171. private _maxDepth;
  53172. private _capacity;
  53173. private _minPoint;
  53174. private _maxPoint;
  53175. private _boundingVectors;
  53176. private _creationFunc;
  53177. /**
  53178. * Creates a new block
  53179. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53180. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53181. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53182. * @param depth defines the current depth of this block in the octree
  53183. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53184. * @param creationFunc defines a callback to call when an element is added to the block
  53185. */
  53186. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53187. /**
  53188. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53189. */
  53190. get capacity(): number;
  53191. /**
  53192. * Gets the minimum vector (in world space) of the block's bounding box
  53193. */
  53194. get minPoint(): Vector3;
  53195. /**
  53196. * Gets the maximum vector (in world space) of the block's bounding box
  53197. */
  53198. get maxPoint(): Vector3;
  53199. /**
  53200. * Add a new element to this block
  53201. * @param entry defines the element to add
  53202. */
  53203. addEntry(entry: T): void;
  53204. /**
  53205. * Remove an element from this block
  53206. * @param entry defines the element to remove
  53207. */
  53208. removeEntry(entry: T): void;
  53209. /**
  53210. * Add an array of elements to this block
  53211. * @param entries defines the array of elements to add
  53212. */
  53213. addEntries(entries: T[]): void;
  53214. /**
  53215. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53216. * @param frustumPlanes defines the frustum planes to test
  53217. * @param selection defines the array to store current content if selection is positive
  53218. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53219. */
  53220. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53221. /**
  53222. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53223. * @param sphereCenter defines the bounding sphere center
  53224. * @param sphereRadius defines the bounding sphere radius
  53225. * @param selection defines the array to store current content if selection is positive
  53226. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53227. */
  53228. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53229. /**
  53230. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53231. * @param ray defines the ray to test with
  53232. * @param selection defines the array to store current content if selection is positive
  53233. */
  53234. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53235. /**
  53236. * Subdivide the content into child blocks (this block will then be empty)
  53237. */
  53238. createInnerBlocks(): void;
  53239. /**
  53240. * @hidden
  53241. */
  53242. 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;
  53243. }
  53244. }
  53245. declare module BABYLON {
  53246. /**
  53247. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53249. */
  53250. export class Octree<T> {
  53251. /** 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.) */
  53252. maxDepth: number;
  53253. /**
  53254. * Blocks within the octree containing objects
  53255. */
  53256. blocks: Array<OctreeBlock<T>>;
  53257. /**
  53258. * Content stored in the octree
  53259. */
  53260. dynamicContent: T[];
  53261. private _maxBlockCapacity;
  53262. private _selectionContent;
  53263. private _creationFunc;
  53264. /**
  53265. * Creates a octree
  53266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53267. * @param creationFunc function to be used to instatiate the octree
  53268. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53269. * @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.)
  53270. */
  53271. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53272. /** 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.) */
  53273. maxDepth?: number);
  53274. /**
  53275. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53276. * @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);
  53277. * @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);
  53278. * @param entries meshes to be added to the octree blocks
  53279. */
  53280. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53281. /**
  53282. * Adds a mesh to the octree
  53283. * @param entry Mesh to add to the octree
  53284. */
  53285. addMesh(entry: T): void;
  53286. /**
  53287. * Remove an element from the octree
  53288. * @param entry defines the element to remove
  53289. */
  53290. removeMesh(entry: T): void;
  53291. /**
  53292. * Selects an array of meshes within the frustum
  53293. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53294. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53295. * @returns array of meshes within the frustum
  53296. */
  53297. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53298. /**
  53299. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53300. * @param sphereCenter defines the bounding sphere center
  53301. * @param sphereRadius defines the bounding sphere radius
  53302. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53303. * @returns an array of objects that intersect the sphere
  53304. */
  53305. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53306. /**
  53307. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53308. * @param ray defines the ray to test with
  53309. * @returns array of intersected objects
  53310. */
  53311. intersectsRay(ray: Ray): SmartArray<T>;
  53312. /**
  53313. * Adds a mesh into the octree block if it intersects the block
  53314. */
  53315. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53316. /**
  53317. * Adds a submesh into the octree block if it intersects the block
  53318. */
  53319. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53320. }
  53321. }
  53322. declare module BABYLON {
  53323. interface Scene {
  53324. /**
  53325. * @hidden
  53326. * Backing Filed
  53327. */
  53328. _selectionOctree: Octree<AbstractMesh>;
  53329. /**
  53330. * Gets the octree used to boost mesh selection (picking)
  53331. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53332. */
  53333. selectionOctree: Octree<AbstractMesh>;
  53334. /**
  53335. * Creates or updates the octree used to boost selection (picking)
  53336. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53337. * @param maxCapacity defines the maximum capacity per leaf
  53338. * @param maxDepth defines the maximum depth of the octree
  53339. * @returns an octree of AbstractMesh
  53340. */
  53341. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53342. }
  53343. interface AbstractMesh {
  53344. /**
  53345. * @hidden
  53346. * Backing Field
  53347. */
  53348. _submeshesOctree: Octree<SubMesh>;
  53349. /**
  53350. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53351. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53352. * @param maxCapacity defines the maximum size of each block (64 by default)
  53353. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53354. * @returns the new octree
  53355. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53357. */
  53358. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53359. }
  53360. /**
  53361. * Defines the octree scene component responsible to manage any octrees
  53362. * in a given scene.
  53363. */
  53364. export class OctreeSceneComponent {
  53365. /**
  53366. * The component name help to identify the component in the list of scene components.
  53367. */
  53368. readonly name: string;
  53369. /**
  53370. * The scene the component belongs to.
  53371. */
  53372. scene: Scene;
  53373. /**
  53374. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53375. */
  53376. readonly checksIsEnabled: boolean;
  53377. /**
  53378. * Creates a new instance of the component for the given scene
  53379. * @param scene Defines the scene to register the component in
  53380. */
  53381. constructor(scene: Scene);
  53382. /**
  53383. * Registers the component in a given scene
  53384. */
  53385. register(): void;
  53386. /**
  53387. * Return the list of active meshes
  53388. * @returns the list of active meshes
  53389. */
  53390. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53391. /**
  53392. * Return the list of active sub meshes
  53393. * @param mesh The mesh to get the candidates sub meshes from
  53394. * @returns the list of active sub meshes
  53395. */
  53396. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53397. private _tempRay;
  53398. /**
  53399. * Return the list of sub meshes intersecting with a given local ray
  53400. * @param mesh defines the mesh to find the submesh for
  53401. * @param localRay defines the ray in local space
  53402. * @returns the list of intersecting sub meshes
  53403. */
  53404. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53405. /**
  53406. * Return the list of sub meshes colliding with a collider
  53407. * @param mesh defines the mesh to find the submesh for
  53408. * @param collider defines the collider to evaluate the collision against
  53409. * @returns the list of colliding sub meshes
  53410. */
  53411. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53412. /**
  53413. * Rebuilds the elements related to this component in case of
  53414. * context lost for instance.
  53415. */
  53416. rebuild(): void;
  53417. /**
  53418. * Disposes the component and the associated ressources.
  53419. */
  53420. dispose(): void;
  53421. }
  53422. }
  53423. declare module BABYLON {
  53424. /**
  53425. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53426. */
  53427. export class Gizmo implements IDisposable {
  53428. /** The utility layer the gizmo will be added to */
  53429. gizmoLayer: UtilityLayerRenderer;
  53430. /**
  53431. * The root mesh of the gizmo
  53432. */
  53433. _rootMesh: Mesh;
  53434. private _attachedMesh;
  53435. private _attachedNode;
  53436. /**
  53437. * Ratio for the scale of the gizmo (Default: 1)
  53438. */
  53439. protected _scaleRatio: number;
  53440. /**
  53441. * boolean updated by pointermove when a gizmo mesh is hovered
  53442. */
  53443. protected _isHovered: boolean;
  53444. /**
  53445. * Ratio for the scale of the gizmo (Default: 1)
  53446. */
  53447. set scaleRatio(value: number);
  53448. get scaleRatio(): number;
  53449. /**
  53450. * True when the mouse pointer is hovered a gizmo mesh
  53451. */
  53452. get isHovered(): boolean;
  53453. /**
  53454. * If a custom mesh has been set (Default: false)
  53455. */
  53456. protected _customMeshSet: boolean;
  53457. /**
  53458. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53459. * * When set, interactions will be enabled
  53460. */
  53461. get attachedMesh(): Nullable<AbstractMesh>;
  53462. set attachedMesh(value: Nullable<AbstractMesh>);
  53463. /**
  53464. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53465. * * When set, interactions will be enabled
  53466. */
  53467. get attachedNode(): Nullable<Node>;
  53468. set attachedNode(value: Nullable<Node>);
  53469. /**
  53470. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53471. * @param mesh The mesh to replace the default mesh of the gizmo
  53472. */
  53473. setCustomMesh(mesh: Mesh): void;
  53474. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53475. /**
  53476. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53477. */
  53478. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53479. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53480. /**
  53481. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53482. */
  53483. updateGizmoPositionToMatchAttachedMesh: boolean;
  53484. /**
  53485. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53486. */
  53487. updateScale: boolean;
  53488. protected _interactionsEnabled: boolean;
  53489. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53490. private _beforeRenderObserver;
  53491. private _tempQuaternion;
  53492. private _tempVector;
  53493. private _tempVector2;
  53494. private _tempMatrix1;
  53495. private _tempMatrix2;
  53496. private _rightHandtoLeftHandMatrix;
  53497. /**
  53498. * Creates a gizmo
  53499. * @param gizmoLayer The utility layer the gizmo will be added to
  53500. */
  53501. constructor(
  53502. /** The utility layer the gizmo will be added to */
  53503. gizmoLayer?: UtilityLayerRenderer);
  53504. /**
  53505. * Updates the gizmo to match the attached mesh's position/rotation
  53506. */
  53507. protected _update(): void;
  53508. /**
  53509. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53510. * @param value Node, TransformNode or mesh
  53511. */
  53512. protected _matrixChanged(): void;
  53513. /**
  53514. * Disposes of the gizmo
  53515. */
  53516. dispose(): void;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. /**
  53521. * Single plane drag gizmo
  53522. */
  53523. export class PlaneDragGizmo extends Gizmo {
  53524. /**
  53525. * Drag behavior responsible for the gizmos dragging interactions
  53526. */
  53527. dragBehavior: PointerDragBehavior;
  53528. private _pointerObserver;
  53529. /**
  53530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53531. */
  53532. snapDistance: number;
  53533. /**
  53534. * Event that fires each time the gizmo snaps to a new location.
  53535. * * snapDistance is the the change in distance
  53536. */
  53537. onSnapObservable: Observable<{
  53538. snapDistance: number;
  53539. }>;
  53540. private _plane;
  53541. private _coloredMaterial;
  53542. private _hoverMaterial;
  53543. private _isEnabled;
  53544. private _parent;
  53545. /** @hidden */
  53546. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53547. /** @hidden */
  53548. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53549. /**
  53550. * Creates a PlaneDragGizmo
  53551. * @param gizmoLayer The utility layer the gizmo will be added to
  53552. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53553. * @param color The color of the gizmo
  53554. */
  53555. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53556. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53557. /**
  53558. * If the gizmo is enabled
  53559. */
  53560. set isEnabled(value: boolean);
  53561. get isEnabled(): boolean;
  53562. /**
  53563. * Disposes of the gizmo
  53564. */
  53565. dispose(): void;
  53566. }
  53567. }
  53568. declare module BABYLON {
  53569. /**
  53570. * Gizmo that enables dragging a mesh along 3 axis
  53571. */
  53572. export class PositionGizmo extends Gizmo {
  53573. /**
  53574. * Internal gizmo used for interactions on the x axis
  53575. */
  53576. xGizmo: AxisDragGizmo;
  53577. /**
  53578. * Internal gizmo used for interactions on the y axis
  53579. */
  53580. yGizmo: AxisDragGizmo;
  53581. /**
  53582. * Internal gizmo used for interactions on the z axis
  53583. */
  53584. zGizmo: AxisDragGizmo;
  53585. /**
  53586. * Internal gizmo used for interactions on the yz plane
  53587. */
  53588. xPlaneGizmo: PlaneDragGizmo;
  53589. /**
  53590. * Internal gizmo used for interactions on the xz plane
  53591. */
  53592. yPlaneGizmo: PlaneDragGizmo;
  53593. /**
  53594. * Internal gizmo used for interactions on the xy plane
  53595. */
  53596. zPlaneGizmo: PlaneDragGizmo;
  53597. /**
  53598. * private variables
  53599. */
  53600. private _meshAttached;
  53601. private _nodeAttached;
  53602. private _snapDistance;
  53603. /** Fires an event when any of it's sub gizmos are dragged */
  53604. onDragStartObservable: Observable<unknown>;
  53605. /** Fires an event when any of it's sub gizmos are released from dragging */
  53606. onDragEndObservable: Observable<unknown>;
  53607. /**
  53608. * If set to true, planar drag is enabled
  53609. */
  53610. private _planarGizmoEnabled;
  53611. get attachedMesh(): Nullable<AbstractMesh>;
  53612. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53613. get attachedNode(): Nullable<Node>;
  53614. set attachedNode(node: Nullable<Node>);
  53615. /**
  53616. * True when the mouse pointer is hovering a gizmo mesh
  53617. */
  53618. get isHovered(): boolean;
  53619. /**
  53620. * Creates a PositionGizmo
  53621. * @param gizmoLayer The utility layer the gizmo will be added to
  53622. @param thickness display gizmo axis thickness
  53623. */
  53624. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53625. /**
  53626. * If the planar drag gizmo is enabled
  53627. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53628. */
  53629. set planarGizmoEnabled(value: boolean);
  53630. get planarGizmoEnabled(): boolean;
  53631. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53632. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53633. /**
  53634. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53635. */
  53636. set snapDistance(value: number);
  53637. get snapDistance(): number;
  53638. /**
  53639. * Ratio for the scale of the gizmo (Default: 1)
  53640. */
  53641. set scaleRatio(value: number);
  53642. get scaleRatio(): number;
  53643. /**
  53644. * Disposes of the gizmo
  53645. */
  53646. dispose(): void;
  53647. /**
  53648. * CustomMeshes are not supported by this gizmo
  53649. * @param mesh The mesh to replace the default mesh of the gizmo
  53650. */
  53651. setCustomMesh(mesh: Mesh): void;
  53652. }
  53653. }
  53654. declare module BABYLON {
  53655. /**
  53656. * Single axis drag gizmo
  53657. */
  53658. export class AxisDragGizmo extends Gizmo {
  53659. /**
  53660. * Drag behavior responsible for the gizmos dragging interactions
  53661. */
  53662. dragBehavior: PointerDragBehavior;
  53663. private _pointerObserver;
  53664. /**
  53665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53666. */
  53667. snapDistance: number;
  53668. /**
  53669. * Event that fires each time the gizmo snaps to a new location.
  53670. * * snapDistance is the the change in distance
  53671. */
  53672. onSnapObservable: Observable<{
  53673. snapDistance: number;
  53674. }>;
  53675. private _isEnabled;
  53676. private _parent;
  53677. private _arrow;
  53678. private _coloredMaterial;
  53679. private _hoverMaterial;
  53680. /** @hidden */
  53681. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53682. /** @hidden */
  53683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53684. /**
  53685. * Creates an AxisDragGizmo
  53686. * @param gizmoLayer The utility layer the gizmo will be added to
  53687. * @param dragAxis The axis which the gizmo will be able to drag on
  53688. * @param color The color of the gizmo
  53689. * @param thickness display gizmo axis thickness
  53690. */
  53691. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53692. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53693. /**
  53694. * If the gizmo is enabled
  53695. */
  53696. set isEnabled(value: boolean);
  53697. get isEnabled(): boolean;
  53698. /**
  53699. * Disposes of the gizmo
  53700. */
  53701. dispose(): void;
  53702. }
  53703. }
  53704. declare module BABYLON.Debug {
  53705. /**
  53706. * The Axes viewer will show 3 axes in a specific point in space
  53707. */
  53708. export class AxesViewer {
  53709. private _xAxis;
  53710. private _yAxis;
  53711. private _zAxis;
  53712. private _scaleLinesFactor;
  53713. private _instanced;
  53714. /**
  53715. * Gets the hosting scene
  53716. */
  53717. scene: Nullable<Scene>;
  53718. /**
  53719. * Gets or sets a number used to scale line length
  53720. */
  53721. scaleLines: number;
  53722. /** Gets the node hierarchy used to render x-axis */
  53723. get xAxis(): TransformNode;
  53724. /** Gets the node hierarchy used to render y-axis */
  53725. get yAxis(): TransformNode;
  53726. /** Gets the node hierarchy used to render z-axis */
  53727. get zAxis(): TransformNode;
  53728. /**
  53729. * Creates a new AxesViewer
  53730. * @param scene defines the hosting scene
  53731. * @param scaleLines defines a number used to scale line length (1 by default)
  53732. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53733. * @param xAxis defines the node hierarchy used to render the x-axis
  53734. * @param yAxis defines the node hierarchy used to render the y-axis
  53735. * @param zAxis defines the node hierarchy used to render the z-axis
  53736. */
  53737. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53738. /**
  53739. * Force the viewer to update
  53740. * @param position defines the position of the viewer
  53741. * @param xaxis defines the x axis of the viewer
  53742. * @param yaxis defines the y axis of the viewer
  53743. * @param zaxis defines the z axis of the viewer
  53744. */
  53745. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53746. /**
  53747. * Creates an instance of this axes viewer.
  53748. * @returns a new axes viewer with instanced meshes
  53749. */
  53750. createInstance(): AxesViewer;
  53751. /** Releases resources */
  53752. dispose(): void;
  53753. private static _SetRenderingGroupId;
  53754. }
  53755. }
  53756. declare module BABYLON.Debug {
  53757. /**
  53758. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53759. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53760. */
  53761. export class BoneAxesViewer extends AxesViewer {
  53762. /**
  53763. * Gets or sets the target mesh where to display the axes viewer
  53764. */
  53765. mesh: Nullable<Mesh>;
  53766. /**
  53767. * Gets or sets the target bone where to display the axes viewer
  53768. */
  53769. bone: Nullable<Bone>;
  53770. /** Gets current position */
  53771. pos: Vector3;
  53772. /** Gets direction of X axis */
  53773. xaxis: Vector3;
  53774. /** Gets direction of Y axis */
  53775. yaxis: Vector3;
  53776. /** Gets direction of Z axis */
  53777. zaxis: Vector3;
  53778. /**
  53779. * Creates a new BoneAxesViewer
  53780. * @param scene defines the hosting scene
  53781. * @param bone defines the target bone
  53782. * @param mesh defines the target mesh
  53783. * @param scaleLines defines a scaling factor for line length (1 by default)
  53784. */
  53785. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53786. /**
  53787. * Force the viewer to update
  53788. */
  53789. update(): void;
  53790. /** Releases resources */
  53791. dispose(): void;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Interface used to define scene explorer extensibility option
  53797. */
  53798. export interface IExplorerExtensibilityOption {
  53799. /**
  53800. * Define the option label
  53801. */
  53802. label: string;
  53803. /**
  53804. * Defines the action to execute on click
  53805. */
  53806. action: (entity: any) => void;
  53807. }
  53808. /**
  53809. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53810. */
  53811. export interface IExplorerExtensibilityGroup {
  53812. /**
  53813. * Defines a predicate to test if a given type mut be extended
  53814. */
  53815. predicate: (entity: any) => boolean;
  53816. /**
  53817. * Gets the list of options added to a type
  53818. */
  53819. entries: IExplorerExtensibilityOption[];
  53820. }
  53821. /**
  53822. * Interface used to define the options to use to create the Inspector
  53823. */
  53824. export interface IInspectorOptions {
  53825. /**
  53826. * Display in overlay mode (default: false)
  53827. */
  53828. overlay?: boolean;
  53829. /**
  53830. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53831. */
  53832. globalRoot?: HTMLElement;
  53833. /**
  53834. * Display the Scene explorer
  53835. */
  53836. showExplorer?: boolean;
  53837. /**
  53838. * Display the property inspector
  53839. */
  53840. showInspector?: boolean;
  53841. /**
  53842. * Display in embed mode (both panes on the right)
  53843. */
  53844. embedMode?: boolean;
  53845. /**
  53846. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53847. */
  53848. handleResize?: boolean;
  53849. /**
  53850. * Allow the panes to popup (default: true)
  53851. */
  53852. enablePopup?: boolean;
  53853. /**
  53854. * Allow the panes to be closed by users (default: true)
  53855. */
  53856. enableClose?: boolean;
  53857. /**
  53858. * Optional list of extensibility entries
  53859. */
  53860. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53861. /**
  53862. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53863. */
  53864. inspectorURL?: string;
  53865. /**
  53866. * Optional initial tab (default to DebugLayerTab.Properties)
  53867. */
  53868. initialTab?: DebugLayerTab;
  53869. }
  53870. interface Scene {
  53871. /**
  53872. * @hidden
  53873. * Backing field
  53874. */
  53875. _debugLayer: DebugLayer;
  53876. /**
  53877. * Gets the debug layer (aka Inspector) associated with the scene
  53878. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53879. */
  53880. debugLayer: DebugLayer;
  53881. }
  53882. /**
  53883. * Enum of inspector action tab
  53884. */
  53885. export enum DebugLayerTab {
  53886. /**
  53887. * Properties tag (default)
  53888. */
  53889. Properties = 0,
  53890. /**
  53891. * Debug tab
  53892. */
  53893. Debug = 1,
  53894. /**
  53895. * Statistics tab
  53896. */
  53897. Statistics = 2,
  53898. /**
  53899. * Tools tab
  53900. */
  53901. Tools = 3,
  53902. /**
  53903. * Settings tab
  53904. */
  53905. Settings = 4
  53906. }
  53907. /**
  53908. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53909. * what is happening in your scene
  53910. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53911. */
  53912. export class DebugLayer {
  53913. /**
  53914. * Define the url to get the inspector script from.
  53915. * By default it uses the babylonjs CDN.
  53916. * @ignoreNaming
  53917. */
  53918. static InspectorURL: string;
  53919. private _scene;
  53920. private BJSINSPECTOR;
  53921. private _onPropertyChangedObservable?;
  53922. /**
  53923. * Observable triggered when a property is changed through the inspector.
  53924. */
  53925. get onPropertyChangedObservable(): any;
  53926. /**
  53927. * Instantiates a new debug layer.
  53928. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53929. * what is happening in your scene
  53930. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53931. * @param scene Defines the scene to inspect
  53932. */
  53933. constructor(scene: Scene);
  53934. /** Creates the inspector window. */
  53935. private _createInspector;
  53936. /**
  53937. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53938. * @param entity defines the entity to select
  53939. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53940. */
  53941. select(entity: any, lineContainerTitles?: string | string[]): void;
  53942. /** Get the inspector from bundle or global */
  53943. private _getGlobalInspector;
  53944. /**
  53945. * Get if the inspector is visible or not.
  53946. * @returns true if visible otherwise, false
  53947. */
  53948. isVisible(): boolean;
  53949. /**
  53950. * Hide the inspector and close its window.
  53951. */
  53952. hide(): void;
  53953. /**
  53954. * Update the scene in the inspector
  53955. */
  53956. setAsActiveScene(): void;
  53957. /**
  53958. * Launch the debugLayer.
  53959. * @param config Define the configuration of the inspector
  53960. * @return a promise fulfilled when the debug layer is visible
  53961. */
  53962. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53963. }
  53964. }
  53965. declare module BABYLON {
  53966. /**
  53967. * Class containing static functions to help procedurally build meshes
  53968. */
  53969. export class BoxBuilder {
  53970. /**
  53971. * Creates a box mesh
  53972. * * The parameter `size` sets the size (float) of each box side (default 1)
  53973. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53974. * * 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)
  53975. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53977. * * 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
  53978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53979. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53980. * @param name defines the name of the mesh
  53981. * @param options defines the options used to create the mesh
  53982. * @param scene defines the hosting scene
  53983. * @returns the box mesh
  53984. */
  53985. static CreateBox(name: string, options: {
  53986. size?: number;
  53987. width?: number;
  53988. height?: number;
  53989. depth?: number;
  53990. faceUV?: Vector4[];
  53991. faceColors?: Color4[];
  53992. sideOrientation?: number;
  53993. frontUVs?: Vector4;
  53994. backUVs?: Vector4;
  53995. wrap?: boolean;
  53996. topBaseAt?: number;
  53997. bottomBaseAt?: number;
  53998. updatable?: boolean;
  53999. }, scene?: Nullable<Scene>): Mesh;
  54000. }
  54001. }
  54002. declare module BABYLON.Debug {
  54003. /**
  54004. * Used to show the physics impostor around the specific mesh
  54005. */
  54006. export class PhysicsViewer {
  54007. /** @hidden */
  54008. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54009. /** @hidden */
  54010. protected _meshes: Array<Nullable<AbstractMesh>>;
  54011. /** @hidden */
  54012. protected _scene: Nullable<Scene>;
  54013. /** @hidden */
  54014. protected _numMeshes: number;
  54015. /** @hidden */
  54016. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54017. private _renderFunction;
  54018. private _utilityLayer;
  54019. private _debugBoxMesh;
  54020. private _debugSphereMesh;
  54021. private _debugCylinderMesh;
  54022. private _debugMaterial;
  54023. private _debugMeshMeshes;
  54024. /**
  54025. * Creates a new PhysicsViewer
  54026. * @param scene defines the hosting scene
  54027. */
  54028. constructor(scene: Scene);
  54029. /** @hidden */
  54030. protected _updateDebugMeshes(): void;
  54031. /**
  54032. * Renders a specified physic impostor
  54033. * @param impostor defines the impostor to render
  54034. * @param targetMesh defines the mesh represented by the impostor
  54035. * @returns the new debug mesh used to render the impostor
  54036. */
  54037. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54038. /**
  54039. * Hides a specified physic impostor
  54040. * @param impostor defines the impostor to hide
  54041. */
  54042. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54043. private _getDebugMaterial;
  54044. private _getDebugBoxMesh;
  54045. private _getDebugSphereMesh;
  54046. private _getDebugCylinderMesh;
  54047. private _getDebugMeshMesh;
  54048. private _getDebugMesh;
  54049. /** Releases all resources */
  54050. dispose(): void;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. /**
  54055. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54056. * in order to better appreciate the issue one might have.
  54057. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54058. */
  54059. export class RayHelper {
  54060. /**
  54061. * Defines the ray we are currently tryin to visualize.
  54062. */
  54063. ray: Nullable<Ray>;
  54064. private _renderPoints;
  54065. private _renderLine;
  54066. private _renderFunction;
  54067. private _scene;
  54068. private _onAfterRenderObserver;
  54069. private _onAfterStepObserver;
  54070. private _attachedToMesh;
  54071. private _meshSpaceDirection;
  54072. private _meshSpaceOrigin;
  54073. /**
  54074. * Helper function to create a colored helper in a scene in one line.
  54075. * @param ray Defines the ray we are currently tryin to visualize
  54076. * @param scene Defines the scene the ray is used in
  54077. * @param color Defines the color we want to see the ray in
  54078. * @returns The newly created ray helper.
  54079. */
  54080. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54081. /**
  54082. * Instantiate a new ray helper.
  54083. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54084. * in order to better appreciate the issue one might have.
  54085. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54086. * @param ray Defines the ray we are currently tryin to visualize
  54087. */
  54088. constructor(ray: Ray);
  54089. /**
  54090. * Shows the ray we are willing to debug.
  54091. * @param scene Defines the scene the ray needs to be rendered in
  54092. * @param color Defines the color the ray needs to be rendered in
  54093. */
  54094. show(scene: Scene, color?: Color3): void;
  54095. /**
  54096. * Hides the ray we are debugging.
  54097. */
  54098. hide(): void;
  54099. private _render;
  54100. /**
  54101. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54102. * @param mesh Defines the mesh we want the helper attached to
  54103. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54104. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54105. * @param length Defines the length of the ray
  54106. */
  54107. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54108. /**
  54109. * Detach the ray helper from the mesh it has previously been attached to.
  54110. */
  54111. detachFromMesh(): void;
  54112. private _updateToMesh;
  54113. /**
  54114. * Dispose the helper and release its associated resources.
  54115. */
  54116. dispose(): void;
  54117. }
  54118. }
  54119. declare module BABYLON {
  54120. /**
  54121. * Defines the options associated with the creation of a SkeletonViewer.
  54122. */
  54123. export interface ISkeletonViewerOptions {
  54124. /** Should the system pause animations before building the Viewer? */
  54125. pauseAnimations: boolean;
  54126. /** Should the system return the skeleton to rest before building? */
  54127. returnToRest: boolean;
  54128. /** public Display Mode of the Viewer */
  54129. displayMode: number;
  54130. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54131. displayOptions: ISkeletonViewerDisplayOptions;
  54132. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54133. computeBonesUsingShaders: boolean;
  54134. /** Flag ignore non weighted bones */
  54135. useAllBones: boolean;
  54136. }
  54137. /**
  54138. * Defines how to display the various bone meshes for the viewer.
  54139. */
  54140. export interface ISkeletonViewerDisplayOptions {
  54141. /** How far down to start tapering the bone spurs */
  54142. midStep?: number;
  54143. /** How big is the midStep? */
  54144. midStepFactor?: number;
  54145. /** Base for the Sphere Size */
  54146. sphereBaseSize?: number;
  54147. /** The ratio of the sphere to the longest bone in units */
  54148. sphereScaleUnit?: number;
  54149. /** Ratio for the Sphere Size */
  54150. sphereFactor?: number;
  54151. /** Whether a spur should attach its far end to the child bone position */
  54152. spurFollowsChild?: boolean;
  54153. /** Whether to show local axes or not */
  54154. showLocalAxes?: boolean;
  54155. /** Length of each local axis */
  54156. localAxesSize?: number;
  54157. }
  54158. /**
  54159. * Defines the constructor options for the BoneWeight Shader.
  54160. */
  54161. export interface IBoneWeightShaderOptions {
  54162. /** Skeleton to Map */
  54163. skeleton: Skeleton;
  54164. /** Colors for Uninfluenced bones */
  54165. colorBase?: Color3;
  54166. /** Colors for 0.0-0.25 Weight bones */
  54167. colorZero?: Color3;
  54168. /** Color for 0.25-0.5 Weight Influence */
  54169. colorQuarter?: Color3;
  54170. /** Color for 0.5-0.75 Weight Influence */
  54171. colorHalf?: Color3;
  54172. /** Color for 0.75-1 Weight Influence */
  54173. colorFull?: Color3;
  54174. /** Color for Zero Weight Influence */
  54175. targetBoneIndex?: number;
  54176. }
  54177. /**
  54178. * Simple structure of the gradient steps for the Color Map.
  54179. */
  54180. export interface ISkeletonMapShaderColorMapKnot {
  54181. /** Color of the Knot */
  54182. color: Color3;
  54183. /** Location of the Knot */
  54184. location: number;
  54185. }
  54186. /**
  54187. * Defines the constructor options for the SkeletonMap Shader.
  54188. */
  54189. export interface ISkeletonMapShaderOptions {
  54190. /** Skeleton to Map */
  54191. skeleton: Skeleton;
  54192. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54193. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54194. }
  54195. }
  54196. declare module BABYLON {
  54197. /**
  54198. * Class containing static functions to help procedurally build meshes
  54199. */
  54200. export class RibbonBuilder {
  54201. /**
  54202. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54203. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54204. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54205. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54206. * * 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
  54207. * * 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
  54208. * * 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
  54209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54210. * * 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
  54211. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54212. * * 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
  54213. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54214. * * 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
  54215. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54217. * @param name defines the name of the mesh
  54218. * @param options defines the options used to create the mesh
  54219. * @param scene defines the hosting scene
  54220. * @returns the ribbon mesh
  54221. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54222. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54223. */
  54224. static CreateRibbon(name: string, options: {
  54225. pathArray: Vector3[][];
  54226. closeArray?: boolean;
  54227. closePath?: boolean;
  54228. offset?: number;
  54229. updatable?: boolean;
  54230. sideOrientation?: number;
  54231. frontUVs?: Vector4;
  54232. backUVs?: Vector4;
  54233. instance?: Mesh;
  54234. invertUV?: boolean;
  54235. uvs?: Vector2[];
  54236. colors?: Color4[];
  54237. }, scene?: Nullable<Scene>): Mesh;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. /**
  54242. * Class containing static functions to help procedurally build meshes
  54243. */
  54244. export class ShapeBuilder {
  54245. /**
  54246. * 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.
  54247. * * 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.
  54248. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54249. * * 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.
  54250. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54251. * * 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
  54252. * * 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
  54253. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54255. * * 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
  54256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54258. * @param name defines the name of the mesh
  54259. * @param options defines the options used to create the mesh
  54260. * @param scene defines the hosting scene
  54261. * @returns the extruded shape mesh
  54262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54264. */
  54265. static ExtrudeShape(name: string, options: {
  54266. shape: Vector3[];
  54267. path: Vector3[];
  54268. scale?: number;
  54269. rotation?: number;
  54270. cap?: number;
  54271. updatable?: boolean;
  54272. sideOrientation?: number;
  54273. frontUVs?: Vector4;
  54274. backUVs?: Vector4;
  54275. instance?: Mesh;
  54276. invertUV?: boolean;
  54277. }, scene?: Nullable<Scene>): Mesh;
  54278. /**
  54279. * Creates an custom extruded shape mesh.
  54280. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54281. * * 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.
  54282. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54283. * * 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
  54284. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54285. * * 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
  54286. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54287. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54288. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54289. * * 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
  54290. * * 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
  54291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54293. * * 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
  54294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54296. * @param name defines the name of the mesh
  54297. * @param options defines the options used to create the mesh
  54298. * @param scene defines the hosting scene
  54299. * @returns the custom extruded shape mesh
  54300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54303. */
  54304. static ExtrudeShapeCustom(name: string, options: {
  54305. shape: Vector3[];
  54306. path: Vector3[];
  54307. scaleFunction?: any;
  54308. rotationFunction?: any;
  54309. ribbonCloseArray?: boolean;
  54310. ribbonClosePath?: boolean;
  54311. cap?: number;
  54312. updatable?: boolean;
  54313. sideOrientation?: number;
  54314. frontUVs?: Vector4;
  54315. backUVs?: Vector4;
  54316. instance?: Mesh;
  54317. invertUV?: boolean;
  54318. }, scene?: Nullable<Scene>): Mesh;
  54319. private static _ExtrudeShapeGeneric;
  54320. }
  54321. }
  54322. declare module BABYLON.Debug {
  54323. /**
  54324. * Class used to render a debug view of a given skeleton
  54325. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54326. */
  54327. export class SkeletonViewer {
  54328. /** defines the skeleton to render */
  54329. skeleton: Skeleton;
  54330. /** defines the mesh attached to the skeleton */
  54331. mesh: AbstractMesh;
  54332. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54333. autoUpdateBonesMatrices: boolean;
  54334. /** defines the rendering group id to use with the viewer */
  54335. renderingGroupId: number;
  54336. /** is the options for the viewer */
  54337. options: Partial<ISkeletonViewerOptions>;
  54338. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54339. static readonly DISPLAY_LINES: number;
  54340. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54341. static readonly DISPLAY_SPHERES: number;
  54342. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54343. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54344. /** public static method to create a BoneWeight Shader
  54345. * @param options The constructor options
  54346. * @param scene The scene that the shader is scoped to
  54347. * @returns The created ShaderMaterial
  54348. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54349. */
  54350. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54351. /** public static method to create a BoneWeight Shader
  54352. * @param options The constructor options
  54353. * @param scene The scene that the shader is scoped to
  54354. * @returns The created ShaderMaterial
  54355. */
  54356. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54357. /** private static method to create a BoneWeight Shader
  54358. * @param size The size of the buffer to create (usually the bone count)
  54359. * @param colorMap The gradient data to generate
  54360. * @param scene The scene that the shader is scoped to
  54361. * @returns an Array of floats from the color gradient values
  54362. */
  54363. private static _CreateBoneMapColorBuffer;
  54364. /** If SkeletonViewer scene scope. */
  54365. private _scene;
  54366. /** Gets or sets the color used to render the skeleton */
  54367. color: Color3;
  54368. /** Array of the points of the skeleton fo the line view. */
  54369. private _debugLines;
  54370. /** The SkeletonViewers Mesh. */
  54371. private _debugMesh;
  54372. /** The local axes Meshes. */
  54373. private _localAxes;
  54374. /** If SkeletonViewer is enabled. */
  54375. private _isEnabled;
  54376. /** If SkeletonViewer is ready. */
  54377. private _ready;
  54378. /** SkeletonViewer render observable. */
  54379. private _obs;
  54380. /** The Utility Layer to render the gizmos in. */
  54381. private _utilityLayer;
  54382. private _boneIndices;
  54383. /** Gets the Scene. */
  54384. get scene(): Scene;
  54385. /** Gets the utilityLayer. */
  54386. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54387. /** Checks Ready Status. */
  54388. get isReady(): Boolean;
  54389. /** Sets Ready Status. */
  54390. set ready(value: boolean);
  54391. /** Gets the debugMesh */
  54392. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54393. /** Sets the debugMesh */
  54394. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54395. /** Gets the displayMode */
  54396. get displayMode(): number;
  54397. /** Sets the displayMode */
  54398. set displayMode(value: number);
  54399. /**
  54400. * Creates a new SkeletonViewer
  54401. * @param skeleton defines the skeleton to render
  54402. * @param mesh defines the mesh attached to the skeleton
  54403. * @param scene defines the hosting scene
  54404. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54405. * @param renderingGroupId defines the rendering group id to use with the viewer
  54406. * @param options All of the extra constructor options for the SkeletonViewer
  54407. */
  54408. constructor(
  54409. /** defines the skeleton to render */
  54410. skeleton: Skeleton,
  54411. /** defines the mesh attached to the skeleton */
  54412. mesh: AbstractMesh,
  54413. /** The Scene scope*/
  54414. scene: Scene,
  54415. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54416. autoUpdateBonesMatrices?: boolean,
  54417. /** defines the rendering group id to use with the viewer */
  54418. renderingGroupId?: number,
  54419. /** is the options for the viewer */
  54420. options?: Partial<ISkeletonViewerOptions>);
  54421. /** The Dynamic bindings for the update functions */
  54422. private _bindObs;
  54423. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54424. update(): void;
  54425. /** Gets or sets a boolean indicating if the viewer is enabled */
  54426. set isEnabled(value: boolean);
  54427. get isEnabled(): boolean;
  54428. private _getBonePosition;
  54429. private _getLinesForBonesWithLength;
  54430. private _getLinesForBonesNoLength;
  54431. /** function to revert the mesh and scene back to the initial state. */
  54432. private _revert;
  54433. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54434. private _getAbsoluteBindPoseToRef;
  54435. /** function to build and bind sphere joint points and spur bone representations. */
  54436. private _buildSpheresAndSpurs;
  54437. private _buildLocalAxes;
  54438. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54439. private _displayLinesUpdate;
  54440. /** Changes the displayMode of the skeleton viewer
  54441. * @param mode The displayMode numerical value
  54442. */
  54443. changeDisplayMode(mode: number): void;
  54444. /** Sets a display option of the skeleton viewer
  54445. *
  54446. * | Option | Type | Default | Description |
  54447. * | ---------------- | ------- | ------- | ----------- |
  54448. * | 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`. |
  54449. * | 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`. |
  54450. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54451. * | 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`. |
  54452. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54453. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54454. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54455. *
  54456. * @param option String of the option name
  54457. * @param value The numerical option value
  54458. */
  54459. changeDisplayOptions(option: string, value: number): void;
  54460. /** Release associated resources */
  54461. dispose(): void;
  54462. }
  54463. }
  54464. declare module BABYLON {
  54465. /**
  54466. * Enum for Device Types
  54467. */
  54468. export enum DeviceType {
  54469. /** Generic */
  54470. Generic = 0,
  54471. /** Keyboard */
  54472. Keyboard = 1,
  54473. /** Mouse */
  54474. Mouse = 2,
  54475. /** Touch Pointers */
  54476. Touch = 3,
  54477. /** PS4 Dual Shock */
  54478. DualShock = 4,
  54479. /** Xbox */
  54480. Xbox = 5,
  54481. /** Switch Controller */
  54482. Switch = 6
  54483. }
  54484. /**
  54485. * Enum for All Pointers (Touch/Mouse)
  54486. */
  54487. export enum PointerInput {
  54488. /** Horizontal Axis */
  54489. Horizontal = 0,
  54490. /** Vertical Axis */
  54491. Vertical = 1,
  54492. /** Left Click or Touch */
  54493. LeftClick = 2,
  54494. /** Middle Click */
  54495. MiddleClick = 3,
  54496. /** Right Click */
  54497. RightClick = 4,
  54498. /** Browser Back */
  54499. BrowserBack = 5,
  54500. /** Browser Forward */
  54501. BrowserForward = 6
  54502. }
  54503. /**
  54504. * Enum for Dual Shock Gamepad
  54505. */
  54506. export enum DualShockInput {
  54507. /** Cross */
  54508. Cross = 0,
  54509. /** Circle */
  54510. Circle = 1,
  54511. /** Square */
  54512. Square = 2,
  54513. /** Triangle */
  54514. Triangle = 3,
  54515. /** L1 */
  54516. L1 = 4,
  54517. /** R1 */
  54518. R1 = 5,
  54519. /** L2 */
  54520. L2 = 6,
  54521. /** R2 */
  54522. R2 = 7,
  54523. /** Share */
  54524. Share = 8,
  54525. /** Options */
  54526. Options = 9,
  54527. /** L3 */
  54528. L3 = 10,
  54529. /** R3 */
  54530. R3 = 11,
  54531. /** DPadUp */
  54532. DPadUp = 12,
  54533. /** DPadDown */
  54534. DPadDown = 13,
  54535. /** DPadLeft */
  54536. DPadLeft = 14,
  54537. /** DRight */
  54538. DPadRight = 15,
  54539. /** Home */
  54540. Home = 16,
  54541. /** TouchPad */
  54542. TouchPad = 17,
  54543. /** LStickXAxis */
  54544. LStickXAxis = 18,
  54545. /** LStickYAxis */
  54546. LStickYAxis = 19,
  54547. /** RStickXAxis */
  54548. RStickXAxis = 20,
  54549. /** RStickYAxis */
  54550. RStickYAxis = 21
  54551. }
  54552. /**
  54553. * Enum for Xbox Gamepad
  54554. */
  54555. export enum XboxInput {
  54556. /** A */
  54557. A = 0,
  54558. /** B */
  54559. B = 1,
  54560. /** X */
  54561. X = 2,
  54562. /** Y */
  54563. Y = 3,
  54564. /** LB */
  54565. LB = 4,
  54566. /** RB */
  54567. RB = 5,
  54568. /** LT */
  54569. LT = 6,
  54570. /** RT */
  54571. RT = 7,
  54572. /** Back */
  54573. Back = 8,
  54574. /** Start */
  54575. Start = 9,
  54576. /** LS */
  54577. LS = 10,
  54578. /** RS */
  54579. RS = 11,
  54580. /** DPadUp */
  54581. DPadUp = 12,
  54582. /** DPadDown */
  54583. DPadDown = 13,
  54584. /** DPadLeft */
  54585. DPadLeft = 14,
  54586. /** DRight */
  54587. DPadRight = 15,
  54588. /** Home */
  54589. Home = 16,
  54590. /** LStickXAxis */
  54591. LStickXAxis = 17,
  54592. /** LStickYAxis */
  54593. LStickYAxis = 18,
  54594. /** RStickXAxis */
  54595. RStickXAxis = 19,
  54596. /** RStickYAxis */
  54597. RStickYAxis = 20
  54598. }
  54599. /**
  54600. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54601. */
  54602. export enum SwitchInput {
  54603. /** B */
  54604. B = 0,
  54605. /** A */
  54606. A = 1,
  54607. /** Y */
  54608. Y = 2,
  54609. /** X */
  54610. X = 3,
  54611. /** L */
  54612. L = 4,
  54613. /** R */
  54614. R = 5,
  54615. /** ZL */
  54616. ZL = 6,
  54617. /** ZR */
  54618. ZR = 7,
  54619. /** Minus */
  54620. Minus = 8,
  54621. /** Plus */
  54622. Plus = 9,
  54623. /** LS */
  54624. LS = 10,
  54625. /** RS */
  54626. RS = 11,
  54627. /** DPadUp */
  54628. DPadUp = 12,
  54629. /** DPadDown */
  54630. DPadDown = 13,
  54631. /** DPadLeft */
  54632. DPadLeft = 14,
  54633. /** DRight */
  54634. DPadRight = 15,
  54635. /** Home */
  54636. Home = 16,
  54637. /** Capture */
  54638. Capture = 17,
  54639. /** LStickXAxis */
  54640. LStickXAxis = 18,
  54641. /** LStickYAxis */
  54642. LStickYAxis = 19,
  54643. /** RStickXAxis */
  54644. RStickXAxis = 20,
  54645. /** RStickYAxis */
  54646. RStickYAxis = 21
  54647. }
  54648. }
  54649. declare module BABYLON {
  54650. /**
  54651. * This class will take all inputs from Keyboard, Pointer, and
  54652. * any Gamepads and provide a polling system that all devices
  54653. * will use. This class assumes that there will only be one
  54654. * pointer device and one keyboard.
  54655. */
  54656. export class DeviceInputSystem implements IDisposable {
  54657. /**
  54658. * Callback to be triggered when a device is connected
  54659. */
  54660. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54661. /**
  54662. * Callback to be triggered when a device is disconnected
  54663. */
  54664. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54665. /**
  54666. * Callback to be triggered when event driven input is updated
  54667. */
  54668. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54669. private _inputs;
  54670. private _gamepads;
  54671. private _keyboardActive;
  54672. private _pointerActive;
  54673. private _elementToAttachTo;
  54674. private _keyboardDownEvent;
  54675. private _keyboardUpEvent;
  54676. private _pointerMoveEvent;
  54677. private _pointerDownEvent;
  54678. private _pointerUpEvent;
  54679. private _gamepadConnectedEvent;
  54680. private _gamepadDisconnectedEvent;
  54681. private static _MAX_KEYCODES;
  54682. private static _MAX_POINTER_INPUTS;
  54683. private constructor();
  54684. /**
  54685. * Creates a new DeviceInputSystem instance
  54686. * @param engine Engine to pull input element from
  54687. * @returns The new instance
  54688. */
  54689. static Create(engine: Engine): DeviceInputSystem;
  54690. /**
  54691. * Checks for current device input value, given an id and input index
  54692. * @param deviceName Id of connected device
  54693. * @param inputIndex Index of device input
  54694. * @returns Current value of input
  54695. */
  54696. /**
  54697. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54698. * @param deviceType Enum specifiying device type
  54699. * @param deviceSlot "Slot" or index that device is referenced in
  54700. * @param inputIndex Id of input to be checked
  54701. * @returns Current value of input
  54702. */
  54703. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54704. /**
  54705. * Dispose of all the eventlisteners
  54706. */
  54707. dispose(): void;
  54708. /**
  54709. * Add device and inputs to device array
  54710. * @param deviceType Enum specifiying device type
  54711. * @param deviceSlot "Slot" or index that device is referenced in
  54712. * @param numberOfInputs Number of input entries to create for given device
  54713. */
  54714. private _registerDevice;
  54715. /**
  54716. * Given a specific device name, remove that device from the device map
  54717. * @param deviceType Enum specifiying device type
  54718. * @param deviceSlot "Slot" or index that device is referenced in
  54719. */
  54720. private _unregisterDevice;
  54721. /**
  54722. * Handle all actions that come from keyboard interaction
  54723. */
  54724. private _handleKeyActions;
  54725. /**
  54726. * Handle all actions that come from pointer interaction
  54727. */
  54728. private _handlePointerActions;
  54729. /**
  54730. * Handle all actions that come from gamepad interaction
  54731. */
  54732. private _handleGamepadActions;
  54733. /**
  54734. * Update all non-event based devices with each frame
  54735. * @param deviceType Enum specifiying device type
  54736. * @param deviceSlot "Slot" or index that device is referenced in
  54737. * @param inputIndex Id of input to be checked
  54738. */
  54739. private _updateDevice;
  54740. /**
  54741. * Gets DeviceType from the device name
  54742. * @param deviceName Name of Device from DeviceInputSystem
  54743. * @returns DeviceType enum value
  54744. */
  54745. private _getGamepadDeviceType;
  54746. }
  54747. }
  54748. declare module BABYLON {
  54749. /**
  54750. * Type to handle enforcement of inputs
  54751. */
  54752. 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;
  54753. }
  54754. declare module BABYLON {
  54755. /**
  54756. * Class that handles all input for a specific device
  54757. */
  54758. export class DeviceSource<T extends DeviceType> {
  54759. /** Type of device */
  54760. readonly deviceType: DeviceType;
  54761. /** "Slot" or index that device is referenced in */
  54762. readonly deviceSlot: number;
  54763. /**
  54764. * Observable to handle device input changes per device
  54765. */
  54766. readonly onInputChangedObservable: Observable<{
  54767. inputIndex: DeviceInput<T>;
  54768. previousState: Nullable<number>;
  54769. currentState: Nullable<number>;
  54770. }>;
  54771. private readonly _deviceInputSystem;
  54772. /**
  54773. * Default Constructor
  54774. * @param deviceInputSystem Reference to DeviceInputSystem
  54775. * @param deviceType Type of device
  54776. * @param deviceSlot "Slot" or index that device is referenced in
  54777. */
  54778. constructor(deviceInputSystem: DeviceInputSystem,
  54779. /** Type of device */
  54780. deviceType: DeviceType,
  54781. /** "Slot" or index that device is referenced in */
  54782. deviceSlot?: number);
  54783. /**
  54784. * Get input for specific input
  54785. * @param inputIndex index of specific input on device
  54786. * @returns Input value from DeviceInputSystem
  54787. */
  54788. getInput(inputIndex: DeviceInput<T>): number;
  54789. }
  54790. /**
  54791. * Class to keep track of devices
  54792. */
  54793. export class DeviceSourceManager implements IDisposable {
  54794. /**
  54795. * Observable to be triggered when before a device is connected
  54796. */
  54797. readonly onBeforeDeviceConnectedObservable: Observable<{
  54798. deviceType: DeviceType;
  54799. deviceSlot: number;
  54800. }>;
  54801. /**
  54802. * Observable to be triggered when before a device is disconnected
  54803. */
  54804. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54805. deviceType: DeviceType;
  54806. deviceSlot: number;
  54807. }>;
  54808. /**
  54809. * Observable to be triggered when after a device is connected
  54810. */
  54811. readonly onAfterDeviceConnectedObservable: Observable<{
  54812. deviceType: DeviceType;
  54813. deviceSlot: number;
  54814. }>;
  54815. /**
  54816. * Observable to be triggered when after a device is disconnected
  54817. */
  54818. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54819. deviceType: DeviceType;
  54820. deviceSlot: number;
  54821. }>;
  54822. private readonly _devices;
  54823. private readonly _firstDevice;
  54824. private readonly _deviceInputSystem;
  54825. /**
  54826. * Default Constructor
  54827. * @param engine engine to pull input element from
  54828. */
  54829. constructor(engine: Engine);
  54830. /**
  54831. * Gets a DeviceSource, given a type and slot
  54832. * @param deviceType Enum specifying device type
  54833. * @param deviceSlot "Slot" or index that device is referenced in
  54834. * @returns DeviceSource object
  54835. */
  54836. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54837. /**
  54838. * Gets an array of DeviceSource objects for a given device type
  54839. * @param deviceType Enum specifying device type
  54840. * @returns Array of DeviceSource objects
  54841. */
  54842. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54843. /**
  54844. * Dispose of DeviceInputSystem and other parts
  54845. */
  54846. dispose(): void;
  54847. /**
  54848. * Function to add device name to device list
  54849. * @param deviceType Enum specifying device type
  54850. * @param deviceSlot "Slot" or index that device is referenced in
  54851. */
  54852. private _addDevice;
  54853. /**
  54854. * Function to remove device name to device list
  54855. * @param deviceType Enum specifying device type
  54856. * @param deviceSlot "Slot" or index that device is referenced in
  54857. */
  54858. private _removeDevice;
  54859. /**
  54860. * Updates array storing first connected device of each type
  54861. * @param type Type of Device
  54862. */
  54863. private _updateFirstDevices;
  54864. }
  54865. }
  54866. declare module BABYLON {
  54867. /**
  54868. * Options to create the null engine
  54869. */
  54870. export class NullEngineOptions {
  54871. /**
  54872. * Render width (Default: 512)
  54873. */
  54874. renderWidth: number;
  54875. /**
  54876. * Render height (Default: 256)
  54877. */
  54878. renderHeight: number;
  54879. /**
  54880. * Texture size (Default: 512)
  54881. */
  54882. textureSize: number;
  54883. /**
  54884. * If delta time between frames should be constant
  54885. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54886. */
  54887. deterministicLockstep: boolean;
  54888. /**
  54889. * Maximum about of steps between frames (Default: 4)
  54890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54891. */
  54892. lockstepMaxSteps: number;
  54893. /**
  54894. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54895. */
  54896. useHighPrecisionMatrix?: boolean;
  54897. }
  54898. /**
  54899. * The null engine class provides support for headless version of babylon.js.
  54900. * This can be used in server side scenario or for testing purposes
  54901. */
  54902. export class NullEngine extends Engine {
  54903. private _options;
  54904. /**
  54905. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54907. * @returns true if engine is in deterministic lock step mode
  54908. */
  54909. isDeterministicLockStep(): boolean;
  54910. /**
  54911. * Gets the max steps when engine is running in deterministic lock step
  54912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54913. * @returns the max steps
  54914. */
  54915. getLockstepMaxSteps(): number;
  54916. /**
  54917. * Gets the current hardware scaling level.
  54918. * By default the hardware scaling level is computed from the window device ratio.
  54919. * 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.
  54920. * @returns a number indicating the current hardware scaling level
  54921. */
  54922. getHardwareScalingLevel(): number;
  54923. constructor(options?: NullEngineOptions);
  54924. /**
  54925. * Creates a vertex buffer
  54926. * @param vertices the data for the vertex buffer
  54927. * @returns the new WebGL static buffer
  54928. */
  54929. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54930. /**
  54931. * Creates a new index buffer
  54932. * @param indices defines the content of the index buffer
  54933. * @param updatable defines if the index buffer must be updatable
  54934. * @returns a new webGL buffer
  54935. */
  54936. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54937. /**
  54938. * Clear the current render buffer or the current render target (if any is set up)
  54939. * @param color defines the color to use
  54940. * @param backBuffer defines if the back buffer must be cleared
  54941. * @param depth defines if the depth buffer must be cleared
  54942. * @param stencil defines if the stencil buffer must be cleared
  54943. */
  54944. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54945. /**
  54946. * Gets the current render width
  54947. * @param useScreen defines if screen size must be used (or the current render target if any)
  54948. * @returns a number defining the current render width
  54949. */
  54950. getRenderWidth(useScreen?: boolean): number;
  54951. /**
  54952. * Gets the current render height
  54953. * @param useScreen defines if screen size must be used (or the current render target if any)
  54954. * @returns a number defining the current render height
  54955. */
  54956. getRenderHeight(useScreen?: boolean): number;
  54957. /**
  54958. * Set the WebGL's viewport
  54959. * @param viewport defines the viewport element to be used
  54960. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54961. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54962. */
  54963. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54964. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54965. /**
  54966. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54967. * @param pipelineContext defines the pipeline context to use
  54968. * @param uniformsNames defines the list of uniform names
  54969. * @returns an array of webGL uniform locations
  54970. */
  54971. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54972. /**
  54973. * Gets the lsit of active attributes for a given webGL program
  54974. * @param pipelineContext defines the pipeline context to use
  54975. * @param attributesNames defines the list of attribute names to get
  54976. * @returns an array of indices indicating the offset of each attribute
  54977. */
  54978. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54979. /**
  54980. * Binds an effect to the webGL context
  54981. * @param effect defines the effect to bind
  54982. */
  54983. bindSamplers(effect: Effect): void;
  54984. /**
  54985. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54986. * @param effect defines the effect to activate
  54987. */
  54988. enableEffect(effect: Effect): void;
  54989. /**
  54990. * Set various states to the webGL context
  54991. * @param culling defines backface culling state
  54992. * @param zOffset defines the value to apply to zOffset (0 by default)
  54993. * @param force defines if states must be applied even if cache is up to date
  54994. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54995. */
  54996. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54997. /**
  54998. * Set the value of an uniform to an array of int32
  54999. * @param uniform defines the webGL uniform location where to store the value
  55000. * @param array defines the array of int32 to store
  55001. * @returns true if value was set
  55002. */
  55003. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55004. /**
  55005. * Set the value of an uniform to an array of int32 (stored as vec2)
  55006. * @param uniform defines the webGL uniform location where to store the value
  55007. * @param array defines the array of int32 to store
  55008. * @returns true if value was set
  55009. */
  55010. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55011. /**
  55012. * Set the value of an uniform to an array of int32 (stored as vec3)
  55013. * @param uniform defines the webGL uniform location where to store the value
  55014. * @param array defines the array of int32 to store
  55015. * @returns true if value was set
  55016. */
  55017. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55018. /**
  55019. * Set the value of an uniform to an array of int32 (stored as vec4)
  55020. * @param uniform defines the webGL uniform location where to store the value
  55021. * @param array defines the array of int32 to store
  55022. * @returns true if value was set
  55023. */
  55024. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55025. /**
  55026. * Set the value of an uniform to an array of float32
  55027. * @param uniform defines the webGL uniform location where to store the value
  55028. * @param array defines the array of float32 to store
  55029. * @returns true if value was set
  55030. */
  55031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55032. /**
  55033. * Set the value of an uniform to an array of float32 (stored as vec2)
  55034. * @param uniform defines the webGL uniform location where to store the value
  55035. * @param array defines the array of float32 to store
  55036. * @returns true if value was set
  55037. */
  55038. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55039. /**
  55040. * Set the value of an uniform to an array of float32 (stored as vec3)
  55041. * @param uniform defines the webGL uniform location where to store the value
  55042. * @param array defines the array of float32 to store
  55043. * @returns true if value was set
  55044. */
  55045. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55046. /**
  55047. * Set the value of an uniform to an array of float32 (stored as vec4)
  55048. * @param uniform defines the webGL uniform location where to store the value
  55049. * @param array defines the array of float32 to store
  55050. * @returns true if value was set
  55051. */
  55052. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55053. /**
  55054. * Set the value of an uniform to an array of number
  55055. * @param uniform defines the webGL uniform location where to store the value
  55056. * @param array defines the array of number to store
  55057. * @returns true if value was set
  55058. */
  55059. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55060. /**
  55061. * Set the value of an uniform to an array of number (stored as vec2)
  55062. * @param uniform defines the webGL uniform location where to store the value
  55063. * @param array defines the array of number to store
  55064. * @returns true if value was set
  55065. */
  55066. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55067. /**
  55068. * Set the value of an uniform to an array of number (stored as vec3)
  55069. * @param uniform defines the webGL uniform location where to store the value
  55070. * @param array defines the array of number to store
  55071. * @returns true if value was set
  55072. */
  55073. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55074. /**
  55075. * Set the value of an uniform to an array of number (stored as vec4)
  55076. * @param uniform defines the webGL uniform location where to store the value
  55077. * @param array defines the array of number to store
  55078. * @returns true if value was set
  55079. */
  55080. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55081. /**
  55082. * Set the value of an uniform to an array of float32 (stored as matrices)
  55083. * @param uniform defines the webGL uniform location where to store the value
  55084. * @param matrices defines the array of float32 to store
  55085. * @returns true if value was set
  55086. */
  55087. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55088. /**
  55089. * Set the value of an uniform to a matrix (3x3)
  55090. * @param uniform defines the webGL uniform location where to store the value
  55091. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55092. * @returns true if value was set
  55093. */
  55094. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55095. /**
  55096. * Set the value of an uniform to a matrix (2x2)
  55097. * @param uniform defines the webGL uniform location where to store the value
  55098. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55099. * @returns true if value was set
  55100. */
  55101. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55102. /**
  55103. * Set the value of an uniform to a number (float)
  55104. * @param uniform defines the webGL uniform location where to store the value
  55105. * @param value defines the float number to store
  55106. * @returns true if value was set
  55107. */
  55108. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55109. /**
  55110. * Set the value of an uniform to a vec2
  55111. * @param uniform defines the webGL uniform location where to store the value
  55112. * @param x defines the 1st component of the value
  55113. * @param y defines the 2nd component of the value
  55114. * @returns true if value was set
  55115. */
  55116. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55117. /**
  55118. * Set the value of an uniform to a vec3
  55119. * @param uniform defines the webGL uniform location where to store the value
  55120. * @param x defines the 1st component of the value
  55121. * @param y defines the 2nd component of the value
  55122. * @param z defines the 3rd component of the value
  55123. * @returns true if value was set
  55124. */
  55125. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55126. /**
  55127. * Set the value of an uniform to a boolean
  55128. * @param uniform defines the webGL uniform location where to store the value
  55129. * @param bool defines the boolean to store
  55130. * @returns true if value was set
  55131. */
  55132. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55133. /**
  55134. * Set the value of an uniform to a vec4
  55135. * @param uniform defines the webGL uniform location where to store the value
  55136. * @param x defines the 1st component of the value
  55137. * @param y defines the 2nd component of the value
  55138. * @param z defines the 3rd component of the value
  55139. * @param w defines the 4th component of the value
  55140. * @returns true if value was set
  55141. */
  55142. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55143. /**
  55144. * Sets the current alpha mode
  55145. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55146. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55147. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55148. */
  55149. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55150. /**
  55151. * Bind webGl buffers directly to the webGL context
  55152. * @param vertexBuffers defines the vertex buffer to bind
  55153. * @param indexBuffer defines the index buffer to bind
  55154. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55155. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55156. * @param effect defines the effect associated with the vertex buffer
  55157. */
  55158. bindBuffers(vertexBuffers: {
  55159. [key: string]: VertexBuffer;
  55160. }, indexBuffer: DataBuffer, effect: Effect): void;
  55161. /**
  55162. * Force the entire cache to be cleared
  55163. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55164. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55165. */
  55166. wipeCaches(bruteForce?: boolean): void;
  55167. /**
  55168. * Send a draw order
  55169. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55170. * @param indexStart defines the starting index
  55171. * @param indexCount defines the number of index to draw
  55172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55173. */
  55174. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55175. /**
  55176. * Draw a list of indexed primitives
  55177. * @param fillMode defines the primitive to use
  55178. * @param indexStart defines the starting index
  55179. * @param indexCount defines the number of index to draw
  55180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55181. */
  55182. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55183. /**
  55184. * Draw a list of unindexed primitives
  55185. * @param fillMode defines the primitive to use
  55186. * @param verticesStart defines the index of first vertex to draw
  55187. * @param verticesCount defines the count of vertices to draw
  55188. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55189. */
  55190. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55191. /** @hidden */
  55192. _createTexture(): WebGLTexture;
  55193. /** @hidden */
  55194. _releaseTexture(texture: InternalTexture): void;
  55195. /**
  55196. * Usually called from Texture.ts.
  55197. * Passed information to create a WebGLTexture
  55198. * @param urlArg defines a value which contains one of the following:
  55199. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55200. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55201. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55202. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55203. * @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)
  55204. * @param scene needed for loading to the correct scene
  55205. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55206. * @param onLoad optional callback to be called upon successful completion
  55207. * @param onError optional callback to be called upon failure
  55208. * @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
  55209. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55210. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55211. * @param forcedExtension defines the extension to use to pick the right loader
  55212. * @param mimeType defines an optional mime type
  55213. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55214. */
  55215. 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;
  55216. /**
  55217. * Creates a new render target texture
  55218. * @param size defines the size of the texture
  55219. * @param options defines the options used to create the texture
  55220. * @returns a new render target texture stored in an InternalTexture
  55221. */
  55222. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55223. /**
  55224. * Update the sampling mode of a given texture
  55225. * @param samplingMode defines the required sampling mode
  55226. * @param texture defines the texture to update
  55227. */
  55228. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55229. /**
  55230. * Binds the frame buffer to the specified texture.
  55231. * @param texture The texture to render to or null for the default canvas
  55232. * @param faceIndex The face of the texture to render to in case of cube texture
  55233. * @param requiredWidth The width of the target to render to
  55234. * @param requiredHeight The height of the target to render to
  55235. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55236. * @param lodLevel defines le lod level to bind to the frame buffer
  55237. */
  55238. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55239. /**
  55240. * Unbind the current render target texture from the webGL context
  55241. * @param texture defines the render target texture to unbind
  55242. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55243. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55244. */
  55245. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55246. /**
  55247. * Creates a dynamic vertex buffer
  55248. * @param vertices the data for the dynamic vertex buffer
  55249. * @returns the new WebGL dynamic buffer
  55250. */
  55251. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55252. /**
  55253. * Update the content of a dynamic texture
  55254. * @param texture defines the texture to update
  55255. * @param canvas defines the canvas containing the source
  55256. * @param invertY defines if data must be stored with Y axis inverted
  55257. * @param premulAlpha defines if alpha is stored as premultiplied
  55258. * @param format defines the format of the data
  55259. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55260. */
  55261. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55262. /**
  55263. * Gets a boolean indicating if all created effects are ready
  55264. * @returns true if all effects are ready
  55265. */
  55266. areAllEffectsReady(): boolean;
  55267. /**
  55268. * @hidden
  55269. * Get the current error code of the webGL context
  55270. * @returns the error code
  55271. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55272. */
  55273. getError(): number;
  55274. /** @hidden */
  55275. _getUnpackAlignement(): number;
  55276. /** @hidden */
  55277. _unpackFlipY(value: boolean): void;
  55278. /**
  55279. * Update a dynamic index buffer
  55280. * @param indexBuffer defines the target index buffer
  55281. * @param indices defines the data to update
  55282. * @param offset defines the offset in the target index buffer where update should start
  55283. */
  55284. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55285. /**
  55286. * Updates a dynamic vertex buffer.
  55287. * @param vertexBuffer the vertex buffer to update
  55288. * @param vertices the data used to update the vertex buffer
  55289. * @param byteOffset the byte offset of the data (optional)
  55290. * @param byteLength the byte length of the data (optional)
  55291. */
  55292. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55293. /** @hidden */
  55294. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55295. /** @hidden */
  55296. _bindTexture(channel: number, texture: InternalTexture): void;
  55297. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55298. /**
  55299. * 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
  55300. */
  55301. releaseEffects(): void;
  55302. displayLoadingUI(): void;
  55303. hideLoadingUI(): void;
  55304. /** @hidden */
  55305. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55306. /** @hidden */
  55307. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55308. /** @hidden */
  55309. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55310. /** @hidden */
  55311. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * @hidden
  55317. **/
  55318. export class _TimeToken {
  55319. _startTimeQuery: Nullable<WebGLQuery>;
  55320. _endTimeQuery: Nullable<WebGLQuery>;
  55321. _timeElapsedQuery: Nullable<WebGLQuery>;
  55322. _timeElapsedQueryEnded: boolean;
  55323. }
  55324. }
  55325. declare module BABYLON {
  55326. /** @hidden */
  55327. export class _OcclusionDataStorage {
  55328. /** @hidden */
  55329. occlusionInternalRetryCounter: number;
  55330. /** @hidden */
  55331. isOcclusionQueryInProgress: boolean;
  55332. /** @hidden */
  55333. isOccluded: boolean;
  55334. /** @hidden */
  55335. occlusionRetryCount: number;
  55336. /** @hidden */
  55337. occlusionType: number;
  55338. /** @hidden */
  55339. occlusionQueryAlgorithmType: number;
  55340. }
  55341. interface Engine {
  55342. /**
  55343. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55344. * @return the new query
  55345. */
  55346. createQuery(): WebGLQuery;
  55347. /**
  55348. * Delete and release a webGL query
  55349. * @param query defines the query to delete
  55350. * @return the current engine
  55351. */
  55352. deleteQuery(query: WebGLQuery): Engine;
  55353. /**
  55354. * Check if a given query has resolved and got its value
  55355. * @param query defines the query to check
  55356. * @returns true if the query got its value
  55357. */
  55358. isQueryResultAvailable(query: WebGLQuery): boolean;
  55359. /**
  55360. * Gets the value of a given query
  55361. * @param query defines the query to check
  55362. * @returns the value of the query
  55363. */
  55364. getQueryResult(query: WebGLQuery): number;
  55365. /**
  55366. * Initiates an occlusion query
  55367. * @param algorithmType defines the algorithm to use
  55368. * @param query defines the query to use
  55369. * @returns the current engine
  55370. * @see https://doc.babylonjs.com/features/occlusionquery
  55371. */
  55372. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55373. /**
  55374. * Ends an occlusion query
  55375. * @see https://doc.babylonjs.com/features/occlusionquery
  55376. * @param algorithmType defines the algorithm to use
  55377. * @returns the current engine
  55378. */
  55379. endOcclusionQuery(algorithmType: number): Engine;
  55380. /**
  55381. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55382. * Please note that only one query can be issued at a time
  55383. * @returns a time token used to track the time span
  55384. */
  55385. startTimeQuery(): Nullable<_TimeToken>;
  55386. /**
  55387. * Ends a time query
  55388. * @param token defines the token used to measure the time span
  55389. * @returns the time spent (in ns)
  55390. */
  55391. endTimeQuery(token: _TimeToken): int;
  55392. /** @hidden */
  55393. _currentNonTimestampToken: Nullable<_TimeToken>;
  55394. /** @hidden */
  55395. _createTimeQuery(): WebGLQuery;
  55396. /** @hidden */
  55397. _deleteTimeQuery(query: WebGLQuery): void;
  55398. /** @hidden */
  55399. _getGlAlgorithmType(algorithmType: number): number;
  55400. /** @hidden */
  55401. _getTimeQueryResult(query: WebGLQuery): any;
  55402. /** @hidden */
  55403. _getTimeQueryAvailability(query: WebGLQuery): any;
  55404. }
  55405. interface AbstractMesh {
  55406. /**
  55407. * Backing filed
  55408. * @hidden
  55409. */
  55410. __occlusionDataStorage: _OcclusionDataStorage;
  55411. /**
  55412. * Access property
  55413. * @hidden
  55414. */
  55415. _occlusionDataStorage: _OcclusionDataStorage;
  55416. /**
  55417. * 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.
  55418. * The default value is -1 which means don't break the query and wait till the result
  55419. * @see https://doc.babylonjs.com/features/occlusionquery
  55420. */
  55421. occlusionRetryCount: number;
  55422. /**
  55423. * 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:
  55424. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55425. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55426. * * 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.
  55427. * @see https://doc.babylonjs.com/features/occlusionquery
  55428. */
  55429. occlusionType: number;
  55430. /**
  55431. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55432. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55433. * * 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.
  55434. * @see https://doc.babylonjs.com/features/occlusionquery
  55435. */
  55436. occlusionQueryAlgorithmType: number;
  55437. /**
  55438. * 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
  55439. * @see https://doc.babylonjs.com/features/occlusionquery
  55440. */
  55441. isOccluded: boolean;
  55442. /**
  55443. * Flag to check the progress status of the query
  55444. * @see https://doc.babylonjs.com/features/occlusionquery
  55445. */
  55446. isOcclusionQueryInProgress: boolean;
  55447. }
  55448. }
  55449. declare module BABYLON {
  55450. /** @hidden */
  55451. export var _forceTransformFeedbackToBundle: boolean;
  55452. interface Engine {
  55453. /**
  55454. * Creates a webGL transform feedback object
  55455. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55456. * @returns the webGL transform feedback object
  55457. */
  55458. createTransformFeedback(): WebGLTransformFeedback;
  55459. /**
  55460. * Delete a webGL transform feedback object
  55461. * @param value defines the webGL transform feedback object to delete
  55462. */
  55463. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55464. /**
  55465. * Bind a webGL transform feedback object to the webgl context
  55466. * @param value defines the webGL transform feedback object to bind
  55467. */
  55468. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55469. /**
  55470. * Begins a transform feedback operation
  55471. * @param usePoints defines if points or triangles must be used
  55472. */
  55473. beginTransformFeedback(usePoints: boolean): void;
  55474. /**
  55475. * Ends a transform feedback operation
  55476. */
  55477. endTransformFeedback(): void;
  55478. /**
  55479. * Specify the varyings to use with transform feedback
  55480. * @param program defines the associated webGL program
  55481. * @param value defines the list of strings representing the varying names
  55482. */
  55483. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55484. /**
  55485. * Bind a webGL buffer for a transform feedback operation
  55486. * @param value defines the webGL buffer to bind
  55487. */
  55488. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55489. }
  55490. }
  55491. declare module BABYLON {
  55492. /**
  55493. * Class used to define an additional view for the engine
  55494. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55495. */
  55496. export class EngineView {
  55497. /** Defines the canvas where to render the view */
  55498. target: HTMLCanvasElement;
  55499. /** Defines an optional camera used to render the view (will use active camera else) */
  55500. camera?: Camera;
  55501. }
  55502. interface Engine {
  55503. /**
  55504. * Gets or sets the HTML element to use for attaching events
  55505. */
  55506. inputElement: Nullable<HTMLElement>;
  55507. /**
  55508. * Gets the current engine view
  55509. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55510. */
  55511. activeView: Nullable<EngineView>;
  55512. /** Gets or sets the list of views */
  55513. views: EngineView[];
  55514. /**
  55515. * Register a new child canvas
  55516. * @param canvas defines the canvas to register
  55517. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55518. * @returns the associated view
  55519. */
  55520. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55521. /**
  55522. * Remove a registered child canvas
  55523. * @param canvas defines the canvas to remove
  55524. * @returns the current engine
  55525. */
  55526. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55527. }
  55528. }
  55529. declare module BABYLON {
  55530. interface Engine {
  55531. /** @hidden */
  55532. _excludedCompressedTextures: string[];
  55533. /** @hidden */
  55534. _textureFormatInUse: string;
  55535. /**
  55536. * Gets the list of texture formats supported
  55537. */
  55538. readonly texturesSupported: Array<string>;
  55539. /**
  55540. * Gets the texture format in use
  55541. */
  55542. readonly textureFormatInUse: Nullable<string>;
  55543. /**
  55544. * Set the compressed texture extensions or file names to skip.
  55545. *
  55546. * @param skippedFiles defines the list of those texture files you want to skip
  55547. * Example: [".dds", ".env", "myfile.png"]
  55548. */
  55549. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55550. /**
  55551. * Set the compressed texture format to use, based on the formats you have, and the formats
  55552. * supported by the hardware / browser.
  55553. *
  55554. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55555. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55556. * to API arguments needed to compressed textures. This puts the burden on the container
  55557. * generator to house the arcane code for determining these for current & future formats.
  55558. *
  55559. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55560. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55561. *
  55562. * Note: The result of this call is not taken into account when a texture is base64.
  55563. *
  55564. * @param formatsAvailable defines the list of those format families you have created
  55565. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55566. *
  55567. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55568. * @returns The extension selected.
  55569. */
  55570. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55571. }
  55572. }
  55573. declare module BABYLON {
  55574. /** @hidden */
  55575. export var rgbdEncodePixelShader: {
  55576. name: string;
  55577. shader: string;
  55578. };
  55579. }
  55580. declare module BABYLON {
  55581. /**
  55582. * Raw texture data and descriptor sufficient for WebGL texture upload
  55583. */
  55584. export interface EnvironmentTextureInfo {
  55585. /**
  55586. * Version of the environment map
  55587. */
  55588. version: number;
  55589. /**
  55590. * Width of image
  55591. */
  55592. width: number;
  55593. /**
  55594. * Irradiance information stored in the file.
  55595. */
  55596. irradiance: any;
  55597. /**
  55598. * Specular information stored in the file.
  55599. */
  55600. specular: any;
  55601. }
  55602. /**
  55603. * Defines One Image in the file. It requires only the position in the file
  55604. * as well as the length.
  55605. */
  55606. interface BufferImageData {
  55607. /**
  55608. * Length of the image data.
  55609. */
  55610. length: number;
  55611. /**
  55612. * Position of the data from the null terminator delimiting the end of the JSON.
  55613. */
  55614. position: number;
  55615. }
  55616. /**
  55617. * Defines the specular data enclosed in the file.
  55618. * This corresponds to the version 1 of the data.
  55619. */
  55620. export interface EnvironmentTextureSpecularInfoV1 {
  55621. /**
  55622. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55623. */
  55624. specularDataPosition?: number;
  55625. /**
  55626. * This contains all the images data needed to reconstruct the cubemap.
  55627. */
  55628. mipmaps: Array<BufferImageData>;
  55629. /**
  55630. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55631. */
  55632. lodGenerationScale: number;
  55633. }
  55634. /**
  55635. * Sets of helpers addressing the serialization and deserialization of environment texture
  55636. * stored in a BabylonJS env file.
  55637. * Those files are usually stored as .env files.
  55638. */
  55639. export class EnvironmentTextureTools {
  55640. /**
  55641. * Magic number identifying the env file.
  55642. */
  55643. private static _MagicBytes;
  55644. /**
  55645. * Gets the environment info from an env file.
  55646. * @param data The array buffer containing the .env bytes.
  55647. * @returns the environment file info (the json header) if successfully parsed.
  55648. */
  55649. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55650. /**
  55651. * Creates an environment texture from a loaded cube texture.
  55652. * @param texture defines the cube texture to convert in env file
  55653. * @return a promise containing the environment data if succesfull.
  55654. */
  55655. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55656. /**
  55657. * Creates a JSON representation of the spherical data.
  55658. * @param texture defines the texture containing the polynomials
  55659. * @return the JSON representation of the spherical info
  55660. */
  55661. private static _CreateEnvTextureIrradiance;
  55662. /**
  55663. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55664. * @param data the image data
  55665. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55666. * @return the views described by info providing access to the underlying buffer
  55667. */
  55668. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55669. /**
  55670. * Uploads the texture info contained in the env file to the GPU.
  55671. * @param texture defines the internal texture to upload to
  55672. * @param data defines the data to load
  55673. * @param info defines the texture info retrieved through the GetEnvInfo method
  55674. * @returns a promise
  55675. */
  55676. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55677. private static _OnImageReadyAsync;
  55678. /**
  55679. * Uploads the levels of image data to the GPU.
  55680. * @param texture defines the internal texture to upload to
  55681. * @param imageData defines the array buffer views of image data [mipmap][face]
  55682. * @returns a promise
  55683. */
  55684. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55685. /**
  55686. * Uploads spherical polynomials information to the texture.
  55687. * @param texture defines the texture we are trying to upload the information to
  55688. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55689. */
  55690. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55691. /** @hidden */
  55692. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55693. }
  55694. }
  55695. declare module BABYLON {
  55696. /**
  55697. * Class used to inline functions in shader code
  55698. */
  55699. export class ShaderCodeInliner {
  55700. private static readonly _RegexpFindFunctionNameAndType;
  55701. private _sourceCode;
  55702. private _functionDescr;
  55703. private _numMaxIterations;
  55704. /** Gets or sets the token used to mark the functions to inline */
  55705. inlineToken: string;
  55706. /** Gets or sets the debug mode */
  55707. debug: boolean;
  55708. /** Gets the code after the inlining process */
  55709. get code(): string;
  55710. /**
  55711. * Initializes the inliner
  55712. * @param sourceCode shader code source to inline
  55713. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55714. */
  55715. constructor(sourceCode: string, numMaxIterations?: number);
  55716. /**
  55717. * Start the processing of the shader code
  55718. */
  55719. processCode(): void;
  55720. private _collectFunctions;
  55721. private _processInlining;
  55722. private _extractBetweenMarkers;
  55723. private _skipWhitespaces;
  55724. private _removeComments;
  55725. private _replaceFunctionCallsByCode;
  55726. private _findBackward;
  55727. private _escapeRegExp;
  55728. private _replaceNames;
  55729. }
  55730. }
  55731. declare module BABYLON {
  55732. /**
  55733. * Container for accessors for natively-stored mesh data buffers.
  55734. */
  55735. class NativeDataBuffer extends DataBuffer {
  55736. /**
  55737. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55738. */
  55739. nativeIndexBuffer?: any;
  55740. /**
  55741. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55742. */
  55743. nativeVertexBuffer?: any;
  55744. }
  55745. /** @hidden */
  55746. class NativeTexture extends InternalTexture {
  55747. getInternalTexture(): InternalTexture;
  55748. getViewCount(): number;
  55749. }
  55750. /** @hidden */
  55751. export class NativeEngine extends Engine {
  55752. private readonly _native;
  55753. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55754. private readonly INVALID_HANDLE;
  55755. private _boundBuffersVertexArray;
  55756. private _currentDepthTest;
  55757. getHardwareScalingLevel(): number;
  55758. constructor();
  55759. dispose(): void;
  55760. /**
  55761. * Can be used to override the current requestAnimationFrame requester.
  55762. * @hidden
  55763. */
  55764. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55765. /**
  55766. * Override default engine behavior.
  55767. * @param color
  55768. * @param backBuffer
  55769. * @param depth
  55770. * @param stencil
  55771. */
  55772. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55773. /**
  55774. * Gets host document
  55775. * @returns the host document object
  55776. */
  55777. getHostDocument(): Nullable<Document>;
  55778. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55779. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55780. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55781. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55782. [key: string]: VertexBuffer;
  55783. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55784. bindBuffers(vertexBuffers: {
  55785. [key: string]: VertexBuffer;
  55786. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55787. recordVertexArrayObject(vertexBuffers: {
  55788. [key: string]: VertexBuffer;
  55789. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55790. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55791. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55792. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55793. /**
  55794. * Draw a list of indexed primitives
  55795. * @param fillMode defines the primitive to use
  55796. * @param indexStart defines the starting index
  55797. * @param indexCount defines the number of index to draw
  55798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55799. */
  55800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55801. /**
  55802. * Draw a list of unindexed primitives
  55803. * @param fillMode defines the primitive to use
  55804. * @param verticesStart defines the index of first vertex to draw
  55805. * @param verticesCount defines the count of vertices to draw
  55806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55807. */
  55808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55809. createPipelineContext(): IPipelineContext;
  55810. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55811. /** @hidden */
  55812. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55813. /** @hidden */
  55814. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55815. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55816. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55817. protected _setProgram(program: WebGLProgram): void;
  55818. _releaseEffect(effect: Effect): void;
  55819. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55820. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55821. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55822. bindSamplers(effect: Effect): void;
  55823. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55824. getRenderWidth(useScreen?: boolean): number;
  55825. getRenderHeight(useScreen?: boolean): number;
  55826. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55827. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55828. /**
  55829. * Set the z offset to apply to current rendering
  55830. * @param value defines the offset to apply
  55831. */
  55832. setZOffset(value: number): void;
  55833. /**
  55834. * Gets the current value of the zOffset
  55835. * @returns the current zOffset state
  55836. */
  55837. getZOffset(): number;
  55838. /**
  55839. * Enable or disable depth buffering
  55840. * @param enable defines the state to set
  55841. */
  55842. setDepthBuffer(enable: boolean): void;
  55843. /**
  55844. * Gets a boolean indicating if depth writing is enabled
  55845. * @returns the current depth writing state
  55846. */
  55847. getDepthWrite(): boolean;
  55848. setDepthFunctionToGreater(): void;
  55849. setDepthFunctionToGreaterOrEqual(): void;
  55850. setDepthFunctionToLess(): void;
  55851. setDepthFunctionToLessOrEqual(): void;
  55852. /**
  55853. * Enable or disable depth writing
  55854. * @param enable defines the state to set
  55855. */
  55856. setDepthWrite(enable: boolean): void;
  55857. /**
  55858. * Enable or disable color writing
  55859. * @param enable defines the state to set
  55860. */
  55861. setColorWrite(enable: boolean): void;
  55862. /**
  55863. * Gets a boolean indicating if color writing is enabled
  55864. * @returns the current color writing state
  55865. */
  55866. getColorWrite(): boolean;
  55867. /**
  55868. * Sets alpha constants used by some alpha blending modes
  55869. * @param r defines the red component
  55870. * @param g defines the green component
  55871. * @param b defines the blue component
  55872. * @param a defines the alpha component
  55873. */
  55874. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55875. /**
  55876. * Sets the current alpha mode
  55877. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55878. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55879. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55880. */
  55881. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55882. /**
  55883. * Gets the current alpha mode
  55884. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55885. * @returns the current alpha mode
  55886. */
  55887. getAlphaMode(): number;
  55888. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55889. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55890. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55891. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55892. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55893. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55894. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55895. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55896. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55897. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55898. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55899. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55900. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55901. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55902. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55903. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55904. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55905. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55906. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55907. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55908. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55909. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55910. wipeCaches(bruteForce?: boolean): void;
  55911. _createTexture(): WebGLTexture;
  55912. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55913. /**
  55914. * Update the content of a dynamic texture
  55915. * @param texture defines the texture to update
  55916. * @param canvas defines the canvas containing the source
  55917. * @param invertY defines if data must be stored with Y axis inverted
  55918. * @param premulAlpha defines if alpha is stored as premultiplied
  55919. * @param format defines the format of the data
  55920. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55921. */
  55922. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55923. /**
  55924. * Usually called from Texture.ts.
  55925. * Passed information to create a WebGLTexture
  55926. * @param url defines a value which contains one of the following:
  55927. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55928. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55929. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55931. * @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)
  55932. * @param scene needed for loading to the correct scene
  55933. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55934. * @param onLoad optional callback to be called upon successful completion
  55935. * @param onError optional callback to be called upon failure
  55936. * @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
  55937. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55938. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55939. * @param forcedExtension defines the extension to use to pick the right loader
  55940. * @param mimeType defines an optional mime type
  55941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55942. */
  55943. 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): InternalTexture;
  55944. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55945. _releaseFramebufferObjects(texture: InternalTexture): void;
  55946. /**
  55947. * Creates a cube texture
  55948. * @param rootUrl defines the url where the files to load is located
  55949. * @param scene defines the current scene
  55950. * @param files defines the list of files to load (1 per face)
  55951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55952. * @param onLoad defines an optional callback raised when the texture is loaded
  55953. * @param onError defines an optional callback raised if there is an issue to load the texture
  55954. * @param format defines the format of the data
  55955. * @param forcedExtension defines the extension to use to pick the right loader
  55956. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55957. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55958. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55959. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55960. * @returns the cube texture as an InternalTexture
  55961. */
  55962. 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;
  55963. createRenderTargetTexture(size: number | {
  55964. width: number;
  55965. height: number;
  55966. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55968. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55969. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55970. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55971. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55972. /**
  55973. * Updates a dynamic vertex buffer.
  55974. * @param vertexBuffer the vertex buffer to update
  55975. * @param data the data used to update the vertex buffer
  55976. * @param byteOffset the byte offset of the data (optional)
  55977. * @param byteLength the byte length of the data (optional)
  55978. */
  55979. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55980. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55981. private _updateAnisotropicLevel;
  55982. private _getAddressMode;
  55983. /** @hidden */
  55984. _bindTexture(channel: number, texture: InternalTexture): void;
  55985. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55986. releaseEffects(): void;
  55987. /** @hidden */
  55988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55989. /** @hidden */
  55990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55991. /** @hidden */
  55992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55993. /** @hidden */
  55994. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55995. private _getNativeSamplingMode;
  55996. private _getNativeTextureFormat;
  55997. private _getNativeAlphaMode;
  55998. private _getNativeAttribType;
  55999. }
  56000. }
  56001. declare module BABYLON {
  56002. /**
  56003. * Gather the list of clipboard event types as constants.
  56004. */
  56005. export class ClipboardEventTypes {
  56006. /**
  56007. * The clipboard event is fired when a copy command is active (pressed).
  56008. */
  56009. static readonly COPY: number;
  56010. /**
  56011. * The clipboard event is fired when a cut command is active (pressed).
  56012. */
  56013. static readonly CUT: number;
  56014. /**
  56015. * The clipboard event is fired when a paste command is active (pressed).
  56016. */
  56017. static readonly PASTE: number;
  56018. }
  56019. /**
  56020. * This class is used to store clipboard related info for the onClipboardObservable event.
  56021. */
  56022. export class ClipboardInfo {
  56023. /**
  56024. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56025. */
  56026. type: number;
  56027. /**
  56028. * Defines the related dom event
  56029. */
  56030. event: ClipboardEvent;
  56031. /**
  56032. *Creates an instance of ClipboardInfo.
  56033. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56034. * @param event Defines the related dom event
  56035. */
  56036. constructor(
  56037. /**
  56038. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56039. */
  56040. type: number,
  56041. /**
  56042. * Defines the related dom event
  56043. */
  56044. event: ClipboardEvent);
  56045. /**
  56046. * Get the clipboard event's type from the keycode.
  56047. * @param keyCode Defines the keyCode for the current keyboard event.
  56048. * @return {number}
  56049. */
  56050. static GetTypeFromCharacter(keyCode: number): number;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Google Daydream controller
  56056. */
  56057. export class DaydreamController extends WebVRController {
  56058. /**
  56059. * Base Url for the controller model.
  56060. */
  56061. static MODEL_BASE_URL: string;
  56062. /**
  56063. * File name for the controller model.
  56064. */
  56065. static MODEL_FILENAME: string;
  56066. /**
  56067. * Gamepad Id prefix used to identify Daydream Controller.
  56068. */
  56069. static readonly GAMEPAD_ID_PREFIX: string;
  56070. /**
  56071. * Creates a new DaydreamController from a gamepad
  56072. * @param vrGamepad the gamepad that the controller should be created from
  56073. */
  56074. constructor(vrGamepad: any);
  56075. /**
  56076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56077. * @param scene scene in which to add meshes
  56078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56079. */
  56080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56081. /**
  56082. * Called once for each button that changed state since the last frame
  56083. * @param buttonIdx Which button index changed
  56084. * @param state New state of the button
  56085. * @param changes Which properties on the state changed since last frame
  56086. */
  56087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56088. }
  56089. }
  56090. declare module BABYLON {
  56091. /**
  56092. * Gear VR Controller
  56093. */
  56094. export class GearVRController extends WebVRController {
  56095. /**
  56096. * Base Url for the controller model.
  56097. */
  56098. static MODEL_BASE_URL: string;
  56099. /**
  56100. * File name for the controller model.
  56101. */
  56102. static MODEL_FILENAME: string;
  56103. /**
  56104. * Gamepad Id prefix used to identify this controller.
  56105. */
  56106. static readonly GAMEPAD_ID_PREFIX: string;
  56107. private readonly _buttonIndexToObservableNameMap;
  56108. /**
  56109. * Creates a new GearVRController from a gamepad
  56110. * @param vrGamepad the gamepad that the controller should be created from
  56111. */
  56112. constructor(vrGamepad: any);
  56113. /**
  56114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56115. * @param scene scene in which to add meshes
  56116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56117. */
  56118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56119. /**
  56120. * Called once for each button that changed state since the last frame
  56121. * @param buttonIdx Which button index changed
  56122. * @param state New state of the button
  56123. * @param changes Which properties on the state changed since last frame
  56124. */
  56125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56126. }
  56127. }
  56128. declare module BABYLON {
  56129. /**
  56130. * Generic Controller
  56131. */
  56132. export class GenericController extends WebVRController {
  56133. /**
  56134. * Base Url for the controller model.
  56135. */
  56136. static readonly MODEL_BASE_URL: string;
  56137. /**
  56138. * File name for the controller model.
  56139. */
  56140. static readonly MODEL_FILENAME: string;
  56141. /**
  56142. * Creates a new GenericController from a gamepad
  56143. * @param vrGamepad the gamepad that the controller should be created from
  56144. */
  56145. constructor(vrGamepad: any);
  56146. /**
  56147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56148. * @param scene scene in which to add meshes
  56149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56150. */
  56151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56152. /**
  56153. * Called once for each button that changed state since the last frame
  56154. * @param buttonIdx Which button index changed
  56155. * @param state New state of the button
  56156. * @param changes Which properties on the state changed since last frame
  56157. */
  56158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56159. }
  56160. }
  56161. declare module BABYLON {
  56162. /**
  56163. * Oculus Touch Controller
  56164. */
  56165. export class OculusTouchController extends WebVRController {
  56166. /**
  56167. * Base Url for the controller model.
  56168. */
  56169. static MODEL_BASE_URL: string;
  56170. /**
  56171. * File name for the left controller model.
  56172. */
  56173. static MODEL_LEFT_FILENAME: string;
  56174. /**
  56175. * File name for the right controller model.
  56176. */
  56177. static MODEL_RIGHT_FILENAME: string;
  56178. /**
  56179. * Base Url for the Quest controller model.
  56180. */
  56181. static QUEST_MODEL_BASE_URL: string;
  56182. /**
  56183. * @hidden
  56184. * If the controllers are running on a device that needs the updated Quest controller models
  56185. */
  56186. static _IsQuest: boolean;
  56187. /**
  56188. * Fired when the secondary trigger on this controller is modified
  56189. */
  56190. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56191. /**
  56192. * Fired when the thumb rest on this controller is modified
  56193. */
  56194. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56195. /**
  56196. * Creates a new OculusTouchController from a gamepad
  56197. * @param vrGamepad the gamepad that the controller should be created from
  56198. */
  56199. constructor(vrGamepad: any);
  56200. /**
  56201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56202. * @param scene scene in which to add meshes
  56203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56204. */
  56205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56206. /**
  56207. * Fired when the A button on this controller is modified
  56208. */
  56209. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56210. /**
  56211. * Fired when the B button on this controller is modified
  56212. */
  56213. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56214. /**
  56215. * Fired when the X button on this controller is modified
  56216. */
  56217. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56218. /**
  56219. * Fired when the Y button on this controller is modified
  56220. */
  56221. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56222. /**
  56223. * Called once for each button that changed state since the last frame
  56224. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56225. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56226. * 2) secondary trigger (same)
  56227. * 3) A (right) X (left), touch, pressed = value
  56228. * 4) B / Y
  56229. * 5) thumb rest
  56230. * @param buttonIdx Which button index changed
  56231. * @param state New state of the button
  56232. * @param changes Which properties on the state changed since last frame
  56233. */
  56234. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56235. }
  56236. }
  56237. declare module BABYLON {
  56238. /**
  56239. * Vive Controller
  56240. */
  56241. export class ViveController extends WebVRController {
  56242. /**
  56243. * Base Url for the controller model.
  56244. */
  56245. static MODEL_BASE_URL: string;
  56246. /**
  56247. * File name for the controller model.
  56248. */
  56249. static MODEL_FILENAME: string;
  56250. /**
  56251. * Creates a new ViveController from a gamepad
  56252. * @param vrGamepad the gamepad that the controller should be created from
  56253. */
  56254. constructor(vrGamepad: any);
  56255. /**
  56256. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56257. * @param scene scene in which to add meshes
  56258. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56259. */
  56260. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56261. /**
  56262. * Fired when the left button on this controller is modified
  56263. */
  56264. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56265. /**
  56266. * Fired when the right button on this controller is modified
  56267. */
  56268. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56269. /**
  56270. * Fired when the menu button on this controller is modified
  56271. */
  56272. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56273. /**
  56274. * Called once for each button that changed state since the last frame
  56275. * Vive mapping:
  56276. * 0: touchpad
  56277. * 1: trigger
  56278. * 2: left AND right buttons
  56279. * 3: menu button
  56280. * @param buttonIdx Which button index changed
  56281. * @param state New state of the button
  56282. * @param changes Which properties on the state changed since last frame
  56283. */
  56284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56285. }
  56286. }
  56287. declare module BABYLON {
  56288. /**
  56289. * Defines the WindowsMotionController object that the state of the windows motion controller
  56290. */
  56291. export class WindowsMotionController extends WebVRController {
  56292. /**
  56293. * The base url used to load the left and right controller models
  56294. */
  56295. static MODEL_BASE_URL: string;
  56296. /**
  56297. * The name of the left controller model file
  56298. */
  56299. static MODEL_LEFT_FILENAME: string;
  56300. /**
  56301. * The name of the right controller model file
  56302. */
  56303. static MODEL_RIGHT_FILENAME: string;
  56304. /**
  56305. * The controller name prefix for this controller type
  56306. */
  56307. static readonly GAMEPAD_ID_PREFIX: string;
  56308. /**
  56309. * The controller id pattern for this controller type
  56310. */
  56311. private static readonly GAMEPAD_ID_PATTERN;
  56312. private _loadedMeshInfo;
  56313. protected readonly _mapping: {
  56314. buttons: string[];
  56315. buttonMeshNames: {
  56316. trigger: string;
  56317. menu: string;
  56318. grip: string;
  56319. thumbstick: string;
  56320. trackpad: string;
  56321. };
  56322. buttonObservableNames: {
  56323. trigger: string;
  56324. menu: string;
  56325. grip: string;
  56326. thumbstick: string;
  56327. trackpad: string;
  56328. };
  56329. axisMeshNames: string[];
  56330. pointingPoseMeshName: string;
  56331. };
  56332. /**
  56333. * Fired when the trackpad on this controller is clicked
  56334. */
  56335. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56336. /**
  56337. * Fired when the trackpad on this controller is modified
  56338. */
  56339. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56340. /**
  56341. * The current x and y values of this controller's trackpad
  56342. */
  56343. trackpad: StickValues;
  56344. /**
  56345. * Creates a new WindowsMotionController from a gamepad
  56346. * @param vrGamepad the gamepad that the controller should be created from
  56347. */
  56348. constructor(vrGamepad: any);
  56349. /**
  56350. * Fired when the trigger on this controller is modified
  56351. */
  56352. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56353. /**
  56354. * Fired when the menu button on this controller is modified
  56355. */
  56356. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56357. /**
  56358. * Fired when the grip button on this controller is modified
  56359. */
  56360. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56361. /**
  56362. * Fired when the thumbstick button on this controller is modified
  56363. */
  56364. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56365. /**
  56366. * Fired when the touchpad button on this controller is modified
  56367. */
  56368. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56369. /**
  56370. * Fired when the touchpad values on this controller are modified
  56371. */
  56372. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56373. protected _updateTrackpad(): void;
  56374. /**
  56375. * Called once per frame by the engine.
  56376. */
  56377. update(): void;
  56378. /**
  56379. * Called once for each button that changed state since the last frame
  56380. * @param buttonIdx Which button index changed
  56381. * @param state New state of the button
  56382. * @param changes Which properties on the state changed since last frame
  56383. */
  56384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56385. /**
  56386. * Moves the buttons on the controller mesh based on their current state
  56387. * @param buttonName the name of the button to move
  56388. * @param buttonValue the value of the button which determines the buttons new position
  56389. */
  56390. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56391. /**
  56392. * Moves the axis on the controller mesh based on its current state
  56393. * @param axis the index of the axis
  56394. * @param axisValue the value of the axis which determines the meshes new position
  56395. * @hidden
  56396. */
  56397. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56398. /**
  56399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56400. * @param scene scene in which to add meshes
  56401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56402. */
  56403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56404. /**
  56405. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56406. * can be transformed by button presses and axes values, based on this._mapping.
  56407. *
  56408. * @param scene scene in which the meshes exist
  56409. * @param meshes list of meshes that make up the controller model to process
  56410. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56411. */
  56412. private processModel;
  56413. private createMeshInfo;
  56414. /**
  56415. * Gets the ray of the controller in the direction the controller is pointing
  56416. * @param length the length the resulting ray should be
  56417. * @returns a ray in the direction the controller is pointing
  56418. */
  56419. getForwardRay(length?: number): Ray;
  56420. /**
  56421. * Disposes of the controller
  56422. */
  56423. dispose(): void;
  56424. }
  56425. /**
  56426. * This class represents a new windows motion controller in XR.
  56427. */
  56428. export class XRWindowsMotionController extends WindowsMotionController {
  56429. /**
  56430. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56431. */
  56432. protected readonly _mapping: {
  56433. buttons: string[];
  56434. buttonMeshNames: {
  56435. trigger: string;
  56436. menu: string;
  56437. grip: string;
  56438. thumbstick: string;
  56439. trackpad: string;
  56440. };
  56441. buttonObservableNames: {
  56442. trigger: string;
  56443. menu: string;
  56444. grip: string;
  56445. thumbstick: string;
  56446. trackpad: string;
  56447. };
  56448. axisMeshNames: string[];
  56449. pointingPoseMeshName: string;
  56450. };
  56451. /**
  56452. * Construct a new XR-Based windows motion controller
  56453. *
  56454. * @param gamepadInfo the gamepad object from the browser
  56455. */
  56456. constructor(gamepadInfo: any);
  56457. /**
  56458. * holds the thumbstick values (X,Y)
  56459. */
  56460. thumbstickValues: StickValues;
  56461. /**
  56462. * Fired when the thumbstick on this controller is clicked
  56463. */
  56464. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56465. /**
  56466. * Fired when the thumbstick on this controller is modified
  56467. */
  56468. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56469. /**
  56470. * Fired when the touchpad button on this controller is modified
  56471. */
  56472. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56473. /**
  56474. * Fired when the touchpad values on this controller are modified
  56475. */
  56476. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56477. /**
  56478. * Fired when the thumbstick button on this controller is modified
  56479. * here to prevent breaking changes
  56480. */
  56481. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56482. /**
  56483. * updating the thumbstick(!) and not the trackpad.
  56484. * This is named this way due to the difference between WebVR and XR and to avoid
  56485. * changing the parent class.
  56486. */
  56487. protected _updateTrackpad(): void;
  56488. /**
  56489. * Disposes the class with joy
  56490. */
  56491. dispose(): void;
  56492. }
  56493. }
  56494. declare module BABYLON {
  56495. /**
  56496. * Class containing static functions to help procedurally build meshes
  56497. */
  56498. export class PolyhedronBuilder {
  56499. /**
  56500. * Creates a polyhedron mesh
  56501. * * 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
  56502. * * The parameter `size` (positive float, default 1) sets the polygon size
  56503. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56504. * * 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`
  56505. * * 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
  56506. * * 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)`)
  56507. * * 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
  56508. * * 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
  56509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56510. * * 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
  56511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56512. * @param name defines the name of the mesh
  56513. * @param options defines the options used to create the mesh
  56514. * @param scene defines the hosting scene
  56515. * @returns the polyhedron mesh
  56516. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56517. */
  56518. static CreatePolyhedron(name: string, options: {
  56519. type?: number;
  56520. size?: number;
  56521. sizeX?: number;
  56522. sizeY?: number;
  56523. sizeZ?: number;
  56524. custom?: any;
  56525. faceUV?: Vector4[];
  56526. faceColors?: Color4[];
  56527. flat?: boolean;
  56528. updatable?: boolean;
  56529. sideOrientation?: number;
  56530. frontUVs?: Vector4;
  56531. backUVs?: Vector4;
  56532. }, scene?: Nullable<Scene>): Mesh;
  56533. }
  56534. }
  56535. declare module BABYLON {
  56536. /**
  56537. * Gizmo that enables scaling a mesh along 3 axis
  56538. */
  56539. export class ScaleGizmo extends Gizmo {
  56540. /**
  56541. * Internal gizmo used for interactions on the x axis
  56542. */
  56543. xGizmo: AxisScaleGizmo;
  56544. /**
  56545. * Internal gizmo used for interactions on the y axis
  56546. */
  56547. yGizmo: AxisScaleGizmo;
  56548. /**
  56549. * Internal gizmo used for interactions on the z axis
  56550. */
  56551. zGizmo: AxisScaleGizmo;
  56552. /**
  56553. * Internal gizmo used to scale all axis equally
  56554. */
  56555. uniformScaleGizmo: AxisScaleGizmo;
  56556. private _meshAttached;
  56557. private _nodeAttached;
  56558. private _snapDistance;
  56559. private _uniformScalingMesh;
  56560. private _octahedron;
  56561. private _sensitivity;
  56562. /** Fires an event when any of it's sub gizmos are dragged */
  56563. onDragStartObservable: Observable<unknown>;
  56564. /** Fires an event when any of it's sub gizmos are released from dragging */
  56565. onDragEndObservable: Observable<unknown>;
  56566. get attachedMesh(): Nullable<AbstractMesh>;
  56567. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56568. get attachedNode(): Nullable<Node>;
  56569. set attachedNode(node: Nullable<Node>);
  56570. /**
  56571. * True when the mouse pointer is hovering a gizmo mesh
  56572. */
  56573. get isHovered(): boolean;
  56574. /**
  56575. * Creates a ScaleGizmo
  56576. * @param gizmoLayer The utility layer the gizmo will be added to
  56577. * @param thickness display gizmo axis thickness
  56578. */
  56579. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56580. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56581. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56582. /**
  56583. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56584. */
  56585. set snapDistance(value: number);
  56586. get snapDistance(): number;
  56587. /**
  56588. * Ratio for the scale of the gizmo (Default: 1)
  56589. */
  56590. set scaleRatio(value: number);
  56591. get scaleRatio(): number;
  56592. /**
  56593. * Sensitivity factor for dragging (Default: 1)
  56594. */
  56595. set sensitivity(value: number);
  56596. get sensitivity(): number;
  56597. /**
  56598. * Disposes of the gizmo
  56599. */
  56600. dispose(): void;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /**
  56605. * Single axis scale gizmo
  56606. */
  56607. export class AxisScaleGizmo extends Gizmo {
  56608. /**
  56609. * Drag behavior responsible for the gizmos dragging interactions
  56610. */
  56611. dragBehavior: PointerDragBehavior;
  56612. private _pointerObserver;
  56613. /**
  56614. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56615. */
  56616. snapDistance: number;
  56617. /**
  56618. * Event that fires each time the gizmo snaps to a new location.
  56619. * * snapDistance is the the change in distance
  56620. */
  56621. onSnapObservable: Observable<{
  56622. snapDistance: number;
  56623. }>;
  56624. /**
  56625. * If the scaling operation should be done on all axis (default: false)
  56626. */
  56627. uniformScaling: boolean;
  56628. /**
  56629. * Custom sensitivity value for the drag strength
  56630. */
  56631. sensitivity: number;
  56632. private _isEnabled;
  56633. private _parent;
  56634. private _arrow;
  56635. private _coloredMaterial;
  56636. private _hoverMaterial;
  56637. /**
  56638. * Creates an AxisScaleGizmo
  56639. * @param gizmoLayer The utility layer the gizmo will be added to
  56640. * @param dragAxis The axis which the gizmo will be able to scale on
  56641. * @param color The color of the gizmo
  56642. * @param thickness display gizmo axis thickness
  56643. */
  56644. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56645. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56646. /**
  56647. * If the gizmo is enabled
  56648. */
  56649. set isEnabled(value: boolean);
  56650. get isEnabled(): boolean;
  56651. /**
  56652. * Disposes of the gizmo
  56653. */
  56654. dispose(): void;
  56655. /**
  56656. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56657. * @param mesh The mesh to replace the default mesh of the gizmo
  56658. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56659. */
  56660. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56661. }
  56662. }
  56663. declare module BABYLON {
  56664. /**
  56665. * Bounding box gizmo
  56666. */
  56667. export class BoundingBoxGizmo extends Gizmo {
  56668. private _lineBoundingBox;
  56669. private _rotateSpheresParent;
  56670. private _scaleBoxesParent;
  56671. private _boundingDimensions;
  56672. private _renderObserver;
  56673. private _pointerObserver;
  56674. private _scaleDragSpeed;
  56675. private _tmpQuaternion;
  56676. private _tmpVector;
  56677. private _tmpRotationMatrix;
  56678. /**
  56679. * 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)
  56680. */
  56681. ignoreChildren: boolean;
  56682. /**
  56683. * 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)
  56684. */
  56685. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56686. /**
  56687. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56688. */
  56689. rotationSphereSize: number;
  56690. /**
  56691. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56692. */
  56693. scaleBoxSize: number;
  56694. /**
  56695. * 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)
  56696. */
  56697. fixedDragMeshScreenSize: boolean;
  56698. /**
  56699. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56700. */
  56701. fixedDragMeshScreenSizeDistanceFactor: number;
  56702. /**
  56703. * Fired when a rotation sphere or scale box is dragged
  56704. */
  56705. onDragStartObservable: Observable<{}>;
  56706. /**
  56707. * Fired when a scale box is dragged
  56708. */
  56709. onScaleBoxDragObservable: Observable<{}>;
  56710. /**
  56711. * Fired when a scale box drag is ended
  56712. */
  56713. onScaleBoxDragEndObservable: Observable<{}>;
  56714. /**
  56715. * Fired when a rotation sphere is dragged
  56716. */
  56717. onRotationSphereDragObservable: Observable<{}>;
  56718. /**
  56719. * Fired when a rotation sphere drag is ended
  56720. */
  56721. onRotationSphereDragEndObservable: Observable<{}>;
  56722. /**
  56723. * 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)
  56724. */
  56725. scalePivot: Nullable<Vector3>;
  56726. /**
  56727. * Mesh used as a pivot to rotate the attached node
  56728. */
  56729. private _anchorMesh;
  56730. private _existingMeshScale;
  56731. private _dragMesh;
  56732. private pointerDragBehavior;
  56733. private coloredMaterial;
  56734. private hoverColoredMaterial;
  56735. /**
  56736. * Sets the color of the bounding box gizmo
  56737. * @param color the color to set
  56738. */
  56739. setColor(color: Color3): void;
  56740. /**
  56741. * Creates an BoundingBoxGizmo
  56742. * @param gizmoLayer The utility layer the gizmo will be added to
  56743. * @param color The color of the gizmo
  56744. */
  56745. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56746. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56747. private _selectNode;
  56748. /**
  56749. * Updates the bounding box information for the Gizmo
  56750. */
  56751. updateBoundingBox(): void;
  56752. private _updateRotationSpheres;
  56753. private _updateScaleBoxes;
  56754. /**
  56755. * Enables rotation on the specified axis and disables rotation on the others
  56756. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56757. */
  56758. setEnabledRotationAxis(axis: string): void;
  56759. /**
  56760. * Enables/disables scaling
  56761. * @param enable if scaling should be enabled
  56762. * @param homogeneousScaling defines if scaling should only be homogeneous
  56763. */
  56764. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56765. private _updateDummy;
  56766. /**
  56767. * Enables a pointer drag behavior on the bounding box of the gizmo
  56768. */
  56769. enableDragBehavior(): void;
  56770. /**
  56771. * Disposes of the gizmo
  56772. */
  56773. dispose(): void;
  56774. /**
  56775. * 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)
  56776. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56777. * @returns the bounding box mesh with the passed in mesh as a child
  56778. */
  56779. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56780. /**
  56781. * CustomMeshes are not supported by this gizmo
  56782. * @param mesh The mesh to replace the default mesh of the gizmo
  56783. */
  56784. setCustomMesh(mesh: Mesh): void;
  56785. }
  56786. }
  56787. declare module BABYLON {
  56788. /**
  56789. * Single plane rotation gizmo
  56790. */
  56791. export class PlaneRotationGizmo extends Gizmo {
  56792. /**
  56793. * Drag behavior responsible for the gizmos dragging interactions
  56794. */
  56795. dragBehavior: PointerDragBehavior;
  56796. private _pointerObserver;
  56797. /**
  56798. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56799. */
  56800. snapDistance: number;
  56801. /**
  56802. * Event that fires each time the gizmo snaps to a new location.
  56803. * * snapDistance is the the change in distance
  56804. */
  56805. onSnapObservable: Observable<{
  56806. snapDistance: number;
  56807. }>;
  56808. private _isEnabled;
  56809. private _parent;
  56810. /**
  56811. * Creates a PlaneRotationGizmo
  56812. * @param gizmoLayer The utility layer the gizmo will be added to
  56813. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56814. * @param color The color of the gizmo
  56815. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56816. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56817. * @param thickness display gizmo axis thickness
  56818. */
  56819. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56820. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56821. /**
  56822. * If the gizmo is enabled
  56823. */
  56824. set isEnabled(value: boolean);
  56825. get isEnabled(): boolean;
  56826. /**
  56827. * Disposes of the gizmo
  56828. */
  56829. dispose(): void;
  56830. }
  56831. }
  56832. declare module BABYLON {
  56833. /**
  56834. * Gizmo that enables rotating a mesh along 3 axis
  56835. */
  56836. export class RotationGizmo extends Gizmo {
  56837. /**
  56838. * Internal gizmo used for interactions on the x axis
  56839. */
  56840. xGizmo: PlaneRotationGizmo;
  56841. /**
  56842. * Internal gizmo used for interactions on the y axis
  56843. */
  56844. yGizmo: PlaneRotationGizmo;
  56845. /**
  56846. * Internal gizmo used for interactions on the z axis
  56847. */
  56848. zGizmo: PlaneRotationGizmo;
  56849. /** Fires an event when any of it's sub gizmos are dragged */
  56850. onDragStartObservable: Observable<unknown>;
  56851. /** Fires an event when any of it's sub gizmos are released from dragging */
  56852. onDragEndObservable: Observable<unknown>;
  56853. private _meshAttached;
  56854. private _nodeAttached;
  56855. get attachedMesh(): Nullable<AbstractMesh>;
  56856. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56857. get attachedNode(): Nullable<Node>;
  56858. set attachedNode(node: Nullable<Node>);
  56859. protected _checkBillboardTransform(): void;
  56860. /**
  56861. * True when the mouse pointer is hovering a gizmo mesh
  56862. */
  56863. get isHovered(): boolean;
  56864. /**
  56865. * Creates a RotationGizmo
  56866. * @param gizmoLayer The utility layer the gizmo will be added to
  56867. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56868. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56869. * @param thickness display gizmo axis thickness
  56870. */
  56871. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56872. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56873. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56874. /**
  56875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56876. */
  56877. set snapDistance(value: number);
  56878. get snapDistance(): number;
  56879. /**
  56880. * Ratio for the scale of the gizmo (Default: 1)
  56881. */
  56882. set scaleRatio(value: number);
  56883. get scaleRatio(): number;
  56884. /**
  56885. * Disposes of the gizmo
  56886. */
  56887. dispose(): void;
  56888. /**
  56889. * CustomMeshes are not supported by this gizmo
  56890. * @param mesh The mesh to replace the default mesh of the gizmo
  56891. */
  56892. setCustomMesh(mesh: Mesh): void;
  56893. }
  56894. }
  56895. declare module BABYLON {
  56896. /**
  56897. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56898. */
  56899. export class GizmoManager implements IDisposable {
  56900. private scene;
  56901. /**
  56902. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56903. */
  56904. gizmos: {
  56905. positionGizmo: Nullable<PositionGizmo>;
  56906. rotationGizmo: Nullable<RotationGizmo>;
  56907. scaleGizmo: Nullable<ScaleGizmo>;
  56908. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56909. };
  56910. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56911. clearGizmoOnEmptyPointerEvent: boolean;
  56912. /** Fires an event when the manager is attached to a mesh */
  56913. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56914. /** Fires an event when the manager is attached to a node */
  56915. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56916. private _gizmosEnabled;
  56917. private _pointerObserver;
  56918. private _attachedMesh;
  56919. private _attachedNode;
  56920. private _boundingBoxColor;
  56921. private _defaultUtilityLayer;
  56922. private _defaultKeepDepthUtilityLayer;
  56923. private _thickness;
  56924. /**
  56925. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56926. */
  56927. boundingBoxDragBehavior: SixDofDragBehavior;
  56928. /**
  56929. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56930. */
  56931. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56932. /**
  56933. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56934. */
  56935. attachableNodes: Nullable<Array<Node>>;
  56936. /**
  56937. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56938. */
  56939. usePointerToAttachGizmos: boolean;
  56940. /**
  56941. * Utility layer that the bounding box gizmo belongs to
  56942. */
  56943. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56944. /**
  56945. * Utility layer that all gizmos besides bounding box belong to
  56946. */
  56947. get utilityLayer(): UtilityLayerRenderer;
  56948. /**
  56949. * True when the mouse pointer is hovering a gizmo mesh
  56950. */
  56951. get isHovered(): boolean;
  56952. /**
  56953. * Instatiates a gizmo manager
  56954. * @param scene the scene to overlay the gizmos on top of
  56955. * @param thickness display gizmo axis thickness
  56956. */
  56957. constructor(scene: Scene, thickness?: number);
  56958. /**
  56959. * Attaches a set of gizmos to the specified mesh
  56960. * @param mesh The mesh the gizmo's should be attached to
  56961. */
  56962. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56963. /**
  56964. * Attaches a set of gizmos to the specified node
  56965. * @param node The node the gizmo's should be attached to
  56966. */
  56967. attachToNode(node: Nullable<Node>): void;
  56968. /**
  56969. * If the position gizmo is enabled
  56970. */
  56971. set positionGizmoEnabled(value: boolean);
  56972. get positionGizmoEnabled(): boolean;
  56973. /**
  56974. * If the rotation gizmo is enabled
  56975. */
  56976. set rotationGizmoEnabled(value: boolean);
  56977. get rotationGizmoEnabled(): boolean;
  56978. /**
  56979. * If the scale gizmo is enabled
  56980. */
  56981. set scaleGizmoEnabled(value: boolean);
  56982. get scaleGizmoEnabled(): boolean;
  56983. /**
  56984. * If the boundingBox gizmo is enabled
  56985. */
  56986. set boundingBoxGizmoEnabled(value: boolean);
  56987. get boundingBoxGizmoEnabled(): boolean;
  56988. /**
  56989. * Disposes of the gizmo manager
  56990. */
  56991. dispose(): void;
  56992. }
  56993. }
  56994. declare module BABYLON {
  56995. /**
  56996. * A directional light is defined by a direction (what a surprise!).
  56997. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56998. * 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.
  56999. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57000. */
  57001. export class DirectionalLight extends ShadowLight {
  57002. private _shadowFrustumSize;
  57003. /**
  57004. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57005. */
  57006. get shadowFrustumSize(): number;
  57007. /**
  57008. * Specifies a fix frustum size for the shadow generation.
  57009. */
  57010. set shadowFrustumSize(value: number);
  57011. private _shadowOrthoScale;
  57012. /**
  57013. * Gets the shadow projection scale against the optimal computed one.
  57014. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57015. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57016. */
  57017. get shadowOrthoScale(): number;
  57018. /**
  57019. * Sets the shadow projection scale against the optimal computed one.
  57020. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57021. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57022. */
  57023. set shadowOrthoScale(value: number);
  57024. /**
  57025. * Automatically compute the projection matrix to best fit (including all the casters)
  57026. * on each frame.
  57027. */
  57028. autoUpdateExtends: boolean;
  57029. /**
  57030. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57031. * on each frame. autoUpdateExtends must be set to true for this to work
  57032. */
  57033. autoCalcShadowZBounds: boolean;
  57034. private _orthoLeft;
  57035. private _orthoRight;
  57036. private _orthoTop;
  57037. private _orthoBottom;
  57038. /**
  57039. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57040. * The directional light is emitted from everywhere in the given direction.
  57041. * It can cast shadows.
  57042. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57043. * @param name The friendly name of the light
  57044. * @param direction The direction of the light
  57045. * @param scene The scene the light belongs to
  57046. */
  57047. constructor(name: string, direction: Vector3, scene: Scene);
  57048. /**
  57049. * Returns the string "DirectionalLight".
  57050. * @return The class name
  57051. */
  57052. getClassName(): string;
  57053. /**
  57054. * Returns the integer 1.
  57055. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57056. */
  57057. getTypeID(): number;
  57058. /**
  57059. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57060. * Returns the DirectionalLight Shadow projection matrix.
  57061. */
  57062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57063. /**
  57064. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57065. * Returns the DirectionalLight Shadow projection matrix.
  57066. */
  57067. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57068. /**
  57069. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57070. * Returns the DirectionalLight Shadow projection matrix.
  57071. */
  57072. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57073. protected _buildUniformLayout(): void;
  57074. /**
  57075. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57076. * @param effect The effect to update
  57077. * @param lightIndex The index of the light in the effect to update
  57078. * @returns The directional light
  57079. */
  57080. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57082. /**
  57083. * Gets the minZ used for shadow according to both the scene and the light.
  57084. *
  57085. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57086. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57087. * @param activeCamera The camera we are returning the min for
  57088. * @returns the depth min z
  57089. */
  57090. getDepthMinZ(activeCamera: Camera): number;
  57091. /**
  57092. * Gets the maxZ used for shadow according to both the scene and the light.
  57093. *
  57094. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57095. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57096. * @param activeCamera The camera we are returning the max for
  57097. * @returns the depth max z
  57098. */
  57099. getDepthMaxZ(activeCamera: Camera): number;
  57100. /**
  57101. * Prepares the list of defines specific to the light type.
  57102. * @param defines the list of defines
  57103. * @param lightIndex defines the index of the light for the effect
  57104. */
  57105. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57106. }
  57107. }
  57108. declare module BABYLON {
  57109. /**
  57110. * Class containing static functions to help procedurally build meshes
  57111. */
  57112. export class HemisphereBuilder {
  57113. /**
  57114. * Creates a hemisphere mesh
  57115. * @param name defines the name of the mesh
  57116. * @param options defines the options used to create the mesh
  57117. * @param scene defines the hosting scene
  57118. * @returns the hemisphere mesh
  57119. */
  57120. static CreateHemisphere(name: string, options: {
  57121. segments?: number;
  57122. diameter?: number;
  57123. sideOrientation?: number;
  57124. }, scene: any): Mesh;
  57125. }
  57126. }
  57127. declare module BABYLON {
  57128. /**
  57129. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57130. * These values define a cone of light starting from the position, emitting toward the direction.
  57131. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57132. * and the exponent defines the speed of the decay of the light with distance (reach).
  57133. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57134. */
  57135. export class SpotLight extends ShadowLight {
  57136. private _angle;
  57137. private _innerAngle;
  57138. private _cosHalfAngle;
  57139. private _lightAngleScale;
  57140. private _lightAngleOffset;
  57141. /**
  57142. * Gets the cone angle of the spot light in Radians.
  57143. */
  57144. get angle(): number;
  57145. /**
  57146. * Sets the cone angle of the spot light in Radians.
  57147. */
  57148. set angle(value: number);
  57149. /**
  57150. * Only used in gltf falloff mode, this defines the angle where
  57151. * the directional falloff will start before cutting at angle which could be seen
  57152. * as outer angle.
  57153. */
  57154. get innerAngle(): number;
  57155. /**
  57156. * Only used in gltf falloff mode, this defines the angle where
  57157. * the directional falloff will start before cutting at angle which could be seen
  57158. * as outer angle.
  57159. */
  57160. set innerAngle(value: number);
  57161. private _shadowAngleScale;
  57162. /**
  57163. * Allows scaling the angle of the light for shadow generation only.
  57164. */
  57165. get shadowAngleScale(): number;
  57166. /**
  57167. * Allows scaling the angle of the light for shadow generation only.
  57168. */
  57169. set shadowAngleScale(value: number);
  57170. /**
  57171. * The light decay speed with the distance from the emission spot.
  57172. */
  57173. exponent: number;
  57174. private _projectionTextureMatrix;
  57175. /**
  57176. * Allows reading the projecton texture
  57177. */
  57178. get projectionTextureMatrix(): Matrix;
  57179. protected _projectionTextureLightNear: number;
  57180. /**
  57181. * Gets the near clip of the Spotlight for texture projection.
  57182. */
  57183. get projectionTextureLightNear(): number;
  57184. /**
  57185. * Sets the near clip of the Spotlight for texture projection.
  57186. */
  57187. set projectionTextureLightNear(value: number);
  57188. protected _projectionTextureLightFar: number;
  57189. /**
  57190. * Gets the far clip of the Spotlight for texture projection.
  57191. */
  57192. get projectionTextureLightFar(): number;
  57193. /**
  57194. * Sets the far clip of the Spotlight for texture projection.
  57195. */
  57196. set projectionTextureLightFar(value: number);
  57197. protected _projectionTextureUpDirection: Vector3;
  57198. /**
  57199. * Gets the Up vector of the Spotlight for texture projection.
  57200. */
  57201. get projectionTextureUpDirection(): Vector3;
  57202. /**
  57203. * Sets the Up vector of the Spotlight for texture projection.
  57204. */
  57205. set projectionTextureUpDirection(value: Vector3);
  57206. private _projectionTexture;
  57207. /**
  57208. * Gets the projection texture of the light.
  57209. */
  57210. get projectionTexture(): Nullable<BaseTexture>;
  57211. /**
  57212. * Sets the projection texture of the light.
  57213. */
  57214. set projectionTexture(value: Nullable<BaseTexture>);
  57215. private _projectionTextureViewLightDirty;
  57216. private _projectionTextureProjectionLightDirty;
  57217. private _projectionTextureDirty;
  57218. private _projectionTextureViewTargetVector;
  57219. private _projectionTextureViewLightMatrix;
  57220. private _projectionTextureProjectionLightMatrix;
  57221. private _projectionTextureScalingMatrix;
  57222. /**
  57223. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57224. * It can cast shadows.
  57225. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57226. * @param name The light friendly name
  57227. * @param position The position of the spot light in the scene
  57228. * @param direction The direction of the light in the scene
  57229. * @param angle The cone angle of the light in Radians
  57230. * @param exponent The light decay speed with the distance from the emission spot
  57231. * @param scene The scene the lights belongs to
  57232. */
  57233. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57234. /**
  57235. * Returns the string "SpotLight".
  57236. * @returns the class name
  57237. */
  57238. getClassName(): string;
  57239. /**
  57240. * Returns the integer 2.
  57241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57242. */
  57243. getTypeID(): number;
  57244. /**
  57245. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57246. */
  57247. protected _setDirection(value: Vector3): void;
  57248. /**
  57249. * Overrides the position setter to recompute the projection texture view light Matrix.
  57250. */
  57251. protected _setPosition(value: Vector3): void;
  57252. /**
  57253. * 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.
  57254. * Returns the SpotLight.
  57255. */
  57256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57257. protected _computeProjectionTextureViewLightMatrix(): void;
  57258. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57259. /**
  57260. * Main function for light texture projection matrix computing.
  57261. */
  57262. protected _computeProjectionTextureMatrix(): void;
  57263. protected _buildUniformLayout(): void;
  57264. private _computeAngleValues;
  57265. /**
  57266. * Sets the passed Effect "effect" with the Light textures.
  57267. * @param effect The effect to update
  57268. * @param lightIndex The index of the light in the effect to update
  57269. * @returns The light
  57270. */
  57271. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57272. /**
  57273. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57274. * @param effect The effect to update
  57275. * @param lightIndex The index of the light in the effect to update
  57276. * @returns The spot light
  57277. */
  57278. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57279. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57280. /**
  57281. * Disposes the light and the associated resources.
  57282. */
  57283. dispose(): void;
  57284. /**
  57285. * Prepares the list of defines specific to the light type.
  57286. * @param defines the list of defines
  57287. * @param lightIndex defines the index of the light for the effect
  57288. */
  57289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57290. }
  57291. }
  57292. declare module BABYLON {
  57293. /**
  57294. * Gizmo that enables viewing a light
  57295. */
  57296. export class LightGizmo extends Gizmo {
  57297. private _lightMesh;
  57298. private _material;
  57299. private _cachedPosition;
  57300. private _cachedForward;
  57301. private _attachedMeshParent;
  57302. private _pointerObserver;
  57303. /**
  57304. * Event that fires each time the gizmo is clicked
  57305. */
  57306. onClickedObservable: Observable<Light>;
  57307. /**
  57308. * Creates a LightGizmo
  57309. * @param gizmoLayer The utility layer the gizmo will be added to
  57310. */
  57311. constructor(gizmoLayer?: UtilityLayerRenderer);
  57312. private _light;
  57313. /**
  57314. * The light that the gizmo is attached to
  57315. */
  57316. set light(light: Nullable<Light>);
  57317. get light(): Nullable<Light>;
  57318. /**
  57319. * Gets the material used to render the light gizmo
  57320. */
  57321. get material(): StandardMaterial;
  57322. /**
  57323. * @hidden
  57324. * Updates the gizmo to match the attached mesh's position/rotation
  57325. */
  57326. protected _update(): void;
  57327. private static _Scale;
  57328. /**
  57329. * Creates the lines for a light mesh
  57330. */
  57331. private static _CreateLightLines;
  57332. /**
  57333. * Disposes of the light gizmo
  57334. */
  57335. dispose(): void;
  57336. private static _CreateHemisphericLightMesh;
  57337. private static _CreatePointLightMesh;
  57338. private static _CreateSpotLightMesh;
  57339. private static _CreateDirectionalLightMesh;
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * Gizmo that enables viewing a camera
  57345. */
  57346. export class CameraGizmo extends Gizmo {
  57347. private _cameraMesh;
  57348. private _cameraLinesMesh;
  57349. private _material;
  57350. private _pointerObserver;
  57351. /**
  57352. * Event that fires each time the gizmo is clicked
  57353. */
  57354. onClickedObservable: Observable<Camera>;
  57355. /**
  57356. * Creates a CameraGizmo
  57357. * @param gizmoLayer The utility layer the gizmo will be added to
  57358. */
  57359. constructor(gizmoLayer?: UtilityLayerRenderer);
  57360. private _camera;
  57361. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57362. get displayFrustum(): boolean;
  57363. set displayFrustum(value: boolean);
  57364. /**
  57365. * The camera that the gizmo is attached to
  57366. */
  57367. set camera(camera: Nullable<Camera>);
  57368. get camera(): Nullable<Camera>;
  57369. /**
  57370. * Gets the material used to render the camera gizmo
  57371. */
  57372. get material(): StandardMaterial;
  57373. /**
  57374. * @hidden
  57375. * Updates the gizmo to match the attached mesh's position/rotation
  57376. */
  57377. protected _update(): void;
  57378. private static _Scale;
  57379. private _invProjection;
  57380. /**
  57381. * Disposes of the camera gizmo
  57382. */
  57383. dispose(): void;
  57384. private static _CreateCameraMesh;
  57385. private static _CreateCameraFrustum;
  57386. }
  57387. }
  57388. declare module BABYLON {
  57389. /** @hidden */
  57390. export var backgroundFragmentDeclaration: {
  57391. name: string;
  57392. shader: string;
  57393. };
  57394. }
  57395. declare module BABYLON {
  57396. /** @hidden */
  57397. export var backgroundUboDeclaration: {
  57398. name: string;
  57399. shader: string;
  57400. };
  57401. }
  57402. declare module BABYLON {
  57403. /** @hidden */
  57404. export var backgroundPixelShader: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module BABYLON {
  57410. /** @hidden */
  57411. export var backgroundVertexDeclaration: {
  57412. name: string;
  57413. shader: string;
  57414. };
  57415. }
  57416. declare module BABYLON {
  57417. /** @hidden */
  57418. export var backgroundVertexShader: {
  57419. name: string;
  57420. shader: string;
  57421. };
  57422. }
  57423. declare module BABYLON {
  57424. /**
  57425. * Background material used to create an efficient environement around your scene.
  57426. */
  57427. export class BackgroundMaterial extends PushMaterial {
  57428. /**
  57429. * Standard reflectance value at parallel view angle.
  57430. */
  57431. static StandardReflectance0: number;
  57432. /**
  57433. * Standard reflectance value at grazing angle.
  57434. */
  57435. static StandardReflectance90: number;
  57436. protected _primaryColor: Color3;
  57437. /**
  57438. * Key light Color (multiply against the environement texture)
  57439. */
  57440. primaryColor: Color3;
  57441. protected __perceptualColor: Nullable<Color3>;
  57442. /**
  57443. * Experimental Internal Use Only.
  57444. *
  57445. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57446. * This acts as a helper to set the primary color to a more "human friendly" value.
  57447. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57448. * output color as close as possible from the chosen value.
  57449. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57450. * part of lighting setup.)
  57451. */
  57452. get _perceptualColor(): Nullable<Color3>;
  57453. set _perceptualColor(value: Nullable<Color3>);
  57454. protected _primaryColorShadowLevel: float;
  57455. /**
  57456. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57457. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57458. */
  57459. get primaryColorShadowLevel(): float;
  57460. set primaryColorShadowLevel(value: float);
  57461. protected _primaryColorHighlightLevel: float;
  57462. /**
  57463. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57464. * The primary color is used at the level chosen to define what the white area would look.
  57465. */
  57466. get primaryColorHighlightLevel(): float;
  57467. set primaryColorHighlightLevel(value: float);
  57468. protected _reflectionTexture: Nullable<BaseTexture>;
  57469. /**
  57470. * Reflection Texture used in the material.
  57471. * Should be author in a specific way for the best result (refer to the documentation).
  57472. */
  57473. reflectionTexture: Nullable<BaseTexture>;
  57474. protected _reflectionBlur: float;
  57475. /**
  57476. * Reflection Texture level of blur.
  57477. *
  57478. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57479. * texture twice.
  57480. */
  57481. reflectionBlur: float;
  57482. protected _diffuseTexture: Nullable<BaseTexture>;
  57483. /**
  57484. * Diffuse Texture used in the material.
  57485. * Should be author in a specific way for the best result (refer to the documentation).
  57486. */
  57487. diffuseTexture: Nullable<BaseTexture>;
  57488. protected _shadowLights: Nullable<IShadowLight[]>;
  57489. /**
  57490. * Specify the list of lights casting shadow on the material.
  57491. * All scene shadow lights will be included if null.
  57492. */
  57493. shadowLights: Nullable<IShadowLight[]>;
  57494. protected _shadowLevel: float;
  57495. /**
  57496. * Helps adjusting the shadow to a softer level if required.
  57497. * 0 means black shadows and 1 means no shadows.
  57498. */
  57499. shadowLevel: float;
  57500. protected _sceneCenter: Vector3;
  57501. /**
  57502. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57503. * It is usually zero but might be interesting to modify according to your setup.
  57504. */
  57505. sceneCenter: Vector3;
  57506. protected _opacityFresnel: boolean;
  57507. /**
  57508. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57509. * This helps ensuring a nice transition when the camera goes under the ground.
  57510. */
  57511. opacityFresnel: boolean;
  57512. protected _reflectionFresnel: boolean;
  57513. /**
  57514. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57515. * This helps adding a mirror texture on the ground.
  57516. */
  57517. reflectionFresnel: boolean;
  57518. protected _reflectionFalloffDistance: number;
  57519. /**
  57520. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57521. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57522. */
  57523. reflectionFalloffDistance: number;
  57524. protected _reflectionAmount: number;
  57525. /**
  57526. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57527. */
  57528. reflectionAmount: number;
  57529. protected _reflectionReflectance0: number;
  57530. /**
  57531. * This specifies the weight of the reflection at grazing angle.
  57532. */
  57533. reflectionReflectance0: number;
  57534. protected _reflectionReflectance90: number;
  57535. /**
  57536. * This specifies the weight of the reflection at a perpendicular point of view.
  57537. */
  57538. reflectionReflectance90: number;
  57539. /**
  57540. * Sets the reflection reflectance fresnel values according to the default standard
  57541. * empirically know to work well :-)
  57542. */
  57543. set reflectionStandardFresnelWeight(value: number);
  57544. protected _useRGBColor: boolean;
  57545. /**
  57546. * Helps to directly use the maps channels instead of their level.
  57547. */
  57548. useRGBColor: boolean;
  57549. protected _enableNoise: boolean;
  57550. /**
  57551. * This helps reducing the banding effect that could occur on the background.
  57552. */
  57553. enableNoise: boolean;
  57554. /**
  57555. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57556. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57557. * Recommended to be keep at 1.0 except for special cases.
  57558. */
  57559. get fovMultiplier(): number;
  57560. set fovMultiplier(value: number);
  57561. private _fovMultiplier;
  57562. /**
  57563. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57564. */
  57565. useEquirectangularFOV: boolean;
  57566. private _maxSimultaneousLights;
  57567. /**
  57568. * Number of Simultaneous lights allowed on the material.
  57569. */
  57570. maxSimultaneousLights: int;
  57571. private _shadowOnly;
  57572. /**
  57573. * Make the material only render shadows
  57574. */
  57575. shadowOnly: boolean;
  57576. /**
  57577. * Default configuration related to image processing available in the Background Material.
  57578. */
  57579. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57580. /**
  57581. * Keep track of the image processing observer to allow dispose and replace.
  57582. */
  57583. private _imageProcessingObserver;
  57584. /**
  57585. * Attaches a new image processing configuration to the PBR Material.
  57586. * @param configuration (if null the scene configuration will be use)
  57587. */
  57588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57589. /**
  57590. * Gets the image processing configuration used either in this material.
  57591. */
  57592. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57593. /**
  57594. * Sets the Default image processing configuration used either in the this material.
  57595. *
  57596. * If sets to null, the scene one is in use.
  57597. */
  57598. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57599. /**
  57600. * Gets wether the color curves effect is enabled.
  57601. */
  57602. get cameraColorCurvesEnabled(): boolean;
  57603. /**
  57604. * Sets wether the color curves effect is enabled.
  57605. */
  57606. set cameraColorCurvesEnabled(value: boolean);
  57607. /**
  57608. * Gets wether the color grading effect is enabled.
  57609. */
  57610. get cameraColorGradingEnabled(): boolean;
  57611. /**
  57612. * Gets wether the color grading effect is enabled.
  57613. */
  57614. set cameraColorGradingEnabled(value: boolean);
  57615. /**
  57616. * Gets wether tonemapping is enabled or not.
  57617. */
  57618. get cameraToneMappingEnabled(): boolean;
  57619. /**
  57620. * Sets wether tonemapping is enabled or not
  57621. */
  57622. set cameraToneMappingEnabled(value: boolean);
  57623. /**
  57624. * The camera exposure used on this material.
  57625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57626. * This corresponds to a photographic exposure.
  57627. */
  57628. get cameraExposure(): float;
  57629. /**
  57630. * The camera exposure used on this material.
  57631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57632. * This corresponds to a photographic exposure.
  57633. */
  57634. set cameraExposure(value: float);
  57635. /**
  57636. * Gets The camera contrast used on this material.
  57637. */
  57638. get cameraContrast(): float;
  57639. /**
  57640. * Sets The camera contrast used on this material.
  57641. */
  57642. set cameraContrast(value: float);
  57643. /**
  57644. * Gets the Color Grading 2D Lookup Texture.
  57645. */
  57646. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57647. /**
  57648. * Sets the Color Grading 2D Lookup Texture.
  57649. */
  57650. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57651. /**
  57652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57654. * 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;
  57655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57656. */
  57657. get cameraColorCurves(): Nullable<ColorCurves>;
  57658. /**
  57659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57661. * 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;
  57662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57663. */
  57664. set cameraColorCurves(value: Nullable<ColorCurves>);
  57665. /**
  57666. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57667. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57668. */
  57669. switchToBGR: boolean;
  57670. private _renderTargets;
  57671. private _reflectionControls;
  57672. private _white;
  57673. private _primaryShadowColor;
  57674. private _primaryHighlightColor;
  57675. /**
  57676. * Instantiates a Background Material in the given scene
  57677. * @param name The friendly name of the material
  57678. * @param scene The scene to add the material to
  57679. */
  57680. constructor(name: string, scene: Scene);
  57681. /**
  57682. * Gets a boolean indicating that current material needs to register RTT
  57683. */
  57684. get hasRenderTargetTextures(): boolean;
  57685. /**
  57686. * The entire material has been created in order to prevent overdraw.
  57687. * @returns false
  57688. */
  57689. needAlphaTesting(): boolean;
  57690. /**
  57691. * The entire material has been created in order to prevent overdraw.
  57692. * @returns true if blending is enable
  57693. */
  57694. needAlphaBlending(): boolean;
  57695. /**
  57696. * Checks wether the material is ready to be rendered for a given mesh.
  57697. * @param mesh The mesh to render
  57698. * @param subMesh The submesh to check against
  57699. * @param useInstances Specify wether or not the material is used with instances
  57700. * @returns true if all the dependencies are ready (Textures, Effects...)
  57701. */
  57702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57703. /**
  57704. * Compute the primary color according to the chosen perceptual color.
  57705. */
  57706. private _computePrimaryColorFromPerceptualColor;
  57707. /**
  57708. * Compute the highlights and shadow colors according to their chosen levels.
  57709. */
  57710. private _computePrimaryColors;
  57711. /**
  57712. * Build the uniform buffer used in the material.
  57713. */
  57714. buildUniformLayout(): void;
  57715. /**
  57716. * Unbind the material.
  57717. */
  57718. unbind(): void;
  57719. /**
  57720. * Bind only the world matrix to the material.
  57721. * @param world The world matrix to bind.
  57722. */
  57723. bindOnlyWorldMatrix(world: Matrix): void;
  57724. /**
  57725. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57726. * @param world The world matrix to bind.
  57727. * @param subMesh The submesh to bind for.
  57728. */
  57729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57730. /**
  57731. * Checks to see if a texture is used in the material.
  57732. * @param texture - Base texture to use.
  57733. * @returns - Boolean specifying if a texture is used in the material.
  57734. */
  57735. hasTexture(texture: BaseTexture): boolean;
  57736. /**
  57737. * Dispose the material.
  57738. * @param forceDisposeEffect Force disposal of the associated effect.
  57739. * @param forceDisposeTextures Force disposal of the associated textures.
  57740. */
  57741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57742. /**
  57743. * Clones the material.
  57744. * @param name The cloned name.
  57745. * @returns The cloned material.
  57746. */
  57747. clone(name: string): BackgroundMaterial;
  57748. /**
  57749. * Serializes the current material to its JSON representation.
  57750. * @returns The JSON representation.
  57751. */
  57752. serialize(): any;
  57753. /**
  57754. * Gets the class name of the material
  57755. * @returns "BackgroundMaterial"
  57756. */
  57757. getClassName(): string;
  57758. /**
  57759. * Parse a JSON input to create back a background material.
  57760. * @param source The JSON data to parse
  57761. * @param scene The scene to create the parsed material in
  57762. * @param rootUrl The root url of the assets the material depends upon
  57763. * @returns the instantiated BackgroundMaterial.
  57764. */
  57765. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57766. }
  57767. }
  57768. declare module BABYLON {
  57769. /**
  57770. * Represents the different options available during the creation of
  57771. * a Environment helper.
  57772. *
  57773. * This can control the default ground, skybox and image processing setup of your scene.
  57774. */
  57775. export interface IEnvironmentHelperOptions {
  57776. /**
  57777. * Specifies whether or not to create a ground.
  57778. * True by default.
  57779. */
  57780. createGround: boolean;
  57781. /**
  57782. * Specifies the ground size.
  57783. * 15 by default.
  57784. */
  57785. groundSize: number;
  57786. /**
  57787. * The texture used on the ground for the main color.
  57788. * Comes from the BabylonJS CDN by default.
  57789. *
  57790. * Remarks: Can be either a texture or a url.
  57791. */
  57792. groundTexture: string | BaseTexture;
  57793. /**
  57794. * The color mixed in the ground texture by default.
  57795. * BabylonJS clearColor by default.
  57796. */
  57797. groundColor: Color3;
  57798. /**
  57799. * Specifies the ground opacity.
  57800. * 1 by default.
  57801. */
  57802. groundOpacity: number;
  57803. /**
  57804. * Enables the ground to receive shadows.
  57805. * True by default.
  57806. */
  57807. enableGroundShadow: boolean;
  57808. /**
  57809. * Helps preventing the shadow to be fully black on the ground.
  57810. * 0.5 by default.
  57811. */
  57812. groundShadowLevel: number;
  57813. /**
  57814. * Creates a mirror texture attach to the ground.
  57815. * false by default.
  57816. */
  57817. enableGroundMirror: boolean;
  57818. /**
  57819. * Specifies the ground mirror size ratio.
  57820. * 0.3 by default as the default kernel is 64.
  57821. */
  57822. groundMirrorSizeRatio: number;
  57823. /**
  57824. * Specifies the ground mirror blur kernel size.
  57825. * 64 by default.
  57826. */
  57827. groundMirrorBlurKernel: number;
  57828. /**
  57829. * Specifies the ground mirror visibility amount.
  57830. * 1 by default
  57831. */
  57832. groundMirrorAmount: number;
  57833. /**
  57834. * Specifies the ground mirror reflectance weight.
  57835. * This uses the standard weight of the background material to setup the fresnel effect
  57836. * of the mirror.
  57837. * 1 by default.
  57838. */
  57839. groundMirrorFresnelWeight: number;
  57840. /**
  57841. * Specifies the ground mirror Falloff distance.
  57842. * This can helps reducing the size of the reflection.
  57843. * 0 by Default.
  57844. */
  57845. groundMirrorFallOffDistance: number;
  57846. /**
  57847. * Specifies the ground mirror texture type.
  57848. * Unsigned Int by Default.
  57849. */
  57850. groundMirrorTextureType: number;
  57851. /**
  57852. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57853. * the shown objects.
  57854. */
  57855. groundYBias: number;
  57856. /**
  57857. * Specifies whether or not to create a skybox.
  57858. * True by default.
  57859. */
  57860. createSkybox: boolean;
  57861. /**
  57862. * Specifies the skybox size.
  57863. * 20 by default.
  57864. */
  57865. skyboxSize: number;
  57866. /**
  57867. * The texture used on the skybox for the main color.
  57868. * Comes from the BabylonJS CDN by default.
  57869. *
  57870. * Remarks: Can be either a texture or a url.
  57871. */
  57872. skyboxTexture: string | BaseTexture;
  57873. /**
  57874. * The color mixed in the skybox texture by default.
  57875. * BabylonJS clearColor by default.
  57876. */
  57877. skyboxColor: Color3;
  57878. /**
  57879. * The background rotation around the Y axis of the scene.
  57880. * This helps aligning the key lights of your scene with the background.
  57881. * 0 by default.
  57882. */
  57883. backgroundYRotation: number;
  57884. /**
  57885. * Compute automatically the size of the elements to best fit with the scene.
  57886. */
  57887. sizeAuto: boolean;
  57888. /**
  57889. * Default position of the rootMesh if autoSize is not true.
  57890. */
  57891. rootPosition: Vector3;
  57892. /**
  57893. * Sets up the image processing in the scene.
  57894. * true by default.
  57895. */
  57896. setupImageProcessing: boolean;
  57897. /**
  57898. * The texture used as your environment texture in the scene.
  57899. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57900. *
  57901. * Remarks: Can be either a texture or a url.
  57902. */
  57903. environmentTexture: string | BaseTexture;
  57904. /**
  57905. * The value of the exposure to apply to the scene.
  57906. * 0.6 by default if setupImageProcessing is true.
  57907. */
  57908. cameraExposure: number;
  57909. /**
  57910. * The value of the contrast to apply to the scene.
  57911. * 1.6 by default if setupImageProcessing is true.
  57912. */
  57913. cameraContrast: number;
  57914. /**
  57915. * Specifies whether or not tonemapping should be enabled in the scene.
  57916. * true by default if setupImageProcessing is true.
  57917. */
  57918. toneMappingEnabled: boolean;
  57919. }
  57920. /**
  57921. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57922. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57923. * It also helps with the default setup of your imageProcessing configuration.
  57924. */
  57925. export class EnvironmentHelper {
  57926. /**
  57927. * Default ground texture URL.
  57928. */
  57929. private static _groundTextureCDNUrl;
  57930. /**
  57931. * Default skybox texture URL.
  57932. */
  57933. private static _skyboxTextureCDNUrl;
  57934. /**
  57935. * Default environment texture URL.
  57936. */
  57937. private static _environmentTextureCDNUrl;
  57938. /**
  57939. * Creates the default options for the helper.
  57940. */
  57941. private static _getDefaultOptions;
  57942. private _rootMesh;
  57943. /**
  57944. * Gets the root mesh created by the helper.
  57945. */
  57946. get rootMesh(): Mesh;
  57947. private _skybox;
  57948. /**
  57949. * Gets the skybox created by the helper.
  57950. */
  57951. get skybox(): Nullable<Mesh>;
  57952. private _skyboxTexture;
  57953. /**
  57954. * Gets the skybox texture created by the helper.
  57955. */
  57956. get skyboxTexture(): Nullable<BaseTexture>;
  57957. private _skyboxMaterial;
  57958. /**
  57959. * Gets the skybox material created by the helper.
  57960. */
  57961. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57962. private _ground;
  57963. /**
  57964. * Gets the ground mesh created by the helper.
  57965. */
  57966. get ground(): Nullable<Mesh>;
  57967. private _groundTexture;
  57968. /**
  57969. * Gets the ground texture created by the helper.
  57970. */
  57971. get groundTexture(): Nullable<BaseTexture>;
  57972. private _groundMirror;
  57973. /**
  57974. * Gets the ground mirror created by the helper.
  57975. */
  57976. get groundMirror(): Nullable<MirrorTexture>;
  57977. /**
  57978. * Gets the ground mirror render list to helps pushing the meshes
  57979. * you wish in the ground reflection.
  57980. */
  57981. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57982. private _groundMaterial;
  57983. /**
  57984. * Gets the ground material created by the helper.
  57985. */
  57986. get groundMaterial(): Nullable<BackgroundMaterial>;
  57987. /**
  57988. * Stores the creation options.
  57989. */
  57990. private readonly _scene;
  57991. private _options;
  57992. /**
  57993. * This observable will be notified with any error during the creation of the environment,
  57994. * mainly texture creation errors.
  57995. */
  57996. onErrorObservable: Observable<{
  57997. message?: string;
  57998. exception?: any;
  57999. }>;
  58000. /**
  58001. * constructor
  58002. * @param options Defines the options we want to customize the helper
  58003. * @param scene The scene to add the material to
  58004. */
  58005. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58006. /**
  58007. * Updates the background according to the new options
  58008. * @param options
  58009. */
  58010. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58011. /**
  58012. * Sets the primary color of all the available elements.
  58013. * @param color the main color to affect to the ground and the background
  58014. */
  58015. setMainColor(color: Color3): void;
  58016. /**
  58017. * Setup the image processing according to the specified options.
  58018. */
  58019. private _setupImageProcessing;
  58020. /**
  58021. * Setup the environment texture according to the specified options.
  58022. */
  58023. private _setupEnvironmentTexture;
  58024. /**
  58025. * Setup the background according to the specified options.
  58026. */
  58027. private _setupBackground;
  58028. /**
  58029. * Get the scene sizes according to the setup.
  58030. */
  58031. private _getSceneSize;
  58032. /**
  58033. * Setup the ground according to the specified options.
  58034. */
  58035. private _setupGround;
  58036. /**
  58037. * Setup the ground material according to the specified options.
  58038. */
  58039. private _setupGroundMaterial;
  58040. /**
  58041. * Setup the ground diffuse texture according to the specified options.
  58042. */
  58043. private _setupGroundDiffuseTexture;
  58044. /**
  58045. * Setup the ground mirror texture according to the specified options.
  58046. */
  58047. private _setupGroundMirrorTexture;
  58048. /**
  58049. * Setup the ground to receive the mirror texture.
  58050. */
  58051. private _setupMirrorInGroundMaterial;
  58052. /**
  58053. * Setup the skybox according to the specified options.
  58054. */
  58055. private _setupSkybox;
  58056. /**
  58057. * Setup the skybox material according to the specified options.
  58058. */
  58059. private _setupSkyboxMaterial;
  58060. /**
  58061. * Setup the skybox reflection texture according to the specified options.
  58062. */
  58063. private _setupSkyboxReflectionTexture;
  58064. private _errorHandler;
  58065. /**
  58066. * Dispose all the elements created by the Helper.
  58067. */
  58068. dispose(): void;
  58069. }
  58070. }
  58071. declare module BABYLON {
  58072. /**
  58073. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58074. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58075. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58076. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58077. */
  58078. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58079. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58080. /**
  58081. * Define the source as a Monoscopic panoramic 360/180.
  58082. */
  58083. static readonly MODE_MONOSCOPIC: number;
  58084. /**
  58085. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58086. */
  58087. static readonly MODE_TOPBOTTOM: number;
  58088. /**
  58089. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58090. */
  58091. static readonly MODE_SIDEBYSIDE: number;
  58092. private _halfDome;
  58093. private _crossEye;
  58094. protected _useDirectMapping: boolean;
  58095. /**
  58096. * The texture being displayed on the sphere
  58097. */
  58098. protected _texture: T;
  58099. /**
  58100. * Gets the texture being displayed on the sphere
  58101. */
  58102. get texture(): T;
  58103. /**
  58104. * Sets the texture being displayed on the sphere
  58105. */
  58106. set texture(newTexture: T);
  58107. /**
  58108. * The skybox material
  58109. */
  58110. protected _material: BackgroundMaterial;
  58111. /**
  58112. * The surface used for the dome
  58113. */
  58114. protected _mesh: Mesh;
  58115. /**
  58116. * Gets the mesh used for the dome.
  58117. */
  58118. get mesh(): Mesh;
  58119. /**
  58120. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58121. */
  58122. private _halfDomeMask;
  58123. /**
  58124. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58125. * Also see the options.resolution property.
  58126. */
  58127. get fovMultiplier(): number;
  58128. set fovMultiplier(value: number);
  58129. protected _textureMode: number;
  58130. /**
  58131. * Gets or set the current texture mode for the texture. It can be:
  58132. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58133. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58134. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58135. */
  58136. get textureMode(): number;
  58137. /**
  58138. * Sets the current texture mode for the texture. It can be:
  58139. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58140. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58141. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58142. */
  58143. set textureMode(value: number);
  58144. /**
  58145. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58146. */
  58147. get halfDome(): boolean;
  58148. /**
  58149. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58150. */
  58151. set halfDome(enabled: boolean);
  58152. /**
  58153. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58154. */
  58155. set crossEye(enabled: boolean);
  58156. /**
  58157. * Is it a cross-eye texture?
  58158. */
  58159. get crossEye(): boolean;
  58160. /**
  58161. * The background material of this dome.
  58162. */
  58163. get material(): BackgroundMaterial;
  58164. /**
  58165. * Oberserver used in Stereoscopic VR Mode.
  58166. */
  58167. private _onBeforeCameraRenderObserver;
  58168. /**
  58169. * Observable raised when an error occured while loading the 360 image
  58170. */
  58171. onLoadErrorObservable: Observable<string>;
  58172. /**
  58173. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58174. * @param name Element's name, child elements will append suffixes for their own names.
  58175. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58176. * @param options An object containing optional or exposed sub element properties
  58177. */
  58178. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58179. resolution?: number;
  58180. clickToPlay?: boolean;
  58181. autoPlay?: boolean;
  58182. loop?: boolean;
  58183. size?: number;
  58184. poster?: string;
  58185. faceForward?: boolean;
  58186. useDirectMapping?: boolean;
  58187. halfDomeMode?: boolean;
  58188. crossEyeMode?: boolean;
  58189. generateMipMaps?: boolean;
  58190. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58191. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58192. protected _changeTextureMode(value: number): void;
  58193. /**
  58194. * Releases resources associated with this node.
  58195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58197. */
  58198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58199. }
  58200. }
  58201. declare module BABYLON {
  58202. /**
  58203. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58204. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58205. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58206. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58207. */
  58208. export class PhotoDome extends TextureDome<Texture> {
  58209. /**
  58210. * Define the image as a Monoscopic panoramic 360 image.
  58211. */
  58212. static readonly MODE_MONOSCOPIC: number;
  58213. /**
  58214. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58215. */
  58216. static readonly MODE_TOPBOTTOM: number;
  58217. /**
  58218. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58219. */
  58220. static readonly MODE_SIDEBYSIDE: number;
  58221. /**
  58222. * Gets or sets the texture being displayed on the sphere
  58223. */
  58224. get photoTexture(): Texture;
  58225. /**
  58226. * sets the texture being displayed on the sphere
  58227. */
  58228. set photoTexture(value: Texture);
  58229. /**
  58230. * Gets the current video mode for the video. It can be:
  58231. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58232. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58233. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58234. */
  58235. get imageMode(): number;
  58236. /**
  58237. * Sets the current video mode for the video. It can be:
  58238. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58239. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58240. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58241. */
  58242. set imageMode(value: number);
  58243. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58244. }
  58245. }
  58246. declare module BABYLON {
  58247. /**
  58248. * Direct draw surface info
  58249. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58250. */
  58251. export interface DDSInfo {
  58252. /**
  58253. * Width of the texture
  58254. */
  58255. width: number;
  58256. /**
  58257. * Width of the texture
  58258. */
  58259. height: number;
  58260. /**
  58261. * Number of Mipmaps for the texture
  58262. * @see https://en.wikipedia.org/wiki/Mipmap
  58263. */
  58264. mipmapCount: number;
  58265. /**
  58266. * If the textures format is a known fourCC format
  58267. * @see https://www.fourcc.org/
  58268. */
  58269. isFourCC: boolean;
  58270. /**
  58271. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58272. */
  58273. isRGB: boolean;
  58274. /**
  58275. * If the texture is a lumincance format
  58276. */
  58277. isLuminance: boolean;
  58278. /**
  58279. * If this is a cube texture
  58280. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58281. */
  58282. isCube: boolean;
  58283. /**
  58284. * If the texture is a compressed format eg. FOURCC_DXT1
  58285. */
  58286. isCompressed: boolean;
  58287. /**
  58288. * The dxgiFormat of the texture
  58289. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58290. */
  58291. dxgiFormat: number;
  58292. /**
  58293. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58294. */
  58295. textureType: number;
  58296. /**
  58297. * Sphericle polynomial created for the dds texture
  58298. */
  58299. sphericalPolynomial?: SphericalPolynomial;
  58300. }
  58301. /**
  58302. * Class used to provide DDS decompression tools
  58303. */
  58304. export class DDSTools {
  58305. /**
  58306. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58307. */
  58308. static StoreLODInAlphaChannel: boolean;
  58309. /**
  58310. * Gets DDS information from an array buffer
  58311. * @param data defines the array buffer view to read data from
  58312. * @returns the DDS information
  58313. */
  58314. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58315. private static _FloatView;
  58316. private static _Int32View;
  58317. private static _ToHalfFloat;
  58318. private static _FromHalfFloat;
  58319. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58320. private static _GetHalfFloatRGBAArrayBuffer;
  58321. private static _GetFloatRGBAArrayBuffer;
  58322. private static _GetFloatAsUIntRGBAArrayBuffer;
  58323. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58324. private static _GetRGBAArrayBuffer;
  58325. private static _ExtractLongWordOrder;
  58326. private static _GetRGBArrayBuffer;
  58327. private static _GetLuminanceArrayBuffer;
  58328. /**
  58329. * Uploads DDS Levels to a Babylon Texture
  58330. * @hidden
  58331. */
  58332. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58333. }
  58334. interface ThinEngine {
  58335. /**
  58336. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58337. * @param rootUrl defines the url where the file to load is located
  58338. * @param scene defines the current scene
  58339. * @param lodScale defines scale to apply to the mip map selection
  58340. * @param lodOffset defines offset to apply to the mip map selection
  58341. * @param onLoad defines an optional callback raised when the texture is loaded
  58342. * @param onError defines an optional callback raised if there is an issue to load the texture
  58343. * @param format defines the format of the data
  58344. * @param forcedExtension defines the extension to use to pick the right loader
  58345. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58346. * @returns the cube texture as an InternalTexture
  58347. */
  58348. 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;
  58349. }
  58350. }
  58351. declare module BABYLON {
  58352. /**
  58353. * Implementation of the DDS Texture Loader.
  58354. * @hidden
  58355. */
  58356. export class _DDSTextureLoader implements IInternalTextureLoader {
  58357. /**
  58358. * Defines wether the loader supports cascade loading the different faces.
  58359. */
  58360. readonly supportCascades: boolean;
  58361. /**
  58362. * This returns if the loader support the current file information.
  58363. * @param extension defines the file extension of the file being loaded
  58364. * @returns true if the loader can load the specified file
  58365. */
  58366. canLoad(extension: string): boolean;
  58367. /**
  58368. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58369. * @param data contains the texture data
  58370. * @param texture defines the BabylonJS internal texture
  58371. * @param createPolynomials will be true if polynomials have been requested
  58372. * @param onLoad defines the callback to trigger once the texture is ready
  58373. * @param onError defines the callback to trigger in case of error
  58374. */
  58375. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58376. /**
  58377. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58378. * @param data contains the texture data
  58379. * @param texture defines the BabylonJS internal texture
  58380. * @param callback defines the method to call once ready to upload
  58381. */
  58382. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58383. }
  58384. }
  58385. declare module BABYLON {
  58386. /**
  58387. * Implementation of the ENV Texture Loader.
  58388. * @hidden
  58389. */
  58390. export class _ENVTextureLoader implements IInternalTextureLoader {
  58391. /**
  58392. * Defines wether the loader supports cascade loading the different faces.
  58393. */
  58394. readonly supportCascades: boolean;
  58395. /**
  58396. * This returns if the loader support the current file information.
  58397. * @param extension defines the file extension of the file being loaded
  58398. * @returns true if the loader can load the specified file
  58399. */
  58400. canLoad(extension: string): boolean;
  58401. /**
  58402. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58403. * @param data contains the texture data
  58404. * @param texture defines the BabylonJS internal texture
  58405. * @param createPolynomials will be true if polynomials have been requested
  58406. * @param onLoad defines the callback to trigger once the texture is ready
  58407. * @param onError defines the callback to trigger in case of error
  58408. */
  58409. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58410. /**
  58411. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58412. * @param data contains the texture data
  58413. * @param texture defines the BabylonJS internal texture
  58414. * @param callback defines the method to call once ready to upload
  58415. */
  58416. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58417. }
  58418. }
  58419. declare module BABYLON {
  58420. /**
  58421. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58422. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58423. */
  58424. export class KhronosTextureContainer {
  58425. /** contents of the KTX container file */
  58426. data: ArrayBufferView;
  58427. private static HEADER_LEN;
  58428. private static COMPRESSED_2D;
  58429. private static COMPRESSED_3D;
  58430. private static TEX_2D;
  58431. private static TEX_3D;
  58432. /**
  58433. * Gets the openGL type
  58434. */
  58435. glType: number;
  58436. /**
  58437. * Gets the openGL type size
  58438. */
  58439. glTypeSize: number;
  58440. /**
  58441. * Gets the openGL format
  58442. */
  58443. glFormat: number;
  58444. /**
  58445. * Gets the openGL internal format
  58446. */
  58447. glInternalFormat: number;
  58448. /**
  58449. * Gets the base internal format
  58450. */
  58451. glBaseInternalFormat: number;
  58452. /**
  58453. * Gets image width in pixel
  58454. */
  58455. pixelWidth: number;
  58456. /**
  58457. * Gets image height in pixel
  58458. */
  58459. pixelHeight: number;
  58460. /**
  58461. * Gets image depth in pixels
  58462. */
  58463. pixelDepth: number;
  58464. /**
  58465. * Gets the number of array elements
  58466. */
  58467. numberOfArrayElements: number;
  58468. /**
  58469. * Gets the number of faces
  58470. */
  58471. numberOfFaces: number;
  58472. /**
  58473. * Gets the number of mipmap levels
  58474. */
  58475. numberOfMipmapLevels: number;
  58476. /**
  58477. * Gets the bytes of key value data
  58478. */
  58479. bytesOfKeyValueData: number;
  58480. /**
  58481. * Gets the load type
  58482. */
  58483. loadType: number;
  58484. /**
  58485. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58486. */
  58487. isInvalid: boolean;
  58488. /**
  58489. * Creates a new KhronosTextureContainer
  58490. * @param data contents of the KTX container file
  58491. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58492. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58493. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58494. */
  58495. constructor(
  58496. /** contents of the KTX container file */
  58497. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58498. /**
  58499. * Uploads KTX content to a Babylon Texture.
  58500. * It is assumed that the texture has already been created & is currently bound
  58501. * @hidden
  58502. */
  58503. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58504. private _upload2DCompressedLevels;
  58505. /**
  58506. * Checks if the given data starts with a KTX file identifier.
  58507. * @param data the data to check
  58508. * @returns true if the data is a KTX file or false otherwise
  58509. */
  58510. static IsValid(data: ArrayBufferView): boolean;
  58511. }
  58512. }
  58513. declare module BABYLON {
  58514. /**
  58515. * Helper class to push actions to a pool of workers.
  58516. */
  58517. export class WorkerPool implements IDisposable {
  58518. private _workerInfos;
  58519. private _pendingActions;
  58520. /**
  58521. * Constructor
  58522. * @param workers Array of workers to use for actions
  58523. */
  58524. constructor(workers: Array<Worker>);
  58525. /**
  58526. * Terminates all workers and clears any pending actions.
  58527. */
  58528. dispose(): void;
  58529. /**
  58530. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58531. * pended until a worker has completed its action.
  58532. * @param action The action to perform. Call onComplete when the action is complete.
  58533. */
  58534. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58535. private _execute;
  58536. }
  58537. }
  58538. declare module BABYLON {
  58539. /**
  58540. * Class for loading KTX2 files
  58541. */
  58542. export class KhronosTextureContainer2 {
  58543. private static _WorkerPoolPromise?;
  58544. private static _Initialized;
  58545. private static _Ktx2Decoder;
  58546. /**
  58547. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58548. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58549. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58550. * Urls you can change:
  58551. * URLConfig.jsDecoderModule
  58552. * URLConfig.wasmUASTCToASTC
  58553. * URLConfig.wasmUASTCToBC7
  58554. * URLConfig.jsMSCTranscoder
  58555. * URLConfig.wasmMSCTranscoder
  58556. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58557. */
  58558. static URLConfig: {
  58559. jsDecoderModule: string;
  58560. wasmUASTCToASTC: null;
  58561. wasmUASTCToBC7: null;
  58562. jsMSCTranscoder: null;
  58563. wasmMSCTranscoder: null;
  58564. };
  58565. /**
  58566. * Default number of workers used to handle data decoding
  58567. */
  58568. static DefaultNumWorkers: number;
  58569. private static GetDefaultNumWorkers;
  58570. private _engine;
  58571. private static _CreateWorkerPool;
  58572. /**
  58573. * Constructor
  58574. * @param engine The engine to use
  58575. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58576. */
  58577. constructor(engine: ThinEngine, numWorkers?: number);
  58578. /** @hidden */
  58579. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58580. /**
  58581. * Stop all async operations and release resources.
  58582. */
  58583. dispose(): void;
  58584. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58585. /**
  58586. * Checks if the given data starts with a KTX2 file identifier.
  58587. * @param data the data to check
  58588. * @returns true if the data is a KTX2 file or false otherwise
  58589. */
  58590. static IsValid(data: ArrayBufferView): boolean;
  58591. }
  58592. }
  58593. declare module BABYLON {
  58594. /**
  58595. * Implementation of the KTX Texture Loader.
  58596. * @hidden
  58597. */
  58598. export class _KTXTextureLoader implements IInternalTextureLoader {
  58599. /**
  58600. * Defines wether the loader supports cascade loading the different faces.
  58601. */
  58602. readonly supportCascades: boolean;
  58603. /**
  58604. * This returns if the loader support the current file information.
  58605. * @param extension defines the file extension of the file being loaded
  58606. * @param mimeType defines the optional mime type of the file being loaded
  58607. * @returns true if the loader can load the specified file
  58608. */
  58609. canLoad(extension: string, mimeType?: string): boolean;
  58610. /**
  58611. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58612. * @param data contains the texture data
  58613. * @param texture defines the BabylonJS internal texture
  58614. * @param createPolynomials will be true if polynomials have been requested
  58615. * @param onLoad defines the callback to trigger once the texture is ready
  58616. * @param onError defines the callback to trigger in case of error
  58617. */
  58618. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58619. /**
  58620. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58621. * @param data contains the texture data
  58622. * @param texture defines the BabylonJS internal texture
  58623. * @param callback defines the method to call once ready to upload
  58624. */
  58625. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58626. }
  58627. }
  58628. declare module BABYLON {
  58629. /** @hidden */
  58630. export var _forceSceneHelpersToBundle: boolean;
  58631. interface Scene {
  58632. /**
  58633. * Creates a default light for the scene.
  58634. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58635. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58636. */
  58637. createDefaultLight(replace?: boolean): void;
  58638. /**
  58639. * Creates a default camera for the scene.
  58640. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58641. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58642. * @param replace has default false, when true replaces the active camera in the scene
  58643. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58644. */
  58645. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58646. /**
  58647. * Creates a default camera and a default light.
  58648. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58649. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58650. * @param replace has the default false, when true replaces the active camera/light in the scene
  58651. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58652. */
  58653. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58654. /**
  58655. * Creates a new sky box
  58656. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58657. * @param environmentTexture defines the texture to use as environment texture
  58658. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58659. * @param scale defines the overall scale of the skybox
  58660. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58661. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58662. * @returns a new mesh holding the sky box
  58663. */
  58664. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58665. /**
  58666. * Creates a new environment
  58667. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58668. * @param options defines the options you can use to configure the environment
  58669. * @returns the new EnvironmentHelper
  58670. */
  58671. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58672. /**
  58673. * Creates a new VREXperienceHelper
  58674. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58675. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58676. * @returns a new VREXperienceHelper
  58677. */
  58678. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58679. /**
  58680. * Creates a new WebXRDefaultExperience
  58681. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58682. * @param options experience options
  58683. * @returns a promise for a new WebXRDefaultExperience
  58684. */
  58685. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58686. }
  58687. }
  58688. declare module BABYLON {
  58689. /**
  58690. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58691. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58692. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58693. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58694. */
  58695. export class VideoDome extends TextureDome<VideoTexture> {
  58696. /**
  58697. * Define the video source as a Monoscopic panoramic 360 video.
  58698. */
  58699. static readonly MODE_MONOSCOPIC: number;
  58700. /**
  58701. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58702. */
  58703. static readonly MODE_TOPBOTTOM: number;
  58704. /**
  58705. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58706. */
  58707. static readonly MODE_SIDEBYSIDE: number;
  58708. /**
  58709. * Get the video texture associated with this video dome
  58710. */
  58711. get videoTexture(): VideoTexture;
  58712. /**
  58713. * Get the video mode of this dome
  58714. */
  58715. get videoMode(): number;
  58716. /**
  58717. * Set the video mode of this dome.
  58718. * @see textureMode
  58719. */
  58720. set videoMode(value: number);
  58721. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58722. }
  58723. }
  58724. declare module BABYLON {
  58725. /**
  58726. * This class can be used to get instrumentation data from a Babylon engine
  58727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58728. */
  58729. export class EngineInstrumentation implements IDisposable {
  58730. /**
  58731. * Define the instrumented engine.
  58732. */
  58733. engine: Engine;
  58734. private _captureGPUFrameTime;
  58735. private _gpuFrameTimeToken;
  58736. private _gpuFrameTime;
  58737. private _captureShaderCompilationTime;
  58738. private _shaderCompilationTime;
  58739. private _onBeginFrameObserver;
  58740. private _onEndFrameObserver;
  58741. private _onBeforeShaderCompilationObserver;
  58742. private _onAfterShaderCompilationObserver;
  58743. /**
  58744. * Gets the perf counter used for GPU frame time
  58745. */
  58746. get gpuFrameTimeCounter(): PerfCounter;
  58747. /**
  58748. * Gets the GPU frame time capture status
  58749. */
  58750. get captureGPUFrameTime(): boolean;
  58751. /**
  58752. * Enable or disable the GPU frame time capture
  58753. */
  58754. set captureGPUFrameTime(value: boolean);
  58755. /**
  58756. * Gets the perf counter used for shader compilation time
  58757. */
  58758. get shaderCompilationTimeCounter(): PerfCounter;
  58759. /**
  58760. * Gets the shader compilation time capture status
  58761. */
  58762. get captureShaderCompilationTime(): boolean;
  58763. /**
  58764. * Enable or disable the shader compilation time capture
  58765. */
  58766. set captureShaderCompilationTime(value: boolean);
  58767. /**
  58768. * Instantiates a new engine instrumentation.
  58769. * This class can be used to get instrumentation data from a Babylon engine
  58770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58771. * @param engine Defines the engine to instrument
  58772. */
  58773. constructor(
  58774. /**
  58775. * Define the instrumented engine.
  58776. */
  58777. engine: Engine);
  58778. /**
  58779. * Dispose and release associated resources.
  58780. */
  58781. dispose(): void;
  58782. }
  58783. }
  58784. declare module BABYLON {
  58785. /**
  58786. * This class can be used to get instrumentation data from a Babylon engine
  58787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58788. */
  58789. export class SceneInstrumentation implements IDisposable {
  58790. /**
  58791. * Defines the scene to instrument
  58792. */
  58793. scene: Scene;
  58794. private _captureActiveMeshesEvaluationTime;
  58795. private _activeMeshesEvaluationTime;
  58796. private _captureRenderTargetsRenderTime;
  58797. private _renderTargetsRenderTime;
  58798. private _captureFrameTime;
  58799. private _frameTime;
  58800. private _captureRenderTime;
  58801. private _renderTime;
  58802. private _captureInterFrameTime;
  58803. private _interFrameTime;
  58804. private _captureParticlesRenderTime;
  58805. private _particlesRenderTime;
  58806. private _captureSpritesRenderTime;
  58807. private _spritesRenderTime;
  58808. private _capturePhysicsTime;
  58809. private _physicsTime;
  58810. private _captureAnimationsTime;
  58811. private _animationsTime;
  58812. private _captureCameraRenderTime;
  58813. private _cameraRenderTime;
  58814. private _onBeforeActiveMeshesEvaluationObserver;
  58815. private _onAfterActiveMeshesEvaluationObserver;
  58816. private _onBeforeRenderTargetsRenderObserver;
  58817. private _onAfterRenderTargetsRenderObserver;
  58818. private _onAfterRenderObserver;
  58819. private _onBeforeDrawPhaseObserver;
  58820. private _onAfterDrawPhaseObserver;
  58821. private _onBeforeAnimationsObserver;
  58822. private _onBeforeParticlesRenderingObserver;
  58823. private _onAfterParticlesRenderingObserver;
  58824. private _onBeforeSpritesRenderingObserver;
  58825. private _onAfterSpritesRenderingObserver;
  58826. private _onBeforePhysicsObserver;
  58827. private _onAfterPhysicsObserver;
  58828. private _onAfterAnimationsObserver;
  58829. private _onBeforeCameraRenderObserver;
  58830. private _onAfterCameraRenderObserver;
  58831. /**
  58832. * Gets the perf counter used for active meshes evaluation time
  58833. */
  58834. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58835. /**
  58836. * Gets the active meshes evaluation time capture status
  58837. */
  58838. get captureActiveMeshesEvaluationTime(): boolean;
  58839. /**
  58840. * Enable or disable the active meshes evaluation time capture
  58841. */
  58842. set captureActiveMeshesEvaluationTime(value: boolean);
  58843. /**
  58844. * Gets the perf counter used for render targets render time
  58845. */
  58846. get renderTargetsRenderTimeCounter(): PerfCounter;
  58847. /**
  58848. * Gets the render targets render time capture status
  58849. */
  58850. get captureRenderTargetsRenderTime(): boolean;
  58851. /**
  58852. * Enable or disable the render targets render time capture
  58853. */
  58854. set captureRenderTargetsRenderTime(value: boolean);
  58855. /**
  58856. * Gets the perf counter used for particles render time
  58857. */
  58858. get particlesRenderTimeCounter(): PerfCounter;
  58859. /**
  58860. * Gets the particles render time capture status
  58861. */
  58862. get captureParticlesRenderTime(): boolean;
  58863. /**
  58864. * Enable or disable the particles render time capture
  58865. */
  58866. set captureParticlesRenderTime(value: boolean);
  58867. /**
  58868. * Gets the perf counter used for sprites render time
  58869. */
  58870. get spritesRenderTimeCounter(): PerfCounter;
  58871. /**
  58872. * Gets the sprites render time capture status
  58873. */
  58874. get captureSpritesRenderTime(): boolean;
  58875. /**
  58876. * Enable or disable the sprites render time capture
  58877. */
  58878. set captureSpritesRenderTime(value: boolean);
  58879. /**
  58880. * Gets the perf counter used for physics time
  58881. */
  58882. get physicsTimeCounter(): PerfCounter;
  58883. /**
  58884. * Gets the physics time capture status
  58885. */
  58886. get capturePhysicsTime(): boolean;
  58887. /**
  58888. * Enable or disable the physics time capture
  58889. */
  58890. set capturePhysicsTime(value: boolean);
  58891. /**
  58892. * Gets the perf counter used for animations time
  58893. */
  58894. get animationsTimeCounter(): PerfCounter;
  58895. /**
  58896. * Gets the animations time capture status
  58897. */
  58898. get captureAnimationsTime(): boolean;
  58899. /**
  58900. * Enable or disable the animations time capture
  58901. */
  58902. set captureAnimationsTime(value: boolean);
  58903. /**
  58904. * Gets the perf counter used for frame time capture
  58905. */
  58906. get frameTimeCounter(): PerfCounter;
  58907. /**
  58908. * Gets the frame time capture status
  58909. */
  58910. get captureFrameTime(): boolean;
  58911. /**
  58912. * Enable or disable the frame time capture
  58913. */
  58914. set captureFrameTime(value: boolean);
  58915. /**
  58916. * Gets the perf counter used for inter-frames time capture
  58917. */
  58918. get interFrameTimeCounter(): PerfCounter;
  58919. /**
  58920. * Gets the inter-frames time capture status
  58921. */
  58922. get captureInterFrameTime(): boolean;
  58923. /**
  58924. * Enable or disable the inter-frames time capture
  58925. */
  58926. set captureInterFrameTime(value: boolean);
  58927. /**
  58928. * Gets the perf counter used for render time capture
  58929. */
  58930. get renderTimeCounter(): PerfCounter;
  58931. /**
  58932. * Gets the render time capture status
  58933. */
  58934. get captureRenderTime(): boolean;
  58935. /**
  58936. * Enable or disable the render time capture
  58937. */
  58938. set captureRenderTime(value: boolean);
  58939. /**
  58940. * Gets the perf counter used for camera render time capture
  58941. */
  58942. get cameraRenderTimeCounter(): PerfCounter;
  58943. /**
  58944. * Gets the camera render time capture status
  58945. */
  58946. get captureCameraRenderTime(): boolean;
  58947. /**
  58948. * Enable or disable the camera render time capture
  58949. */
  58950. set captureCameraRenderTime(value: boolean);
  58951. /**
  58952. * Gets the perf counter used for draw calls
  58953. */
  58954. get drawCallsCounter(): PerfCounter;
  58955. /**
  58956. * Instantiates a new scene instrumentation.
  58957. * This class can be used to get instrumentation data from a Babylon engine
  58958. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58959. * @param scene Defines the scene to instrument
  58960. */
  58961. constructor(
  58962. /**
  58963. * Defines the scene to instrument
  58964. */
  58965. scene: Scene);
  58966. /**
  58967. * Dispose and release associated resources.
  58968. */
  58969. dispose(): void;
  58970. }
  58971. }
  58972. declare module BABYLON {
  58973. /** @hidden */
  58974. export var glowMapGenerationPixelShader: {
  58975. name: string;
  58976. shader: string;
  58977. };
  58978. }
  58979. declare module BABYLON {
  58980. /** @hidden */
  58981. export var glowMapGenerationVertexShader: {
  58982. name: string;
  58983. shader: string;
  58984. };
  58985. }
  58986. declare module BABYLON {
  58987. /**
  58988. * Effect layer options. This helps customizing the behaviour
  58989. * of the effect layer.
  58990. */
  58991. export interface IEffectLayerOptions {
  58992. /**
  58993. * Multiplication factor apply to the canvas size to compute the render target size
  58994. * used to generated the objects (the smaller the faster).
  58995. */
  58996. mainTextureRatio: number;
  58997. /**
  58998. * Enforces a fixed size texture to ensure effect stability across devices.
  58999. */
  59000. mainTextureFixedSize?: number;
  59001. /**
  59002. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59003. */
  59004. alphaBlendingMode: number;
  59005. /**
  59006. * The camera attached to the layer.
  59007. */
  59008. camera: Nullable<Camera>;
  59009. /**
  59010. * The rendering group to draw the layer in.
  59011. */
  59012. renderingGroupId: number;
  59013. }
  59014. /**
  59015. * The effect layer Helps adding post process effect blended with the main pass.
  59016. *
  59017. * This can be for instance use to generate glow or higlight effects on the scene.
  59018. *
  59019. * The effect layer class can not be used directly and is intented to inherited from to be
  59020. * customized per effects.
  59021. */
  59022. export abstract class EffectLayer {
  59023. private _vertexBuffers;
  59024. private _indexBuffer;
  59025. private _cachedDefines;
  59026. private _effectLayerMapGenerationEffect;
  59027. private _effectLayerOptions;
  59028. private _mergeEffect;
  59029. protected _scene: Scene;
  59030. protected _engine: Engine;
  59031. protected _maxSize: number;
  59032. protected _mainTextureDesiredSize: ISize;
  59033. protected _mainTexture: RenderTargetTexture;
  59034. protected _shouldRender: boolean;
  59035. protected _postProcesses: PostProcess[];
  59036. protected _textures: BaseTexture[];
  59037. protected _emissiveTextureAndColor: {
  59038. texture: Nullable<BaseTexture>;
  59039. color: Color4;
  59040. };
  59041. /**
  59042. * The name of the layer
  59043. */
  59044. name: string;
  59045. /**
  59046. * The clear color of the texture used to generate the glow map.
  59047. */
  59048. neutralColor: Color4;
  59049. /**
  59050. * Specifies whether the highlight layer is enabled or not.
  59051. */
  59052. isEnabled: boolean;
  59053. /**
  59054. * Gets the camera attached to the layer.
  59055. */
  59056. get camera(): Nullable<Camera>;
  59057. /**
  59058. * Gets the rendering group id the layer should render in.
  59059. */
  59060. get renderingGroupId(): number;
  59061. set renderingGroupId(renderingGroupId: number);
  59062. /**
  59063. * An event triggered when the effect layer has been disposed.
  59064. */
  59065. onDisposeObservable: Observable<EffectLayer>;
  59066. /**
  59067. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59068. */
  59069. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59070. /**
  59071. * An event triggered when the generated texture is being merged in the scene.
  59072. */
  59073. onBeforeComposeObservable: Observable<EffectLayer>;
  59074. /**
  59075. * An event triggered when the mesh is rendered into the effect render target.
  59076. */
  59077. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59078. /**
  59079. * An event triggered after the mesh has been rendered into the effect render target.
  59080. */
  59081. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59082. /**
  59083. * An event triggered when the generated texture has been merged in the scene.
  59084. */
  59085. onAfterComposeObservable: Observable<EffectLayer>;
  59086. /**
  59087. * An event triggered when the efffect layer changes its size.
  59088. */
  59089. onSizeChangedObservable: Observable<EffectLayer>;
  59090. /** @hidden */
  59091. static _SceneComponentInitialization: (scene: Scene) => void;
  59092. /**
  59093. * Instantiates a new effect Layer and references it in the scene.
  59094. * @param name The name of the layer
  59095. * @param scene The scene to use the layer in
  59096. */
  59097. constructor(
  59098. /** The Friendly of the effect in the scene */
  59099. name: string, scene: Scene);
  59100. /**
  59101. * Get the effect name of the layer.
  59102. * @return The effect name
  59103. */
  59104. abstract getEffectName(): string;
  59105. /**
  59106. * Checks for the readiness of the element composing the layer.
  59107. * @param subMesh the mesh to check for
  59108. * @param useInstances specify whether or not to use instances to render the mesh
  59109. * @return true if ready otherwise, false
  59110. */
  59111. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59112. /**
  59113. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59114. * @returns true if the effect requires stencil during the main canvas render pass.
  59115. */
  59116. abstract needStencil(): boolean;
  59117. /**
  59118. * Create the merge effect. This is the shader use to blit the information back
  59119. * to the main canvas at the end of the scene rendering.
  59120. * @returns The effect containing the shader used to merge the effect on the main canvas
  59121. */
  59122. protected abstract _createMergeEffect(): Effect;
  59123. /**
  59124. * Creates the render target textures and post processes used in the effect layer.
  59125. */
  59126. protected abstract _createTextureAndPostProcesses(): void;
  59127. /**
  59128. * Implementation specific of rendering the generating effect on the main canvas.
  59129. * @param effect The effect used to render through
  59130. */
  59131. protected abstract _internalRender(effect: Effect): void;
  59132. /**
  59133. * Sets the required values for both the emissive texture and and the main color.
  59134. */
  59135. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59136. /**
  59137. * Free any resources and references associated to a mesh.
  59138. * Internal use
  59139. * @param mesh The mesh to free.
  59140. */
  59141. abstract _disposeMesh(mesh: Mesh): void;
  59142. /**
  59143. * Serializes this layer (Glow or Highlight for example)
  59144. * @returns a serialized layer object
  59145. */
  59146. abstract serialize?(): any;
  59147. /**
  59148. * Initializes the effect layer with the required options.
  59149. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59150. */
  59151. protected _init(options: Partial<IEffectLayerOptions>): void;
  59152. /**
  59153. * Generates the index buffer of the full screen quad blending to the main canvas.
  59154. */
  59155. private _generateIndexBuffer;
  59156. /**
  59157. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59158. */
  59159. private _generateVertexBuffer;
  59160. /**
  59161. * Sets the main texture desired size which is the closest power of two
  59162. * of the engine canvas size.
  59163. */
  59164. private _setMainTextureSize;
  59165. /**
  59166. * Creates the main texture for the effect layer.
  59167. */
  59168. protected _createMainTexture(): void;
  59169. /**
  59170. * Adds specific effects defines.
  59171. * @param defines The defines to add specifics to.
  59172. */
  59173. protected _addCustomEffectDefines(defines: string[]): void;
  59174. /**
  59175. * Checks for the readiness of the element composing the layer.
  59176. * @param subMesh the mesh to check for
  59177. * @param useInstances specify whether or not to use instances to render the mesh
  59178. * @param emissiveTexture the associated emissive texture used to generate the glow
  59179. * @return true if ready otherwise, false
  59180. */
  59181. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59182. /**
  59183. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59184. */
  59185. render(): void;
  59186. /**
  59187. * Determine if a given mesh will be used in the current effect.
  59188. * @param mesh mesh to test
  59189. * @returns true if the mesh will be used
  59190. */
  59191. hasMesh(mesh: AbstractMesh): boolean;
  59192. /**
  59193. * Returns true if the layer contains information to display, otherwise false.
  59194. * @returns true if the glow layer should be rendered
  59195. */
  59196. shouldRender(): boolean;
  59197. /**
  59198. * Returns true if the mesh should render, otherwise false.
  59199. * @param mesh The mesh to render
  59200. * @returns true if it should render otherwise false
  59201. */
  59202. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59203. /**
  59204. * Returns true if the mesh can be rendered, otherwise false.
  59205. * @param mesh The mesh to render
  59206. * @param material The material used on the mesh
  59207. * @returns true if it can be rendered otherwise false
  59208. */
  59209. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59210. /**
  59211. * Returns true if the mesh should render, otherwise false.
  59212. * @param mesh The mesh to render
  59213. * @returns true if it should render otherwise false
  59214. */
  59215. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59216. /**
  59217. * Renders the submesh passed in parameter to the generation map.
  59218. */
  59219. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59220. /**
  59221. * Defines whether the current material of the mesh should be use to render the effect.
  59222. * @param mesh defines the current mesh to render
  59223. */
  59224. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59225. /**
  59226. * Rebuild the required buffers.
  59227. * @hidden Internal use only.
  59228. */
  59229. _rebuild(): void;
  59230. /**
  59231. * Dispose only the render target textures and post process.
  59232. */
  59233. private _disposeTextureAndPostProcesses;
  59234. /**
  59235. * Dispose the highlight layer and free resources.
  59236. */
  59237. dispose(): void;
  59238. /**
  59239. * Gets the class name of the effect layer
  59240. * @returns the string with the class name of the effect layer
  59241. */
  59242. getClassName(): string;
  59243. /**
  59244. * Creates an effect layer from parsed effect layer data
  59245. * @param parsedEffectLayer defines effect layer data
  59246. * @param scene defines the current scene
  59247. * @param rootUrl defines the root URL containing the effect layer information
  59248. * @returns a parsed effect Layer
  59249. */
  59250. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. interface AbstractScene {
  59255. /**
  59256. * The list of effect layers (highlights/glow) added to the scene
  59257. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59258. * @see https://doc.babylonjs.com/how_to/glow_layer
  59259. */
  59260. effectLayers: Array<EffectLayer>;
  59261. /**
  59262. * Removes the given effect layer from this scene.
  59263. * @param toRemove defines the effect layer to remove
  59264. * @returns the index of the removed effect layer
  59265. */
  59266. removeEffectLayer(toRemove: EffectLayer): number;
  59267. /**
  59268. * Adds the given effect layer to this scene
  59269. * @param newEffectLayer defines the effect layer to add
  59270. */
  59271. addEffectLayer(newEffectLayer: EffectLayer): void;
  59272. }
  59273. /**
  59274. * Defines the layer scene component responsible to manage any effect layers
  59275. * in a given scene.
  59276. */
  59277. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59278. /**
  59279. * The component name helpfull to identify the component in the list of scene components.
  59280. */
  59281. readonly name: string;
  59282. /**
  59283. * The scene the component belongs to.
  59284. */
  59285. scene: Scene;
  59286. private _engine;
  59287. private _renderEffects;
  59288. private _needStencil;
  59289. private _previousStencilState;
  59290. /**
  59291. * Creates a new instance of the component for the given scene
  59292. * @param scene Defines the scene to register the component in
  59293. */
  59294. constructor(scene: Scene);
  59295. /**
  59296. * Registers the component in a given scene
  59297. */
  59298. register(): void;
  59299. /**
  59300. * Rebuilds the elements related to this component in case of
  59301. * context lost for instance.
  59302. */
  59303. rebuild(): void;
  59304. /**
  59305. * Serializes the component data to the specified json object
  59306. * @param serializationObject The object to serialize to
  59307. */
  59308. serialize(serializationObject: any): void;
  59309. /**
  59310. * Adds all the elements from the container to the scene
  59311. * @param container the container holding the elements
  59312. */
  59313. addFromContainer(container: AbstractScene): void;
  59314. /**
  59315. * Removes all the elements in the container from the scene
  59316. * @param container contains the elements to remove
  59317. * @param dispose if the removed element should be disposed (default: false)
  59318. */
  59319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59320. /**
  59321. * Disposes the component and the associated ressources.
  59322. */
  59323. dispose(): void;
  59324. private _isReadyForMesh;
  59325. private _renderMainTexture;
  59326. private _setStencil;
  59327. private _setStencilBack;
  59328. private _draw;
  59329. private _drawCamera;
  59330. private _drawRenderingGroup;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /** @hidden */
  59335. export var glowMapMergePixelShader: {
  59336. name: string;
  59337. shader: string;
  59338. };
  59339. }
  59340. declare module BABYLON {
  59341. /** @hidden */
  59342. export var glowMapMergeVertexShader: {
  59343. name: string;
  59344. shader: string;
  59345. };
  59346. }
  59347. declare module BABYLON {
  59348. interface AbstractScene {
  59349. /**
  59350. * Return a the first highlight layer of the scene with a given name.
  59351. * @param name The name of the highlight layer to look for.
  59352. * @return The highlight layer if found otherwise null.
  59353. */
  59354. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59355. }
  59356. /**
  59357. * Glow layer options. This helps customizing the behaviour
  59358. * of the glow layer.
  59359. */
  59360. export interface IGlowLayerOptions {
  59361. /**
  59362. * Multiplication factor apply to the canvas size to compute the render target size
  59363. * used to generated the glowing objects (the smaller the faster).
  59364. */
  59365. mainTextureRatio: number;
  59366. /**
  59367. * Enforces a fixed size texture to ensure resize independant blur.
  59368. */
  59369. mainTextureFixedSize?: number;
  59370. /**
  59371. * How big is the kernel of the blur texture.
  59372. */
  59373. blurKernelSize: number;
  59374. /**
  59375. * The camera attached to the layer.
  59376. */
  59377. camera: Nullable<Camera>;
  59378. /**
  59379. * Enable MSAA by chosing the number of samples.
  59380. */
  59381. mainTextureSamples?: number;
  59382. /**
  59383. * The rendering group to draw the layer in.
  59384. */
  59385. renderingGroupId: number;
  59386. }
  59387. /**
  59388. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59389. *
  59390. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59391. *
  59392. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59393. */
  59394. export class GlowLayer extends EffectLayer {
  59395. /**
  59396. * Effect Name of the layer.
  59397. */
  59398. static readonly EffectName: string;
  59399. /**
  59400. * The default blur kernel size used for the glow.
  59401. */
  59402. static DefaultBlurKernelSize: number;
  59403. /**
  59404. * The default texture size ratio used for the glow.
  59405. */
  59406. static DefaultTextureRatio: number;
  59407. /**
  59408. * Sets the kernel size of the blur.
  59409. */
  59410. set blurKernelSize(value: number);
  59411. /**
  59412. * Gets the kernel size of the blur.
  59413. */
  59414. get blurKernelSize(): number;
  59415. /**
  59416. * Sets the glow intensity.
  59417. */
  59418. set intensity(value: number);
  59419. /**
  59420. * Gets the glow intensity.
  59421. */
  59422. get intensity(): number;
  59423. private _options;
  59424. private _intensity;
  59425. private _horizontalBlurPostprocess1;
  59426. private _verticalBlurPostprocess1;
  59427. private _horizontalBlurPostprocess2;
  59428. private _verticalBlurPostprocess2;
  59429. private _blurTexture1;
  59430. private _blurTexture2;
  59431. private _postProcesses1;
  59432. private _postProcesses2;
  59433. private _includedOnlyMeshes;
  59434. private _excludedMeshes;
  59435. private _meshesUsingTheirOwnMaterials;
  59436. /**
  59437. * Callback used to let the user override the color selection on a per mesh basis
  59438. */
  59439. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59440. /**
  59441. * Callback used to let the user override the texture selection on a per mesh basis
  59442. */
  59443. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59444. /**
  59445. * Instantiates a new glow Layer and references it to the scene.
  59446. * @param name The name of the layer
  59447. * @param scene The scene to use the layer in
  59448. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59449. */
  59450. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59451. /**
  59452. * Get the effect name of the layer.
  59453. * @return The effect name
  59454. */
  59455. getEffectName(): string;
  59456. /**
  59457. * Create the merge effect. This is the shader use to blit the information back
  59458. * to the main canvas at the end of the scene rendering.
  59459. */
  59460. protected _createMergeEffect(): Effect;
  59461. /**
  59462. * Creates the render target textures and post processes used in the glow layer.
  59463. */
  59464. protected _createTextureAndPostProcesses(): void;
  59465. /**
  59466. * Checks for the readiness of the element composing the layer.
  59467. * @param subMesh the mesh to check for
  59468. * @param useInstances specify wether or not to use instances to render the mesh
  59469. * @param emissiveTexture the associated emissive texture used to generate the glow
  59470. * @return true if ready otherwise, false
  59471. */
  59472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59473. /**
  59474. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59475. */
  59476. needStencil(): boolean;
  59477. /**
  59478. * Returns true if the mesh can be rendered, otherwise false.
  59479. * @param mesh The mesh to render
  59480. * @param material The material used on the mesh
  59481. * @returns true if it can be rendered otherwise false
  59482. */
  59483. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59484. /**
  59485. * Implementation specific of rendering the generating effect on the main canvas.
  59486. * @param effect The effect used to render through
  59487. */
  59488. protected _internalRender(effect: Effect): void;
  59489. /**
  59490. * Sets the required values for both the emissive texture and and the main color.
  59491. */
  59492. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59493. /**
  59494. * Returns true if the mesh should render, otherwise false.
  59495. * @param mesh The mesh to render
  59496. * @returns true if it should render otherwise false
  59497. */
  59498. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59499. /**
  59500. * Adds specific effects defines.
  59501. * @param defines The defines to add specifics to.
  59502. */
  59503. protected _addCustomEffectDefines(defines: string[]): void;
  59504. /**
  59505. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59506. * @param mesh The mesh to exclude from the glow layer
  59507. */
  59508. addExcludedMesh(mesh: Mesh): void;
  59509. /**
  59510. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59511. * @param mesh The mesh to remove
  59512. */
  59513. removeExcludedMesh(mesh: Mesh): void;
  59514. /**
  59515. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59516. * @param mesh The mesh to include in the glow layer
  59517. */
  59518. addIncludedOnlyMesh(mesh: Mesh): void;
  59519. /**
  59520. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59521. * @param mesh The mesh to remove
  59522. */
  59523. removeIncludedOnlyMesh(mesh: Mesh): void;
  59524. /**
  59525. * Determine if a given mesh will be used in the glow layer
  59526. * @param mesh The mesh to test
  59527. * @returns true if the mesh will be highlighted by the current glow layer
  59528. */
  59529. hasMesh(mesh: AbstractMesh): boolean;
  59530. /**
  59531. * Defines whether the current material of the mesh should be use to render the effect.
  59532. * @param mesh defines the current mesh to render
  59533. */
  59534. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59535. /**
  59536. * Add a mesh to be rendered through its own material and not with emissive only.
  59537. * @param mesh The mesh for which we need to use its material
  59538. */
  59539. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59540. /**
  59541. * Remove a mesh from being rendered through its own material and not with emissive only.
  59542. * @param mesh The mesh for which we need to not use its material
  59543. */
  59544. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59545. /**
  59546. * Free any resources and references associated to a mesh.
  59547. * Internal use
  59548. * @param mesh The mesh to free.
  59549. * @hidden
  59550. */
  59551. _disposeMesh(mesh: Mesh): void;
  59552. /**
  59553. * Gets the class name of the effect layer
  59554. * @returns the string with the class name of the effect layer
  59555. */
  59556. getClassName(): string;
  59557. /**
  59558. * Serializes this glow layer
  59559. * @returns a serialized glow layer object
  59560. */
  59561. serialize(): any;
  59562. /**
  59563. * Creates a Glow Layer from parsed glow layer data
  59564. * @param parsedGlowLayer defines glow layer data
  59565. * @param scene defines the current scene
  59566. * @param rootUrl defines the root URL containing the glow layer information
  59567. * @returns a parsed Glow Layer
  59568. */
  59569. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59570. }
  59571. }
  59572. declare module BABYLON {
  59573. /** @hidden */
  59574. export var glowBlurPostProcessPixelShader: {
  59575. name: string;
  59576. shader: string;
  59577. };
  59578. }
  59579. declare module BABYLON {
  59580. interface AbstractScene {
  59581. /**
  59582. * Return a the first highlight layer of the scene with a given name.
  59583. * @param name The name of the highlight layer to look for.
  59584. * @return The highlight layer if found otherwise null.
  59585. */
  59586. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59587. }
  59588. /**
  59589. * Highlight layer options. This helps customizing the behaviour
  59590. * of the highlight layer.
  59591. */
  59592. export interface IHighlightLayerOptions {
  59593. /**
  59594. * Multiplication factor apply to the canvas size to compute the render target size
  59595. * used to generated the glowing objects (the smaller the faster).
  59596. */
  59597. mainTextureRatio: number;
  59598. /**
  59599. * Enforces a fixed size texture to ensure resize independant blur.
  59600. */
  59601. mainTextureFixedSize?: number;
  59602. /**
  59603. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59604. * of the picture to blur (the smaller the faster).
  59605. */
  59606. blurTextureSizeRatio: number;
  59607. /**
  59608. * How big in texel of the blur texture is the vertical blur.
  59609. */
  59610. blurVerticalSize: number;
  59611. /**
  59612. * How big in texel of the blur texture is the horizontal blur.
  59613. */
  59614. blurHorizontalSize: number;
  59615. /**
  59616. * Alpha blending mode used to apply the blur. Default is combine.
  59617. */
  59618. alphaBlendingMode: number;
  59619. /**
  59620. * The camera attached to the layer.
  59621. */
  59622. camera: Nullable<Camera>;
  59623. /**
  59624. * Should we display highlight as a solid stroke?
  59625. */
  59626. isStroke?: boolean;
  59627. /**
  59628. * The rendering group to draw the layer in.
  59629. */
  59630. renderingGroupId: number;
  59631. }
  59632. /**
  59633. * The highlight layer Helps adding a glow effect around a mesh.
  59634. *
  59635. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59636. * glowy meshes to your scene.
  59637. *
  59638. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59639. */
  59640. export class HighlightLayer extends EffectLayer {
  59641. name: string;
  59642. /**
  59643. * Effect Name of the highlight layer.
  59644. */
  59645. static readonly EffectName: string;
  59646. /**
  59647. * The neutral color used during the preparation of the glow effect.
  59648. * This is black by default as the blend operation is a blend operation.
  59649. */
  59650. static NeutralColor: Color4;
  59651. /**
  59652. * Stencil value used for glowing meshes.
  59653. */
  59654. static GlowingMeshStencilReference: number;
  59655. /**
  59656. * Stencil value used for the other meshes in the scene.
  59657. */
  59658. static NormalMeshStencilReference: number;
  59659. /**
  59660. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59661. */
  59662. innerGlow: boolean;
  59663. /**
  59664. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59665. */
  59666. outerGlow: boolean;
  59667. /**
  59668. * Specifies the horizontal size of the blur.
  59669. */
  59670. set blurHorizontalSize(value: number);
  59671. /**
  59672. * Specifies the vertical size of the blur.
  59673. */
  59674. set blurVerticalSize(value: number);
  59675. /**
  59676. * Gets the horizontal size of the blur.
  59677. */
  59678. get blurHorizontalSize(): number;
  59679. /**
  59680. * Gets the vertical size of the blur.
  59681. */
  59682. get blurVerticalSize(): number;
  59683. /**
  59684. * An event triggered when the highlight layer is being blurred.
  59685. */
  59686. onBeforeBlurObservable: Observable<HighlightLayer>;
  59687. /**
  59688. * An event triggered when the highlight layer has been blurred.
  59689. */
  59690. onAfterBlurObservable: Observable<HighlightLayer>;
  59691. private _instanceGlowingMeshStencilReference;
  59692. private _options;
  59693. private _downSamplePostprocess;
  59694. private _horizontalBlurPostprocess;
  59695. private _verticalBlurPostprocess;
  59696. private _blurTexture;
  59697. private _meshes;
  59698. private _excludedMeshes;
  59699. /**
  59700. * Instantiates a new highlight Layer and references it to the scene..
  59701. * @param name The name of the layer
  59702. * @param scene The scene to use the layer in
  59703. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59704. */
  59705. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59706. /**
  59707. * Get the effect name of the layer.
  59708. * @return The effect name
  59709. */
  59710. getEffectName(): string;
  59711. /**
  59712. * Create the merge effect. This is the shader use to blit the information back
  59713. * to the main canvas at the end of the scene rendering.
  59714. */
  59715. protected _createMergeEffect(): Effect;
  59716. /**
  59717. * Creates the render target textures and post processes used in the highlight layer.
  59718. */
  59719. protected _createTextureAndPostProcesses(): void;
  59720. /**
  59721. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59722. */
  59723. needStencil(): boolean;
  59724. /**
  59725. * Checks for the readiness of the element composing the layer.
  59726. * @param subMesh the mesh to check for
  59727. * @param useInstances specify wether or not to use instances to render the mesh
  59728. * @param emissiveTexture the associated emissive texture used to generate the glow
  59729. * @return true if ready otherwise, false
  59730. */
  59731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59732. /**
  59733. * Implementation specific of rendering the generating effect on the main canvas.
  59734. * @param effect The effect used to render through
  59735. */
  59736. protected _internalRender(effect: Effect): void;
  59737. /**
  59738. * Returns true if the layer contains information to display, otherwise false.
  59739. */
  59740. shouldRender(): boolean;
  59741. /**
  59742. * Returns true if the mesh should render, otherwise false.
  59743. * @param mesh The mesh to render
  59744. * @returns true if it should render otherwise false
  59745. */
  59746. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59747. /**
  59748. * Returns true if the mesh can be rendered, otherwise false.
  59749. * @param mesh The mesh to render
  59750. * @param material The material used on the mesh
  59751. * @returns true if it can be rendered otherwise false
  59752. */
  59753. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59754. /**
  59755. * Adds specific effects defines.
  59756. * @param defines The defines to add specifics to.
  59757. */
  59758. protected _addCustomEffectDefines(defines: string[]): void;
  59759. /**
  59760. * Sets the required values for both the emissive texture and and the main color.
  59761. */
  59762. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59763. /**
  59764. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59765. * @param mesh The mesh to exclude from the highlight layer
  59766. */
  59767. addExcludedMesh(mesh: Mesh): void;
  59768. /**
  59769. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59770. * @param mesh The mesh to highlight
  59771. */
  59772. removeExcludedMesh(mesh: Mesh): void;
  59773. /**
  59774. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59775. * @param mesh mesh to test
  59776. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59777. */
  59778. hasMesh(mesh: AbstractMesh): boolean;
  59779. /**
  59780. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59781. * @param mesh The mesh to highlight
  59782. * @param color The color of the highlight
  59783. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59784. */
  59785. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59786. /**
  59787. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59788. * @param mesh The mesh to highlight
  59789. */
  59790. removeMesh(mesh: Mesh): void;
  59791. /**
  59792. * Remove all the meshes currently referenced in the highlight layer
  59793. */
  59794. removeAllMeshes(): void;
  59795. /**
  59796. * Force the stencil to the normal expected value for none glowing parts
  59797. */
  59798. private _defaultStencilReference;
  59799. /**
  59800. * Free any resources and references associated to a mesh.
  59801. * Internal use
  59802. * @param mesh The mesh to free.
  59803. * @hidden
  59804. */
  59805. _disposeMesh(mesh: Mesh): void;
  59806. /**
  59807. * Dispose the highlight layer and free resources.
  59808. */
  59809. dispose(): void;
  59810. /**
  59811. * Gets the class name of the effect layer
  59812. * @returns the string with the class name of the effect layer
  59813. */
  59814. getClassName(): string;
  59815. /**
  59816. * Serializes this Highlight layer
  59817. * @returns a serialized Highlight layer object
  59818. */
  59819. serialize(): any;
  59820. /**
  59821. * Creates a Highlight layer from parsed Highlight layer data
  59822. * @param parsedHightlightLayer defines the Highlight layer data
  59823. * @param scene defines the current scene
  59824. * @param rootUrl defines the root URL containing the Highlight layer information
  59825. * @returns a parsed Highlight layer
  59826. */
  59827. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59828. }
  59829. }
  59830. declare module BABYLON {
  59831. interface AbstractScene {
  59832. /**
  59833. * The list of layers (background and foreground) of the scene
  59834. */
  59835. layers: Array<Layer>;
  59836. }
  59837. /**
  59838. * Defines the layer scene component responsible to manage any layers
  59839. * in a given scene.
  59840. */
  59841. export class LayerSceneComponent implements ISceneComponent {
  59842. /**
  59843. * The component name helpfull to identify the component in the list of scene components.
  59844. */
  59845. readonly name: string;
  59846. /**
  59847. * The scene the component belongs to.
  59848. */
  59849. scene: Scene;
  59850. private _engine;
  59851. /**
  59852. * Creates a new instance of the component for the given scene
  59853. * @param scene Defines the scene to register the component in
  59854. */
  59855. constructor(scene: Scene);
  59856. /**
  59857. * Registers the component in a given scene
  59858. */
  59859. register(): void;
  59860. /**
  59861. * Rebuilds the elements related to this component in case of
  59862. * context lost for instance.
  59863. */
  59864. rebuild(): void;
  59865. /**
  59866. * Disposes the component and the associated ressources.
  59867. */
  59868. dispose(): void;
  59869. private _draw;
  59870. private _drawCameraPredicate;
  59871. private _drawCameraBackground;
  59872. private _drawCameraForeground;
  59873. private _drawRenderTargetPredicate;
  59874. private _drawRenderTargetBackground;
  59875. private _drawRenderTargetForeground;
  59876. /**
  59877. * Adds all the elements from the container to the scene
  59878. * @param container the container holding the elements
  59879. */
  59880. addFromContainer(container: AbstractScene): void;
  59881. /**
  59882. * Removes all the elements in the container from the scene
  59883. * @param container contains the elements to remove
  59884. * @param dispose if the removed element should be disposed (default: false)
  59885. */
  59886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59887. }
  59888. }
  59889. declare module BABYLON {
  59890. /** @hidden */
  59891. export var layerPixelShader: {
  59892. name: string;
  59893. shader: string;
  59894. };
  59895. }
  59896. declare module BABYLON {
  59897. /** @hidden */
  59898. export var layerVertexShader: {
  59899. name: string;
  59900. shader: string;
  59901. };
  59902. }
  59903. declare module BABYLON {
  59904. /**
  59905. * This represents a full screen 2d layer.
  59906. * This can be useful to display a picture in the background of your scene for instance.
  59907. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59908. */
  59909. export class Layer {
  59910. /**
  59911. * Define the name of the layer.
  59912. */
  59913. name: string;
  59914. /**
  59915. * Define the texture the layer should display.
  59916. */
  59917. texture: Nullable<Texture>;
  59918. /**
  59919. * Is the layer in background or foreground.
  59920. */
  59921. isBackground: boolean;
  59922. /**
  59923. * Define the color of the layer (instead of texture).
  59924. */
  59925. color: Color4;
  59926. /**
  59927. * Define the scale of the layer in order to zoom in out of the texture.
  59928. */
  59929. scale: Vector2;
  59930. /**
  59931. * Define an offset for the layer in order to shift the texture.
  59932. */
  59933. offset: Vector2;
  59934. /**
  59935. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59936. */
  59937. alphaBlendingMode: number;
  59938. /**
  59939. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59940. * Alpha test will not mix with the background color in case of transparency.
  59941. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59942. */
  59943. alphaTest: boolean;
  59944. /**
  59945. * Define a mask to restrict the layer to only some of the scene cameras.
  59946. */
  59947. layerMask: number;
  59948. /**
  59949. * Define the list of render target the layer is visible into.
  59950. */
  59951. renderTargetTextures: RenderTargetTexture[];
  59952. /**
  59953. * Define if the layer is only used in renderTarget or if it also
  59954. * renders in the main frame buffer of the canvas.
  59955. */
  59956. renderOnlyInRenderTargetTextures: boolean;
  59957. private _scene;
  59958. private _vertexBuffers;
  59959. private _indexBuffer;
  59960. private _effect;
  59961. private _previousDefines;
  59962. /**
  59963. * An event triggered when the layer is disposed.
  59964. */
  59965. onDisposeObservable: Observable<Layer>;
  59966. private _onDisposeObserver;
  59967. /**
  59968. * Back compatibility with callback before the onDisposeObservable existed.
  59969. * The set callback will be triggered when the layer has been disposed.
  59970. */
  59971. set onDispose(callback: () => void);
  59972. /**
  59973. * An event triggered before rendering the scene
  59974. */
  59975. onBeforeRenderObservable: Observable<Layer>;
  59976. private _onBeforeRenderObserver;
  59977. /**
  59978. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59979. * The set callback will be triggered just before rendering the layer.
  59980. */
  59981. set onBeforeRender(callback: () => void);
  59982. /**
  59983. * An event triggered after rendering the scene
  59984. */
  59985. onAfterRenderObservable: Observable<Layer>;
  59986. private _onAfterRenderObserver;
  59987. /**
  59988. * Back compatibility with callback before the onAfterRenderObservable existed.
  59989. * The set callback will be triggered just after rendering the layer.
  59990. */
  59991. set onAfterRender(callback: () => void);
  59992. /**
  59993. * Instantiates a new layer.
  59994. * This represents a full screen 2d layer.
  59995. * This can be useful to display a picture in the background of your scene for instance.
  59996. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59997. * @param name Define the name of the layer in the scene
  59998. * @param imgUrl Define the url of the texture to display in the layer
  59999. * @param scene Define the scene the layer belongs to
  60000. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60001. * @param color Defines a color for the layer
  60002. */
  60003. constructor(
  60004. /**
  60005. * Define the name of the layer.
  60006. */
  60007. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60008. private _createIndexBuffer;
  60009. /** @hidden */
  60010. _rebuild(): void;
  60011. /**
  60012. * Renders the layer in the scene.
  60013. */
  60014. render(): void;
  60015. /**
  60016. * Disposes and releases the associated ressources.
  60017. */
  60018. dispose(): void;
  60019. }
  60020. }
  60021. declare module BABYLON {
  60022. /** @hidden */
  60023. export var lensFlarePixelShader: {
  60024. name: string;
  60025. shader: string;
  60026. };
  60027. }
  60028. declare module BABYLON {
  60029. /** @hidden */
  60030. export var lensFlareVertexShader: {
  60031. name: string;
  60032. shader: string;
  60033. };
  60034. }
  60035. declare module BABYLON {
  60036. /**
  60037. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60038. * It is usually composed of several `lensFlare`.
  60039. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60040. */
  60041. export class LensFlareSystem {
  60042. /**
  60043. * Define the name of the lens flare system
  60044. */
  60045. name: string;
  60046. /**
  60047. * List of lens flares used in this system.
  60048. */
  60049. lensFlares: LensFlare[];
  60050. /**
  60051. * Define a limit from the border the lens flare can be visible.
  60052. */
  60053. borderLimit: number;
  60054. /**
  60055. * Define a viewport border we do not want to see the lens flare in.
  60056. */
  60057. viewportBorder: number;
  60058. /**
  60059. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60060. */
  60061. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60062. /**
  60063. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60064. */
  60065. layerMask: number;
  60066. /**
  60067. * Define the id of the lens flare system in the scene.
  60068. * (equal to name by default)
  60069. */
  60070. id: string;
  60071. private _scene;
  60072. private _emitter;
  60073. private _vertexBuffers;
  60074. private _indexBuffer;
  60075. private _effect;
  60076. private _positionX;
  60077. private _positionY;
  60078. private _isEnabled;
  60079. /** @hidden */
  60080. static _SceneComponentInitialization: (scene: Scene) => void;
  60081. /**
  60082. * Instantiates a lens flare system.
  60083. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60084. * It is usually composed of several `lensFlare`.
  60085. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60086. * @param name Define the name of the lens flare system in the scene
  60087. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60088. * @param scene Define the scene the lens flare system belongs to
  60089. */
  60090. constructor(
  60091. /**
  60092. * Define the name of the lens flare system
  60093. */
  60094. name: string, emitter: any, scene: Scene);
  60095. /**
  60096. * Define if the lens flare system is enabled.
  60097. */
  60098. get isEnabled(): boolean;
  60099. set isEnabled(value: boolean);
  60100. /**
  60101. * Get the scene the effects belongs to.
  60102. * @returns the scene holding the lens flare system
  60103. */
  60104. getScene(): Scene;
  60105. /**
  60106. * Get the emitter of the lens flare system.
  60107. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60108. * @returns the emitter of the lens flare system
  60109. */
  60110. getEmitter(): any;
  60111. /**
  60112. * Set the emitter of the lens flare system.
  60113. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60114. * @param newEmitter Define the new emitter of the system
  60115. */
  60116. setEmitter(newEmitter: any): void;
  60117. /**
  60118. * Get the lens flare system emitter position.
  60119. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60120. * @returns the position
  60121. */
  60122. getEmitterPosition(): Vector3;
  60123. /**
  60124. * @hidden
  60125. */
  60126. computeEffectivePosition(globalViewport: Viewport): boolean;
  60127. /** @hidden */
  60128. _isVisible(): boolean;
  60129. /**
  60130. * @hidden
  60131. */
  60132. render(): boolean;
  60133. /**
  60134. * Dispose and release the lens flare with its associated resources.
  60135. */
  60136. dispose(): void;
  60137. /**
  60138. * Parse a lens flare system from a JSON repressentation
  60139. * @param parsedLensFlareSystem Define the JSON to parse
  60140. * @param scene Define the scene the parsed system should be instantiated in
  60141. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60142. * @returns the parsed system
  60143. */
  60144. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60145. /**
  60146. * Serialize the current Lens Flare System into a JSON representation.
  60147. * @returns the serialized JSON
  60148. */
  60149. serialize(): any;
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /**
  60154. * This represents one of the lens effect in a `lensFlareSystem`.
  60155. * It controls one of the indiviual texture used in the effect.
  60156. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60157. */
  60158. export class LensFlare {
  60159. /**
  60160. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60161. */
  60162. size: number;
  60163. /**
  60164. * 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.
  60165. */
  60166. position: number;
  60167. /**
  60168. * Define the lens color.
  60169. */
  60170. color: Color3;
  60171. /**
  60172. * Define the lens texture.
  60173. */
  60174. texture: Nullable<Texture>;
  60175. /**
  60176. * Define the alpha mode to render this particular lens.
  60177. */
  60178. alphaMode: number;
  60179. private _system;
  60180. /**
  60181. * Creates a new Lens Flare.
  60182. * This represents one of the lens effect in a `lensFlareSystem`.
  60183. * It controls one of the indiviual texture used in the effect.
  60184. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60185. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60186. * @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.
  60187. * @param color Define the lens color
  60188. * @param imgUrl Define the lens texture url
  60189. * @param system Define the `lensFlareSystem` this flare is part of
  60190. * @returns The newly created Lens Flare
  60191. */
  60192. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60193. /**
  60194. * Instantiates a new Lens Flare.
  60195. * This represents one of the lens effect in a `lensFlareSystem`.
  60196. * It controls one of the indiviual texture used in the effect.
  60197. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60198. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60199. * @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.
  60200. * @param color Define the lens color
  60201. * @param imgUrl Define the lens texture url
  60202. * @param system Define the `lensFlareSystem` this flare is part of
  60203. */
  60204. constructor(
  60205. /**
  60206. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60207. */
  60208. size: number,
  60209. /**
  60210. * 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.
  60211. */
  60212. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60213. /**
  60214. * Dispose and release the lens flare with its associated resources.
  60215. */
  60216. dispose(): void;
  60217. }
  60218. }
  60219. declare module BABYLON {
  60220. interface AbstractScene {
  60221. /**
  60222. * The list of lens flare system added to the scene
  60223. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60224. */
  60225. lensFlareSystems: Array<LensFlareSystem>;
  60226. /**
  60227. * Removes the given lens flare system from this scene.
  60228. * @param toRemove The lens flare system to remove
  60229. * @returns The index of the removed lens flare system
  60230. */
  60231. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60232. /**
  60233. * Adds the given lens flare system to this scene
  60234. * @param newLensFlareSystem The lens flare system to add
  60235. */
  60236. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60237. /**
  60238. * Gets a lens flare system using its name
  60239. * @param name defines the name to look for
  60240. * @returns the lens flare system or null if not found
  60241. */
  60242. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60243. /**
  60244. * Gets a lens flare system using its id
  60245. * @param id defines the id to look for
  60246. * @returns the lens flare system or null if not found
  60247. */
  60248. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60249. }
  60250. /**
  60251. * Defines the lens flare scene component responsible to manage any lens flares
  60252. * in a given scene.
  60253. */
  60254. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60255. /**
  60256. * The component name helpfull to identify the component in the list of scene components.
  60257. */
  60258. readonly name: string;
  60259. /**
  60260. * The scene the component belongs to.
  60261. */
  60262. scene: Scene;
  60263. /**
  60264. * Creates a new instance of the component for the given scene
  60265. * @param scene Defines the scene to register the component in
  60266. */
  60267. constructor(scene: Scene);
  60268. /**
  60269. * Registers the component in a given scene
  60270. */
  60271. register(): void;
  60272. /**
  60273. * Rebuilds the elements related to this component in case of
  60274. * context lost for instance.
  60275. */
  60276. rebuild(): void;
  60277. /**
  60278. * Adds all the elements from the container to the scene
  60279. * @param container the container holding the elements
  60280. */
  60281. addFromContainer(container: AbstractScene): void;
  60282. /**
  60283. * Removes all the elements in the container from the scene
  60284. * @param container contains the elements to remove
  60285. * @param dispose if the removed element should be disposed (default: false)
  60286. */
  60287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60288. /**
  60289. * Serializes the component data to the specified json object
  60290. * @param serializationObject The object to serialize to
  60291. */
  60292. serialize(serializationObject: any): void;
  60293. /**
  60294. * Disposes the component and the associated ressources.
  60295. */
  60296. dispose(): void;
  60297. private _draw;
  60298. }
  60299. }
  60300. declare module BABYLON {
  60301. /** @hidden */
  60302. export var depthPixelShader: {
  60303. name: string;
  60304. shader: string;
  60305. };
  60306. }
  60307. declare module BABYLON {
  60308. /** @hidden */
  60309. export var depthVertexShader: {
  60310. name: string;
  60311. shader: string;
  60312. };
  60313. }
  60314. declare module BABYLON {
  60315. /**
  60316. * This represents a depth renderer in Babylon.
  60317. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60318. */
  60319. export class DepthRenderer {
  60320. private _scene;
  60321. private _depthMap;
  60322. private _effect;
  60323. private readonly _storeNonLinearDepth;
  60324. private readonly _clearColor;
  60325. /** Get if the depth renderer is using packed depth or not */
  60326. readonly isPacked: boolean;
  60327. private _cachedDefines;
  60328. private _camera;
  60329. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60330. enabled: boolean;
  60331. /**
  60332. * Specifiess that the depth renderer will only be used within
  60333. * the camera it is created for.
  60334. * This can help forcing its rendering during the camera processing.
  60335. */
  60336. useOnlyInActiveCamera: boolean;
  60337. /** @hidden */
  60338. static _SceneComponentInitialization: (scene: Scene) => void;
  60339. /**
  60340. * Instantiates a depth renderer
  60341. * @param scene The scene the renderer belongs to
  60342. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60343. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60344. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60345. */
  60346. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60347. /**
  60348. * Creates the depth rendering effect and checks if the effect is ready.
  60349. * @param subMesh The submesh to be used to render the depth map of
  60350. * @param useInstances If multiple world instances should be used
  60351. * @returns if the depth renderer is ready to render the depth map
  60352. */
  60353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60354. /**
  60355. * Gets the texture which the depth map will be written to.
  60356. * @returns The depth map texture
  60357. */
  60358. getDepthMap(): RenderTargetTexture;
  60359. /**
  60360. * Disposes of the depth renderer.
  60361. */
  60362. dispose(): void;
  60363. }
  60364. }
  60365. declare module BABYLON {
  60366. /** @hidden */
  60367. export var minmaxReduxPixelShader: {
  60368. name: string;
  60369. shader: string;
  60370. };
  60371. }
  60372. declare module BABYLON {
  60373. /**
  60374. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60375. * and maximum values from all values of the texture.
  60376. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60377. * The source values are read from the red channel of the texture.
  60378. */
  60379. export class MinMaxReducer {
  60380. /**
  60381. * Observable triggered when the computation has been performed
  60382. */
  60383. onAfterReductionPerformed: Observable<{
  60384. min: number;
  60385. max: number;
  60386. }>;
  60387. protected _camera: Camera;
  60388. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60389. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60390. protected _postProcessManager: PostProcessManager;
  60391. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60392. protected _forceFullscreenViewport: boolean;
  60393. /**
  60394. * Creates a min/max reducer
  60395. * @param camera The camera to use for the post processes
  60396. */
  60397. constructor(camera: Camera);
  60398. /**
  60399. * Gets the texture used to read the values from.
  60400. */
  60401. get sourceTexture(): Nullable<RenderTargetTexture>;
  60402. /**
  60403. * Sets the source texture to read the values from.
  60404. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60405. * because in such textures '1' value must not be taken into account to compute the maximum
  60406. * as this value is used to clear the texture.
  60407. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60408. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60409. * @param depthRedux Indicates if the texture is a depth texture or not
  60410. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60411. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60412. */
  60413. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60414. /**
  60415. * Defines the refresh rate of the computation.
  60416. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60417. */
  60418. get refreshRate(): number;
  60419. set refreshRate(value: number);
  60420. protected _activated: boolean;
  60421. /**
  60422. * Gets the activation status of the reducer
  60423. */
  60424. get activated(): boolean;
  60425. /**
  60426. * Activates the reduction computation.
  60427. * When activated, the observers registered in onAfterReductionPerformed are
  60428. * called after the compuation is performed
  60429. */
  60430. activate(): void;
  60431. /**
  60432. * Deactivates the reduction computation.
  60433. */
  60434. deactivate(): void;
  60435. /**
  60436. * Disposes the min/max reducer
  60437. * @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.
  60438. */
  60439. dispose(disposeAll?: boolean): void;
  60440. }
  60441. }
  60442. declare module BABYLON {
  60443. /**
  60444. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60445. */
  60446. export class DepthReducer extends MinMaxReducer {
  60447. private _depthRenderer;
  60448. private _depthRendererId;
  60449. /**
  60450. * Gets the depth renderer used for the computation.
  60451. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60452. */
  60453. get depthRenderer(): Nullable<DepthRenderer>;
  60454. /**
  60455. * Creates a depth reducer
  60456. * @param camera The camera used to render the depth texture
  60457. */
  60458. constructor(camera: Camera);
  60459. /**
  60460. * Sets the depth renderer to use to generate the depth map
  60461. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60462. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60463. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60464. */
  60465. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60466. /** @hidden */
  60467. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60468. /**
  60469. * Activates the reduction computation.
  60470. * When activated, the observers registered in onAfterReductionPerformed are
  60471. * called after the compuation is performed
  60472. */
  60473. activate(): void;
  60474. /**
  60475. * Deactivates the reduction computation.
  60476. */
  60477. deactivate(): void;
  60478. /**
  60479. * Disposes the depth reducer
  60480. * @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.
  60481. */
  60482. dispose(disposeAll?: boolean): void;
  60483. }
  60484. }
  60485. declare module BABYLON {
  60486. /**
  60487. * A CSM implementation allowing casting shadows on large scenes.
  60488. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60489. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60490. */
  60491. export class CascadedShadowGenerator extends ShadowGenerator {
  60492. private static readonly frustumCornersNDCSpace;
  60493. /**
  60494. * Name of the CSM class
  60495. */
  60496. static CLASSNAME: string;
  60497. /**
  60498. * Defines the default number of cascades used by the CSM.
  60499. */
  60500. static readonly DEFAULT_CASCADES_COUNT: number;
  60501. /**
  60502. * Defines the minimum number of cascades used by the CSM.
  60503. */
  60504. static readonly MIN_CASCADES_COUNT: number;
  60505. /**
  60506. * Defines the maximum number of cascades used by the CSM.
  60507. */
  60508. static readonly MAX_CASCADES_COUNT: number;
  60509. protected _validateFilter(filter: number): number;
  60510. /**
  60511. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60512. */
  60513. penumbraDarkness: number;
  60514. private _numCascades;
  60515. /**
  60516. * Gets or set the number of cascades used by the CSM.
  60517. */
  60518. get numCascades(): number;
  60519. set numCascades(value: number);
  60520. /**
  60521. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60522. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60523. */
  60524. stabilizeCascades: boolean;
  60525. private _freezeShadowCastersBoundingInfo;
  60526. private _freezeShadowCastersBoundingInfoObservable;
  60527. /**
  60528. * Enables or disables the shadow casters bounding info computation.
  60529. * If your shadow casters don't move, you can disable this feature.
  60530. * If it is enabled, the bounding box computation is done every frame.
  60531. */
  60532. get freezeShadowCastersBoundingInfo(): boolean;
  60533. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60534. private _scbiMin;
  60535. private _scbiMax;
  60536. protected _computeShadowCastersBoundingInfo(): void;
  60537. protected _shadowCastersBoundingInfo: BoundingInfo;
  60538. /**
  60539. * Gets or sets the shadow casters bounding info.
  60540. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60541. * so that the system won't overwrite the bounds you provide
  60542. */
  60543. get shadowCastersBoundingInfo(): BoundingInfo;
  60544. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60545. protected _breaksAreDirty: boolean;
  60546. protected _minDistance: number;
  60547. protected _maxDistance: number;
  60548. /**
  60549. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60550. *
  60551. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60552. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60553. * @param min minimal distance for the breaks (default to 0.)
  60554. * @param max maximal distance for the breaks (default to 1.)
  60555. */
  60556. setMinMaxDistance(min: number, max: number): void;
  60557. /** Gets the minimal distance used in the cascade break computation */
  60558. get minDistance(): number;
  60559. /** Gets the maximal distance used in the cascade break computation */
  60560. get maxDistance(): number;
  60561. /**
  60562. * Gets the class name of that object
  60563. * @returns "CascadedShadowGenerator"
  60564. */
  60565. getClassName(): string;
  60566. private _cascadeMinExtents;
  60567. private _cascadeMaxExtents;
  60568. /**
  60569. * Gets a cascade minimum extents
  60570. * @param cascadeIndex index of the cascade
  60571. * @returns the minimum cascade extents
  60572. */
  60573. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60574. /**
  60575. * Gets a cascade maximum extents
  60576. * @param cascadeIndex index of the cascade
  60577. * @returns the maximum cascade extents
  60578. */
  60579. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60580. private _cascades;
  60581. private _currentLayer;
  60582. private _viewSpaceFrustumsZ;
  60583. private _viewMatrices;
  60584. private _projectionMatrices;
  60585. private _transformMatrices;
  60586. private _transformMatricesAsArray;
  60587. private _frustumLengths;
  60588. private _lightSizeUVCorrection;
  60589. private _depthCorrection;
  60590. private _frustumCornersWorldSpace;
  60591. private _frustumCenter;
  60592. private _shadowCameraPos;
  60593. private _shadowMaxZ;
  60594. /**
  60595. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60596. * It defaults to camera.maxZ
  60597. */
  60598. get shadowMaxZ(): number;
  60599. /**
  60600. * Sets the shadow max z distance.
  60601. */
  60602. set shadowMaxZ(value: number);
  60603. protected _debug: boolean;
  60604. /**
  60605. * Gets or sets the debug flag.
  60606. * When enabled, the cascades are materialized by different colors on the screen.
  60607. */
  60608. get debug(): boolean;
  60609. set debug(dbg: boolean);
  60610. private _depthClamp;
  60611. /**
  60612. * Gets or sets the depth clamping value.
  60613. *
  60614. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60615. * to account for the shadow casters far away.
  60616. *
  60617. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60618. */
  60619. get depthClamp(): boolean;
  60620. set depthClamp(value: boolean);
  60621. private _cascadeBlendPercentage;
  60622. /**
  60623. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60624. * It defaults to 0.1 (10% blending).
  60625. */
  60626. get cascadeBlendPercentage(): number;
  60627. set cascadeBlendPercentage(value: number);
  60628. private _lambda;
  60629. /**
  60630. * Gets or set the lambda parameter.
  60631. * This parameter is used to split the camera frustum and create the cascades.
  60632. * 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.
  60633. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60634. */
  60635. get lambda(): number;
  60636. set lambda(value: number);
  60637. /**
  60638. * Gets the view matrix corresponding to a given cascade
  60639. * @param cascadeNum cascade to retrieve the view matrix from
  60640. * @returns the cascade view matrix
  60641. */
  60642. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60643. /**
  60644. * Gets the projection matrix corresponding to a given cascade
  60645. * @param cascadeNum cascade to retrieve the projection matrix from
  60646. * @returns the cascade projection matrix
  60647. */
  60648. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60649. /**
  60650. * Gets the transformation matrix corresponding to a given cascade
  60651. * @param cascadeNum cascade to retrieve the transformation matrix from
  60652. * @returns the cascade transformation matrix
  60653. */
  60654. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60655. private _depthRenderer;
  60656. /**
  60657. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60658. *
  60659. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60660. *
  60661. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60662. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60663. * @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
  60664. */
  60665. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60666. private _depthReducer;
  60667. private _autoCalcDepthBounds;
  60668. /**
  60669. * Gets or sets the autoCalcDepthBounds property.
  60670. *
  60671. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60672. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60673. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60674. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60675. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60676. */
  60677. get autoCalcDepthBounds(): boolean;
  60678. set autoCalcDepthBounds(value: boolean);
  60679. /**
  60680. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60681. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60682. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60683. * for setting the refresh rate on the renderer yourself!
  60684. */
  60685. get autoCalcDepthBoundsRefreshRate(): number;
  60686. set autoCalcDepthBoundsRefreshRate(value: number);
  60687. /**
  60688. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60689. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60690. * you change the camera near/far planes!
  60691. */
  60692. splitFrustum(): void;
  60693. private _splitFrustum;
  60694. private _computeMatrices;
  60695. private _computeFrustumInWorldSpace;
  60696. private _computeCascadeFrustum;
  60697. /**
  60698. * Support test.
  60699. */
  60700. static get IsSupported(): boolean;
  60701. /** @hidden */
  60702. static _SceneComponentInitialization: (scene: Scene) => void;
  60703. /**
  60704. * Creates a Cascaded Shadow Generator object.
  60705. * A ShadowGenerator is the required tool to use the shadows.
  60706. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60707. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60708. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60709. * @param light The directional light object generating the shadows.
  60710. * @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.
  60711. */
  60712. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60713. protected _initializeGenerator(): void;
  60714. protected _createTargetRenderTexture(): void;
  60715. protected _initializeShadowMap(): void;
  60716. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60717. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60718. /**
  60719. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60720. * @param defines Defines of the material we want to update
  60721. * @param lightIndex Index of the light in the enabled light list of the material
  60722. */
  60723. prepareDefines(defines: any, lightIndex: number): void;
  60724. /**
  60725. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60726. * defined in the generator but impacting the effect).
  60727. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60728. * @param effect The effect we are binfing the information for
  60729. */
  60730. bindShadowLight(lightIndex: string, effect: Effect): void;
  60731. /**
  60732. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60733. * (eq to view projection * shadow projection matrices)
  60734. * @returns The transform matrix used to create the shadow map
  60735. */
  60736. getTransformMatrix(): Matrix;
  60737. /**
  60738. * Disposes the ShadowGenerator.
  60739. * Returns nothing.
  60740. */
  60741. dispose(): void;
  60742. /**
  60743. * Serializes the shadow generator setup to a json object.
  60744. * @returns The serialized JSON object
  60745. */
  60746. serialize(): any;
  60747. /**
  60748. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60749. * @param parsedShadowGenerator The JSON object to parse
  60750. * @param scene The scene to create the shadow map for
  60751. * @returns The parsed shadow generator
  60752. */
  60753. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60754. }
  60755. }
  60756. declare module BABYLON {
  60757. /**
  60758. * Defines the shadow generator component responsible to manage any shadow generators
  60759. * in a given scene.
  60760. */
  60761. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60762. /**
  60763. * The component name helpfull to identify the component in the list of scene components.
  60764. */
  60765. readonly name: string;
  60766. /**
  60767. * The scene the component belongs to.
  60768. */
  60769. scene: Scene;
  60770. /**
  60771. * Creates a new instance of the component for the given scene
  60772. * @param scene Defines the scene to register the component in
  60773. */
  60774. constructor(scene: Scene);
  60775. /**
  60776. * Registers the component in a given scene
  60777. */
  60778. register(): void;
  60779. /**
  60780. * Rebuilds the elements related to this component in case of
  60781. * context lost for instance.
  60782. */
  60783. rebuild(): void;
  60784. /**
  60785. * Serializes the component data to the specified json object
  60786. * @param serializationObject The object to serialize to
  60787. */
  60788. serialize(serializationObject: any): void;
  60789. /**
  60790. * Adds all the elements from the container to the scene
  60791. * @param container the container holding the elements
  60792. */
  60793. addFromContainer(container: AbstractScene): void;
  60794. /**
  60795. * Removes all the elements in the container from the scene
  60796. * @param container contains the elements to remove
  60797. * @param dispose if the removed element should be disposed (default: false)
  60798. */
  60799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60800. /**
  60801. * Rebuilds the elements related to this component in case of
  60802. * context lost for instance.
  60803. */
  60804. dispose(): void;
  60805. private _gatherRenderTargets;
  60806. }
  60807. }
  60808. declare module BABYLON {
  60809. /**
  60810. * A point light is a light defined by an unique point in world space.
  60811. * The light is emitted in every direction from this point.
  60812. * A good example of a point light is a standard light bulb.
  60813. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60814. */
  60815. export class PointLight extends ShadowLight {
  60816. private _shadowAngle;
  60817. /**
  60818. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60819. * This specifies what angle the shadow will use to be created.
  60820. *
  60821. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60822. */
  60823. get shadowAngle(): number;
  60824. /**
  60825. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60826. * This specifies what angle the shadow will use to be created.
  60827. *
  60828. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60829. */
  60830. set shadowAngle(value: number);
  60831. /**
  60832. * Gets the direction if it has been set.
  60833. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60834. */
  60835. get direction(): Vector3;
  60836. /**
  60837. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60838. */
  60839. set direction(value: Vector3);
  60840. /**
  60841. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60842. * A PointLight emits the light in every direction.
  60843. * It can cast shadows.
  60844. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60845. * ```javascript
  60846. * var pointLight = new PointLight("pl", camera.position, scene);
  60847. * ```
  60848. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60849. * @param name The light friendly name
  60850. * @param position The position of the point light in the scene
  60851. * @param scene The scene the lights belongs to
  60852. */
  60853. constructor(name: string, position: Vector3, scene: Scene);
  60854. /**
  60855. * Returns the string "PointLight"
  60856. * @returns the class name
  60857. */
  60858. getClassName(): string;
  60859. /**
  60860. * Returns the integer 0.
  60861. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60862. */
  60863. getTypeID(): number;
  60864. /**
  60865. * Specifies wether or not the shadowmap should be a cube texture.
  60866. * @returns true if the shadowmap needs to be a cube texture.
  60867. */
  60868. needCube(): boolean;
  60869. /**
  60870. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60871. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60872. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60873. */
  60874. getShadowDirection(faceIndex?: number): Vector3;
  60875. /**
  60876. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60877. * - fov = PI / 2
  60878. * - aspect ratio : 1.0
  60879. * - z-near and far equal to the active camera minZ and maxZ.
  60880. * Returns the PointLight.
  60881. */
  60882. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60883. protected _buildUniformLayout(): void;
  60884. /**
  60885. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60886. * @param effect The effect to update
  60887. * @param lightIndex The index of the light in the effect to update
  60888. * @returns The point light
  60889. */
  60890. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60891. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60892. /**
  60893. * Prepares the list of defines specific to the light type.
  60894. * @param defines the list of defines
  60895. * @param lightIndex defines the index of the light for the effect
  60896. */
  60897. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Header information of HDR texture files.
  60903. */
  60904. export interface HDRInfo {
  60905. /**
  60906. * The height of the texture in pixels.
  60907. */
  60908. height: number;
  60909. /**
  60910. * The width of the texture in pixels.
  60911. */
  60912. width: number;
  60913. /**
  60914. * The index of the beginning of the data in the binary file.
  60915. */
  60916. dataPosition: number;
  60917. }
  60918. /**
  60919. * This groups tools to convert HDR texture to native colors array.
  60920. */
  60921. export class HDRTools {
  60922. private static Ldexp;
  60923. private static Rgbe2float;
  60924. private static readStringLine;
  60925. /**
  60926. * Reads header information from an RGBE texture stored in a native array.
  60927. * More information on this format are available here:
  60928. * https://en.wikipedia.org/wiki/RGBE_image_format
  60929. *
  60930. * @param uint8array The binary file stored in native array.
  60931. * @return The header information.
  60932. */
  60933. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60934. /**
  60935. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60936. * This RGBE texture needs to store the information as a panorama.
  60937. *
  60938. * More information on this format are available here:
  60939. * https://en.wikipedia.org/wiki/RGBE_image_format
  60940. *
  60941. * @param buffer The binary file stored in an array buffer.
  60942. * @param size The expected size of the extracted cubemap.
  60943. * @return The Cube Map information.
  60944. */
  60945. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60946. /**
  60947. * Returns the pixels data extracted from an RGBE texture.
  60948. * This pixels will be stored left to right up to down in the R G B order in one array.
  60949. *
  60950. * More information on this format are available here:
  60951. * https://en.wikipedia.org/wiki/RGBE_image_format
  60952. *
  60953. * @param uint8array The binary file stored in an array buffer.
  60954. * @param hdrInfo The header information of the file.
  60955. * @return The pixels data in RGB right to left up to down order.
  60956. */
  60957. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60958. private static RGBE_ReadPixels_RLE;
  60959. private static RGBE_ReadPixels_NOT_RLE;
  60960. }
  60961. }
  60962. declare module BABYLON {
  60963. /**
  60964. * Effect Render Options
  60965. */
  60966. export interface IEffectRendererOptions {
  60967. /**
  60968. * Defines the vertices positions.
  60969. */
  60970. positions?: number[];
  60971. /**
  60972. * Defines the indices.
  60973. */
  60974. indices?: number[];
  60975. }
  60976. /**
  60977. * Helper class to render one or more effects.
  60978. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60979. */
  60980. export class EffectRenderer {
  60981. private engine;
  60982. private static _DefaultOptions;
  60983. private _vertexBuffers;
  60984. private _indexBuffer;
  60985. private _fullscreenViewport;
  60986. /**
  60987. * Creates an effect renderer
  60988. * @param engine the engine to use for rendering
  60989. * @param options defines the options of the effect renderer
  60990. */
  60991. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60992. /**
  60993. * Sets the current viewport in normalized coordinates 0-1
  60994. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60995. */
  60996. setViewport(viewport?: Viewport): void;
  60997. /**
  60998. * Binds the embedded attributes buffer to the effect.
  60999. * @param effect Defines the effect to bind the attributes for
  61000. */
  61001. bindBuffers(effect: Effect): void;
  61002. /**
  61003. * Sets the current effect wrapper to use during draw.
  61004. * The effect needs to be ready before calling this api.
  61005. * This also sets the default full screen position attribute.
  61006. * @param effectWrapper Defines the effect to draw with
  61007. */
  61008. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61009. /**
  61010. * Restores engine states
  61011. */
  61012. restoreStates(): void;
  61013. /**
  61014. * Draws a full screen quad.
  61015. */
  61016. draw(): void;
  61017. private isRenderTargetTexture;
  61018. /**
  61019. * renders one or more effects to a specified texture
  61020. * @param effectWrapper the effect to renderer
  61021. * @param outputTexture texture to draw to, if null it will render to the screen.
  61022. */
  61023. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61024. /**
  61025. * Disposes of the effect renderer
  61026. */
  61027. dispose(): void;
  61028. }
  61029. /**
  61030. * Options to create an EffectWrapper
  61031. */
  61032. interface EffectWrapperCreationOptions {
  61033. /**
  61034. * Engine to use to create the effect
  61035. */
  61036. engine: ThinEngine;
  61037. /**
  61038. * Fragment shader for the effect
  61039. */
  61040. fragmentShader: string;
  61041. /**
  61042. * Use the shader store instead of direct source code
  61043. */
  61044. useShaderStore?: boolean;
  61045. /**
  61046. * Vertex shader for the effect
  61047. */
  61048. vertexShader?: string;
  61049. /**
  61050. * Attributes to use in the shader
  61051. */
  61052. attributeNames?: Array<string>;
  61053. /**
  61054. * Uniforms to use in the shader
  61055. */
  61056. uniformNames?: Array<string>;
  61057. /**
  61058. * Texture sampler names to use in the shader
  61059. */
  61060. samplerNames?: Array<string>;
  61061. /**
  61062. * Defines to use in the shader
  61063. */
  61064. defines?: Array<string>;
  61065. /**
  61066. * Callback when effect is compiled
  61067. */
  61068. onCompiled?: Nullable<(effect: Effect) => void>;
  61069. /**
  61070. * The friendly name of the effect displayed in Spector.
  61071. */
  61072. name?: string;
  61073. }
  61074. /**
  61075. * Wraps an effect to be used for rendering
  61076. */
  61077. export class EffectWrapper {
  61078. /**
  61079. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61080. */
  61081. onApplyObservable: Observable<{}>;
  61082. /**
  61083. * The underlying effect
  61084. */
  61085. effect: Effect;
  61086. /**
  61087. * Creates an effect to be renderer
  61088. * @param creationOptions options to create the effect
  61089. */
  61090. constructor(creationOptions: EffectWrapperCreationOptions);
  61091. /**
  61092. * Disposes of the effect wrapper
  61093. */
  61094. dispose(): void;
  61095. }
  61096. }
  61097. declare module BABYLON {
  61098. /** @hidden */
  61099. export var hdrFilteringVertexShader: {
  61100. name: string;
  61101. shader: string;
  61102. };
  61103. }
  61104. declare module BABYLON {
  61105. /** @hidden */
  61106. export var hdrFilteringPixelShader: {
  61107. name: string;
  61108. shader: string;
  61109. };
  61110. }
  61111. declare module BABYLON {
  61112. /**
  61113. * Options for texture filtering
  61114. */
  61115. interface IHDRFilteringOptions {
  61116. /**
  61117. * Scales pixel intensity for the input HDR map.
  61118. */
  61119. hdrScale?: number;
  61120. /**
  61121. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61122. */
  61123. quality?: number;
  61124. }
  61125. /**
  61126. * Filters HDR maps to get correct renderings of PBR reflections
  61127. */
  61128. export class HDRFiltering {
  61129. private _engine;
  61130. private _effectRenderer;
  61131. private _effectWrapper;
  61132. private _lodGenerationOffset;
  61133. private _lodGenerationScale;
  61134. /**
  61135. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61136. * you care about baking speed.
  61137. */
  61138. quality: number;
  61139. /**
  61140. * Scales pixel intensity for the input HDR map.
  61141. */
  61142. hdrScale: number;
  61143. /**
  61144. * Instantiates HDR filter for reflection maps
  61145. *
  61146. * @param engine Thin engine
  61147. * @param options Options
  61148. */
  61149. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61150. private _createRenderTarget;
  61151. private _prefilterInternal;
  61152. private _createEffect;
  61153. /**
  61154. * Get a value indicating if the filter is ready to be used
  61155. * @param texture Texture to filter
  61156. * @returns true if the filter is ready
  61157. */
  61158. isReady(texture: BaseTexture): boolean;
  61159. /**
  61160. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61161. * Prefiltering will be invoked at the end of next rendering pass.
  61162. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61163. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61164. * @param texture Texture to filter
  61165. * @param onFinished Callback when filtering is done
  61166. * @return Promise called when prefiltering is done
  61167. */
  61168. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61169. }
  61170. }
  61171. declare module BABYLON {
  61172. /**
  61173. * This represents a texture coming from an HDR input.
  61174. *
  61175. * The only supported format is currently panorama picture stored in RGBE format.
  61176. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61177. */
  61178. export class HDRCubeTexture extends BaseTexture {
  61179. private static _facesMapping;
  61180. private _generateHarmonics;
  61181. private _noMipmap;
  61182. private _prefilterOnLoad;
  61183. private _textureMatrix;
  61184. private _size;
  61185. private _onLoad;
  61186. private _onError;
  61187. /**
  61188. * The texture URL.
  61189. */
  61190. url: string;
  61191. protected _isBlocking: boolean;
  61192. /**
  61193. * Sets wether or not the texture is blocking during loading.
  61194. */
  61195. set isBlocking(value: boolean);
  61196. /**
  61197. * Gets wether or not the texture is blocking during loading.
  61198. */
  61199. get isBlocking(): boolean;
  61200. protected _rotationY: number;
  61201. /**
  61202. * Sets texture matrix rotation angle around Y axis in radians.
  61203. */
  61204. set rotationY(value: number);
  61205. /**
  61206. * Gets texture matrix rotation angle around Y axis radians.
  61207. */
  61208. get rotationY(): number;
  61209. /**
  61210. * Gets or sets the center of the bounding box associated with the cube texture
  61211. * It must define where the camera used to render the texture was set
  61212. */
  61213. boundingBoxPosition: Vector3;
  61214. private _boundingBoxSize;
  61215. /**
  61216. * Gets or sets the size of the bounding box associated with the cube texture
  61217. * When defined, the cubemap will switch to local mode
  61218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61219. * @example https://www.babylonjs-playground.com/#RNASML
  61220. */
  61221. set boundingBoxSize(value: Vector3);
  61222. get boundingBoxSize(): Vector3;
  61223. /**
  61224. * Instantiates an HDRTexture from the following parameters.
  61225. *
  61226. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61227. * @param sceneOrEngine The scene or engine the texture will be used in
  61228. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61229. * @param noMipmap Forces to not generate the mipmap if true
  61230. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61231. * @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)
  61232. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61233. */
  61234. 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>);
  61235. /**
  61236. * Get the current class name of the texture useful for serialization or dynamic coding.
  61237. * @returns "HDRCubeTexture"
  61238. */
  61239. getClassName(): string;
  61240. /**
  61241. * Occurs when the file is raw .hdr file.
  61242. */
  61243. private loadTexture;
  61244. clone(): HDRCubeTexture;
  61245. delayLoad(): void;
  61246. /**
  61247. * Get the texture reflection matrix used to rotate/transform the reflection.
  61248. * @returns the reflection matrix
  61249. */
  61250. getReflectionTextureMatrix(): Matrix;
  61251. /**
  61252. * Set the texture reflection matrix used to rotate/transform the reflection.
  61253. * @param value Define the reflection matrix to set
  61254. */
  61255. setReflectionTextureMatrix(value: Matrix): void;
  61256. /**
  61257. * Parses a JSON representation of an HDR Texture in order to create the texture
  61258. * @param parsedTexture Define the JSON representation
  61259. * @param scene Define the scene the texture should be created in
  61260. * @param rootUrl Define the root url in case we need to load relative dependencies
  61261. * @returns the newly created texture after parsing
  61262. */
  61263. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61264. serialize(): any;
  61265. }
  61266. }
  61267. declare module BABYLON {
  61268. /**
  61269. * Class used to control physics engine
  61270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61271. */
  61272. export class PhysicsEngine implements IPhysicsEngine {
  61273. private _physicsPlugin;
  61274. /**
  61275. * Global value used to control the smallest number supported by the simulation
  61276. */
  61277. static Epsilon: number;
  61278. private _impostors;
  61279. private _joints;
  61280. private _subTimeStep;
  61281. /**
  61282. * Gets the gravity vector used by the simulation
  61283. */
  61284. gravity: Vector3;
  61285. /**
  61286. * Factory used to create the default physics plugin.
  61287. * @returns The default physics plugin
  61288. */
  61289. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61290. /**
  61291. * Creates a new Physics Engine
  61292. * @param gravity defines the gravity vector used by the simulation
  61293. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61294. */
  61295. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61296. /**
  61297. * Sets the gravity vector used by the simulation
  61298. * @param gravity defines the gravity vector to use
  61299. */
  61300. setGravity(gravity: Vector3): void;
  61301. /**
  61302. * Set the time step of the physics engine.
  61303. * Default is 1/60.
  61304. * To slow it down, enter 1/600 for example.
  61305. * To speed it up, 1/30
  61306. * @param newTimeStep defines the new timestep to apply to this world.
  61307. */
  61308. setTimeStep(newTimeStep?: number): void;
  61309. /**
  61310. * Get the time step of the physics engine.
  61311. * @returns the current time step
  61312. */
  61313. getTimeStep(): number;
  61314. /**
  61315. * Set the sub time step of the physics engine.
  61316. * Default is 0 meaning there is no sub steps
  61317. * To increase physics resolution precision, set a small value (like 1 ms)
  61318. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61319. */
  61320. setSubTimeStep(subTimeStep?: number): void;
  61321. /**
  61322. * Get the sub time step of the physics engine.
  61323. * @returns the current sub time step
  61324. */
  61325. getSubTimeStep(): number;
  61326. /**
  61327. * Release all resources
  61328. */
  61329. dispose(): void;
  61330. /**
  61331. * Gets the name of the current physics plugin
  61332. * @returns the name of the plugin
  61333. */
  61334. getPhysicsPluginName(): string;
  61335. /**
  61336. * Adding a new impostor for the impostor tracking.
  61337. * This will be done by the impostor itself.
  61338. * @param impostor the impostor to add
  61339. */
  61340. addImpostor(impostor: PhysicsImpostor): void;
  61341. /**
  61342. * Remove an impostor from the engine.
  61343. * This impostor and its mesh will not longer be updated by the physics engine.
  61344. * @param impostor the impostor to remove
  61345. */
  61346. removeImpostor(impostor: PhysicsImpostor): void;
  61347. /**
  61348. * Add a joint to the physics engine
  61349. * @param mainImpostor defines the main impostor to which the joint is added.
  61350. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61351. * @param joint defines the joint that will connect both impostors.
  61352. */
  61353. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61354. /**
  61355. * Removes a joint from the simulation
  61356. * @param mainImpostor defines the impostor used with the joint
  61357. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61358. * @param joint defines the joint to remove
  61359. */
  61360. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61361. /**
  61362. * Called by the scene. No need to call it.
  61363. * @param delta defines the timespam between frames
  61364. */
  61365. _step(delta: number): void;
  61366. /**
  61367. * Gets the current plugin used to run the simulation
  61368. * @returns current plugin
  61369. */
  61370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61371. /**
  61372. * Gets the list of physic impostors
  61373. * @returns an array of PhysicsImpostor
  61374. */
  61375. getImpostors(): Array<PhysicsImpostor>;
  61376. /**
  61377. * Gets the impostor for a physics enabled object
  61378. * @param object defines the object impersonated by the impostor
  61379. * @returns the PhysicsImpostor or null if not found
  61380. */
  61381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61382. /**
  61383. * Gets the impostor for a physics body object
  61384. * @param body defines physics body used by the impostor
  61385. * @returns the PhysicsImpostor or null if not found
  61386. */
  61387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61388. /**
  61389. * Does a raycast in the physics world
  61390. * @param from when should the ray start?
  61391. * @param to when should the ray end?
  61392. * @returns PhysicsRaycastResult
  61393. */
  61394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61395. }
  61396. }
  61397. declare module BABYLON {
  61398. /** @hidden */
  61399. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61400. private _useDeltaForWorldStep;
  61401. world: any;
  61402. name: string;
  61403. private _physicsMaterials;
  61404. private _fixedTimeStep;
  61405. private _cannonRaycastResult;
  61406. private _raycastResult;
  61407. private _physicsBodysToRemoveAfterStep;
  61408. private _firstFrame;
  61409. BJSCANNON: any;
  61410. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61411. setGravity(gravity: Vector3): void;
  61412. setTimeStep(timeStep: number): void;
  61413. getTimeStep(): number;
  61414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61415. private _removeMarkedPhysicsBodiesFromWorld;
  61416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61419. private _processChildMeshes;
  61420. removePhysicsBody(impostor: PhysicsImpostor): void;
  61421. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61422. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61423. private _addMaterial;
  61424. private _checkWithEpsilon;
  61425. private _createShape;
  61426. private _createHeightmap;
  61427. private _minus90X;
  61428. private _plus90X;
  61429. private _tmpPosition;
  61430. private _tmpDeltaPosition;
  61431. private _tmpUnityRotation;
  61432. private _updatePhysicsBodyTransformation;
  61433. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61434. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61435. isSupported(): boolean;
  61436. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61437. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61438. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61439. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61440. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61441. getBodyMass(impostor: PhysicsImpostor): number;
  61442. getBodyFriction(impostor: PhysicsImpostor): number;
  61443. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61444. getBodyRestitution(impostor: PhysicsImpostor): number;
  61445. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61446. sleepBody(impostor: PhysicsImpostor): void;
  61447. wakeUpBody(impostor: PhysicsImpostor): void;
  61448. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61449. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61450. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61451. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61452. getRadius(impostor: PhysicsImpostor): number;
  61453. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61454. dispose(): void;
  61455. private _extendNamespace;
  61456. /**
  61457. * Does a raycast in the physics world
  61458. * @param from when should the ray start?
  61459. * @param to when should the ray end?
  61460. * @returns PhysicsRaycastResult
  61461. */
  61462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61463. }
  61464. }
  61465. declare module BABYLON {
  61466. /** @hidden */
  61467. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61468. private _useDeltaForWorldStep;
  61469. world: any;
  61470. name: string;
  61471. BJSOIMO: any;
  61472. private _raycastResult;
  61473. private _fixedTimeStep;
  61474. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61475. setGravity(gravity: Vector3): void;
  61476. setTimeStep(timeStep: number): void;
  61477. getTimeStep(): number;
  61478. private _tmpImpostorsArray;
  61479. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61480. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61481. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61482. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61483. private _tmpPositionVector;
  61484. removePhysicsBody(impostor: PhysicsImpostor): void;
  61485. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61486. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61487. isSupported(): boolean;
  61488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61495. getBodyMass(impostor: PhysicsImpostor): number;
  61496. getBodyFriction(impostor: PhysicsImpostor): number;
  61497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61498. getBodyRestitution(impostor: PhysicsImpostor): number;
  61499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61500. sleepBody(impostor: PhysicsImpostor): void;
  61501. wakeUpBody(impostor: PhysicsImpostor): void;
  61502. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61503. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61504. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61505. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61506. getRadius(impostor: PhysicsImpostor): number;
  61507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61508. dispose(): void;
  61509. /**
  61510. * Does a raycast in the physics world
  61511. * @param from when should the ray start?
  61512. * @param to when should the ray end?
  61513. * @returns PhysicsRaycastResult
  61514. */
  61515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61516. }
  61517. }
  61518. declare module BABYLON {
  61519. /**
  61520. * AmmoJS Physics plugin
  61521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61522. * @see https://github.com/kripken/ammo.js/
  61523. */
  61524. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61525. private _useDeltaForWorldStep;
  61526. /**
  61527. * Reference to the Ammo library
  61528. */
  61529. bjsAMMO: any;
  61530. /**
  61531. * Created ammoJS world which physics bodies are added to
  61532. */
  61533. world: any;
  61534. /**
  61535. * Name of the plugin
  61536. */
  61537. name: string;
  61538. private _timeStep;
  61539. private _fixedTimeStep;
  61540. private _maxSteps;
  61541. private _tmpQuaternion;
  61542. private _tmpAmmoTransform;
  61543. private _tmpAmmoQuaternion;
  61544. private _tmpAmmoConcreteContactResultCallback;
  61545. private _collisionConfiguration;
  61546. private _dispatcher;
  61547. private _overlappingPairCache;
  61548. private _solver;
  61549. private _softBodySolver;
  61550. private _tmpAmmoVectorA;
  61551. private _tmpAmmoVectorB;
  61552. private _tmpAmmoVectorC;
  61553. private _tmpAmmoVectorD;
  61554. private _tmpContactCallbackResult;
  61555. private _tmpAmmoVectorRCA;
  61556. private _tmpAmmoVectorRCB;
  61557. private _raycastResult;
  61558. private _tmpContactPoint;
  61559. private static readonly DISABLE_COLLISION_FLAG;
  61560. private static readonly KINEMATIC_FLAG;
  61561. private static readonly DISABLE_DEACTIVATION_FLAG;
  61562. /**
  61563. * Initializes the ammoJS plugin
  61564. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61565. * @param ammoInjection can be used to inject your own ammo reference
  61566. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61567. */
  61568. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61569. /**
  61570. * Sets the gravity of the physics world (m/(s^2))
  61571. * @param gravity Gravity to set
  61572. */
  61573. setGravity(gravity: Vector3): void;
  61574. /**
  61575. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61576. * @param timeStep timestep to use in seconds
  61577. */
  61578. setTimeStep(timeStep: number): void;
  61579. /**
  61580. * 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)
  61581. * @param fixedTimeStep fixedTimeStep to use in seconds
  61582. */
  61583. setFixedTimeStep(fixedTimeStep: number): void;
  61584. /**
  61585. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61586. * @param maxSteps the maximum number of steps by the physics engine per frame
  61587. */
  61588. setMaxSteps(maxSteps: number): void;
  61589. /**
  61590. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61591. * @returns the current timestep in seconds
  61592. */
  61593. getTimeStep(): number;
  61594. /**
  61595. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61596. */
  61597. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61598. private _isImpostorInContact;
  61599. private _isImpostorPairInContact;
  61600. private _stepSimulation;
  61601. /**
  61602. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61603. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61604. * After the step the babylon meshes are set to the position of the physics imposters
  61605. * @param delta amount of time to step forward
  61606. * @param impostors array of imposters to update before/after the step
  61607. */
  61608. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61609. /**
  61610. * Update babylon mesh to match physics world object
  61611. * @param impostor imposter to match
  61612. */
  61613. private _afterSoftStep;
  61614. /**
  61615. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61616. * @param impostor imposter to match
  61617. */
  61618. private _ropeStep;
  61619. /**
  61620. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61621. * @param impostor imposter to match
  61622. */
  61623. private _softbodyOrClothStep;
  61624. private _tmpMatrix;
  61625. /**
  61626. * Applies an impulse on the imposter
  61627. * @param impostor imposter to apply impulse to
  61628. * @param force amount of force to be applied to the imposter
  61629. * @param contactPoint the location to apply the impulse on the imposter
  61630. */
  61631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61632. /**
  61633. * Applies a force on the imposter
  61634. * @param impostor imposter to apply force
  61635. * @param force amount of force to be applied to the imposter
  61636. * @param contactPoint the location to apply the force on the imposter
  61637. */
  61638. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61639. /**
  61640. * Creates a physics body using the plugin
  61641. * @param impostor the imposter to create the physics body on
  61642. */
  61643. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61644. /**
  61645. * Removes the physics body from the imposter and disposes of the body's memory
  61646. * @param impostor imposter to remove the physics body from
  61647. */
  61648. removePhysicsBody(impostor: PhysicsImpostor): void;
  61649. /**
  61650. * Generates a joint
  61651. * @param impostorJoint the imposter joint to create the joint with
  61652. */
  61653. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61654. /**
  61655. * Removes a joint
  61656. * @param impostorJoint the imposter joint to remove the joint from
  61657. */
  61658. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61659. private _addMeshVerts;
  61660. /**
  61661. * Initialise the soft body vertices to match its object's (mesh) vertices
  61662. * Softbody vertices (nodes) are in world space and to match this
  61663. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61664. * @param impostor to create the softbody for
  61665. */
  61666. private _softVertexData;
  61667. /**
  61668. * Create an impostor's soft body
  61669. * @param impostor to create the softbody for
  61670. */
  61671. private _createSoftbody;
  61672. /**
  61673. * Create cloth for an impostor
  61674. * @param impostor to create the softbody for
  61675. */
  61676. private _createCloth;
  61677. /**
  61678. * Create rope for an impostor
  61679. * @param impostor to create the softbody for
  61680. */
  61681. private _createRope;
  61682. /**
  61683. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61684. * @param impostor to create the custom physics shape for
  61685. */
  61686. private _createCustom;
  61687. private _addHullVerts;
  61688. private _createShape;
  61689. /**
  61690. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61691. * @param impostor imposter containing the physics body and babylon object
  61692. */
  61693. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61694. /**
  61695. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61696. * @param impostor imposter containing the physics body and babylon object
  61697. * @param newPosition new position
  61698. * @param newRotation new rotation
  61699. */
  61700. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61701. /**
  61702. * If this plugin is supported
  61703. * @returns true if its supported
  61704. */
  61705. isSupported(): boolean;
  61706. /**
  61707. * Sets the linear velocity of the physics body
  61708. * @param impostor imposter to set the velocity on
  61709. * @param velocity velocity to set
  61710. */
  61711. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61712. /**
  61713. * Sets the angular velocity of the physics body
  61714. * @param impostor imposter to set the velocity on
  61715. * @param velocity velocity to set
  61716. */
  61717. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61718. /**
  61719. * gets the linear velocity
  61720. * @param impostor imposter to get linear velocity from
  61721. * @returns linear velocity
  61722. */
  61723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61724. /**
  61725. * gets the angular velocity
  61726. * @param impostor imposter to get angular velocity from
  61727. * @returns angular velocity
  61728. */
  61729. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61730. /**
  61731. * Sets the mass of physics body
  61732. * @param impostor imposter to set the mass on
  61733. * @param mass mass to set
  61734. */
  61735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61736. /**
  61737. * Gets the mass of the physics body
  61738. * @param impostor imposter to get the mass from
  61739. * @returns mass
  61740. */
  61741. getBodyMass(impostor: PhysicsImpostor): number;
  61742. /**
  61743. * Gets friction of the impostor
  61744. * @param impostor impostor to get friction from
  61745. * @returns friction value
  61746. */
  61747. getBodyFriction(impostor: PhysicsImpostor): number;
  61748. /**
  61749. * Sets friction of the impostor
  61750. * @param impostor impostor to set friction on
  61751. * @param friction friction value
  61752. */
  61753. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61754. /**
  61755. * Gets restitution of the impostor
  61756. * @param impostor impostor to get restitution from
  61757. * @returns restitution value
  61758. */
  61759. getBodyRestitution(impostor: PhysicsImpostor): number;
  61760. /**
  61761. * Sets resitution of the impostor
  61762. * @param impostor impostor to set resitution on
  61763. * @param restitution resitution value
  61764. */
  61765. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61766. /**
  61767. * Gets pressure inside the impostor
  61768. * @param impostor impostor to get pressure from
  61769. * @returns pressure value
  61770. */
  61771. getBodyPressure(impostor: PhysicsImpostor): number;
  61772. /**
  61773. * Sets pressure inside a soft body impostor
  61774. * Cloth and rope must remain 0 pressure
  61775. * @param impostor impostor to set pressure on
  61776. * @param pressure pressure value
  61777. */
  61778. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61779. /**
  61780. * Gets stiffness of the impostor
  61781. * @param impostor impostor to get stiffness from
  61782. * @returns pressure value
  61783. */
  61784. getBodyStiffness(impostor: PhysicsImpostor): number;
  61785. /**
  61786. * Sets stiffness of the impostor
  61787. * @param impostor impostor to set stiffness on
  61788. * @param stiffness stiffness value from 0 to 1
  61789. */
  61790. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61791. /**
  61792. * Gets velocityIterations of the impostor
  61793. * @param impostor impostor to get velocity iterations from
  61794. * @returns velocityIterations value
  61795. */
  61796. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61797. /**
  61798. * Sets velocityIterations of the impostor
  61799. * @param impostor impostor to set velocity iterations on
  61800. * @param velocityIterations velocityIterations value
  61801. */
  61802. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61803. /**
  61804. * Gets positionIterations of the impostor
  61805. * @param impostor impostor to get position iterations from
  61806. * @returns positionIterations value
  61807. */
  61808. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61809. /**
  61810. * Sets positionIterations of the impostor
  61811. * @param impostor impostor to set position on
  61812. * @param positionIterations positionIterations value
  61813. */
  61814. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61815. /**
  61816. * Append an anchor to a cloth object
  61817. * @param impostor is the cloth impostor to add anchor to
  61818. * @param otherImpostor is the rigid impostor to anchor to
  61819. * @param width ratio across width from 0 to 1
  61820. * @param height ratio up height from 0 to 1
  61821. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61822. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61823. */
  61824. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61825. /**
  61826. * Append an hook to a rope object
  61827. * @param impostor is the rope impostor to add hook to
  61828. * @param otherImpostor is the rigid impostor to hook to
  61829. * @param length ratio along the rope from 0 to 1
  61830. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61831. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61832. */
  61833. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61834. /**
  61835. * Sleeps the physics body and stops it from being active
  61836. * @param impostor impostor to sleep
  61837. */
  61838. sleepBody(impostor: PhysicsImpostor): void;
  61839. /**
  61840. * Activates the physics body
  61841. * @param impostor impostor to activate
  61842. */
  61843. wakeUpBody(impostor: PhysicsImpostor): void;
  61844. /**
  61845. * Updates the distance parameters of the joint
  61846. * @param joint joint to update
  61847. * @param maxDistance maximum distance of the joint
  61848. * @param minDistance minimum distance of the joint
  61849. */
  61850. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61851. /**
  61852. * Sets a motor on the joint
  61853. * @param joint joint to set motor on
  61854. * @param speed speed of the motor
  61855. * @param maxForce maximum force of the motor
  61856. * @param motorIndex index of the motor
  61857. */
  61858. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61859. /**
  61860. * Sets the motors limit
  61861. * @param joint joint to set limit on
  61862. * @param upperLimit upper limit
  61863. * @param lowerLimit lower limit
  61864. */
  61865. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61866. /**
  61867. * Syncs the position and rotation of a mesh with the impostor
  61868. * @param mesh mesh to sync
  61869. * @param impostor impostor to update the mesh with
  61870. */
  61871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61872. /**
  61873. * Gets the radius of the impostor
  61874. * @param impostor impostor to get radius from
  61875. * @returns the radius
  61876. */
  61877. getRadius(impostor: PhysicsImpostor): number;
  61878. /**
  61879. * Gets the box size of the impostor
  61880. * @param impostor impostor to get box size from
  61881. * @param result the resulting box size
  61882. */
  61883. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61884. /**
  61885. * Disposes of the impostor
  61886. */
  61887. dispose(): void;
  61888. /**
  61889. * Does a raycast in the physics world
  61890. * @param from when should the ray start?
  61891. * @param to when should the ray end?
  61892. * @returns PhysicsRaycastResult
  61893. */
  61894. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61895. }
  61896. }
  61897. declare module BABYLON {
  61898. interface AbstractScene {
  61899. /**
  61900. * The list of reflection probes added to the scene
  61901. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61902. */
  61903. reflectionProbes: Array<ReflectionProbe>;
  61904. /**
  61905. * Removes the given reflection probe from this scene.
  61906. * @param toRemove The reflection probe to remove
  61907. * @returns The index of the removed reflection probe
  61908. */
  61909. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61910. /**
  61911. * Adds the given reflection probe to this scene.
  61912. * @param newReflectionProbe The reflection probe to add
  61913. */
  61914. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61915. }
  61916. /**
  61917. * Class used to generate realtime reflection / refraction cube textures
  61918. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61919. */
  61920. export class ReflectionProbe {
  61921. /** defines the name of the probe */
  61922. name: string;
  61923. private _scene;
  61924. private _renderTargetTexture;
  61925. private _projectionMatrix;
  61926. private _viewMatrix;
  61927. private _target;
  61928. private _add;
  61929. private _attachedMesh;
  61930. private _invertYAxis;
  61931. /** Gets or sets probe position (center of the cube map) */
  61932. position: Vector3;
  61933. /**
  61934. * Creates a new reflection probe
  61935. * @param name defines the name of the probe
  61936. * @param size defines the texture resolution (for each face)
  61937. * @param scene defines the hosting scene
  61938. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61939. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61940. */
  61941. constructor(
  61942. /** defines the name of the probe */
  61943. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61944. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61945. get samples(): number;
  61946. set samples(value: number);
  61947. /** Gets or sets the refresh rate to use (on every frame by default) */
  61948. get refreshRate(): number;
  61949. set refreshRate(value: number);
  61950. /**
  61951. * Gets the hosting scene
  61952. * @returns a Scene
  61953. */
  61954. getScene(): Scene;
  61955. /** Gets the internal CubeTexture used to render to */
  61956. get cubeTexture(): RenderTargetTexture;
  61957. /** Gets the list of meshes to render */
  61958. get renderList(): Nullable<AbstractMesh[]>;
  61959. /**
  61960. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61961. * @param mesh defines the mesh to attach to
  61962. */
  61963. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61964. /**
  61965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61966. * @param renderingGroupId The rendering group id corresponding to its index
  61967. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61968. */
  61969. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61970. /**
  61971. * Clean all associated resources
  61972. */
  61973. dispose(): void;
  61974. /**
  61975. * Converts the reflection probe information to a readable string for debug purpose.
  61976. * @param fullDetails Supports for multiple levels of logging within scene loading
  61977. * @returns the human readable reflection probe info
  61978. */
  61979. toString(fullDetails?: boolean): string;
  61980. /**
  61981. * Get the class name of the relfection probe.
  61982. * @returns "ReflectionProbe"
  61983. */
  61984. getClassName(): string;
  61985. /**
  61986. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61987. * @returns The JSON representation of the texture
  61988. */
  61989. serialize(): any;
  61990. /**
  61991. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61992. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61993. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61994. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61995. * @returns The parsed reflection probe if successful
  61996. */
  61997. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61998. }
  61999. }
  62000. declare module BABYLON {
  62001. /** @hidden */
  62002. export var _BabylonLoaderRegistered: boolean;
  62003. /**
  62004. * Helps setting up some configuration for the babylon file loader.
  62005. */
  62006. export class BabylonFileLoaderConfiguration {
  62007. /**
  62008. * The loader does not allow injecting custom physix engine into the plugins.
  62009. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62010. * So you could set this variable to your engine import to make it work.
  62011. */
  62012. static LoaderInjectedPhysicsEngine: any;
  62013. }
  62014. }
  62015. declare module BABYLON {
  62016. /**
  62017. * The Physically based simple base material of BJS.
  62018. *
  62019. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62020. * It is used as the base class for both the specGloss and metalRough conventions.
  62021. */
  62022. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62023. /**
  62024. * Number of Simultaneous lights allowed on the material.
  62025. */
  62026. maxSimultaneousLights: number;
  62027. /**
  62028. * If sets to true, disables all the lights affecting the material.
  62029. */
  62030. disableLighting: boolean;
  62031. /**
  62032. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62033. */
  62034. environmentTexture: BaseTexture;
  62035. /**
  62036. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62037. */
  62038. invertNormalMapX: boolean;
  62039. /**
  62040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62041. */
  62042. invertNormalMapY: boolean;
  62043. /**
  62044. * Normal map used in the model.
  62045. */
  62046. normalTexture: BaseTexture;
  62047. /**
  62048. * Emissivie color used to self-illuminate the model.
  62049. */
  62050. emissiveColor: Color3;
  62051. /**
  62052. * Emissivie texture used to self-illuminate the model.
  62053. */
  62054. emissiveTexture: BaseTexture;
  62055. /**
  62056. * Occlusion Channel Strenght.
  62057. */
  62058. occlusionStrength: number;
  62059. /**
  62060. * Occlusion Texture of the material (adding extra occlusion effects).
  62061. */
  62062. occlusionTexture: BaseTexture;
  62063. /**
  62064. * Defines the alpha limits in alpha test mode.
  62065. */
  62066. alphaCutOff: number;
  62067. /**
  62068. * Gets the current double sided mode.
  62069. */
  62070. get doubleSided(): boolean;
  62071. /**
  62072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62073. */
  62074. set doubleSided(value: boolean);
  62075. /**
  62076. * Stores the pre-calculated light information of a mesh in a texture.
  62077. */
  62078. lightmapTexture: BaseTexture;
  62079. /**
  62080. * If true, the light map contains occlusion information instead of lighting info.
  62081. */
  62082. useLightmapAsShadowmap: boolean;
  62083. /**
  62084. * Instantiates a new PBRMaterial instance.
  62085. *
  62086. * @param name The material name
  62087. * @param scene The scene the material will be use in.
  62088. */
  62089. constructor(name: string, scene: Scene);
  62090. getClassName(): string;
  62091. }
  62092. }
  62093. declare module BABYLON {
  62094. /**
  62095. * The PBR material of BJS following the metal roughness convention.
  62096. *
  62097. * This fits to the PBR convention in the GLTF definition:
  62098. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62099. */
  62100. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62101. /**
  62102. * The base color has two different interpretations depending on the value of metalness.
  62103. * When the material is a metal, the base color is the specific measured reflectance value
  62104. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62105. * of the material.
  62106. */
  62107. baseColor: Color3;
  62108. /**
  62109. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62110. * well as opacity information in the alpha channel.
  62111. */
  62112. baseTexture: BaseTexture;
  62113. /**
  62114. * Specifies the metallic scalar value of the material.
  62115. * Can also be used to scale the metalness values of the metallic texture.
  62116. */
  62117. metallic: number;
  62118. /**
  62119. * Specifies the roughness scalar value of the material.
  62120. * Can also be used to scale the roughness values of the metallic texture.
  62121. */
  62122. roughness: number;
  62123. /**
  62124. * Texture containing both the metallic value in the B channel and the
  62125. * roughness value in the G channel to keep better precision.
  62126. */
  62127. metallicRoughnessTexture: BaseTexture;
  62128. /**
  62129. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62130. *
  62131. * @param name The material name
  62132. * @param scene The scene the material will be use in.
  62133. */
  62134. constructor(name: string, scene: Scene);
  62135. /**
  62136. * Return the currrent class name of the material.
  62137. */
  62138. getClassName(): string;
  62139. /**
  62140. * Makes a duplicate of the current material.
  62141. * @param name - name to use for the new material.
  62142. */
  62143. clone(name: string): PBRMetallicRoughnessMaterial;
  62144. /**
  62145. * Serialize the material to a parsable JSON object.
  62146. */
  62147. serialize(): any;
  62148. /**
  62149. * Parses a JSON object correponding to the serialize function.
  62150. */
  62151. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62152. }
  62153. }
  62154. declare module BABYLON {
  62155. /**
  62156. * The PBR material of BJS following the specular glossiness convention.
  62157. *
  62158. * This fits to the PBR convention in the GLTF definition:
  62159. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62160. */
  62161. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62162. /**
  62163. * Specifies the diffuse color of the material.
  62164. */
  62165. diffuseColor: Color3;
  62166. /**
  62167. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62168. * channel.
  62169. */
  62170. diffuseTexture: BaseTexture;
  62171. /**
  62172. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62173. */
  62174. specularColor: Color3;
  62175. /**
  62176. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62177. */
  62178. glossiness: number;
  62179. /**
  62180. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62181. */
  62182. specularGlossinessTexture: BaseTexture;
  62183. /**
  62184. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62185. *
  62186. * @param name The material name
  62187. * @param scene The scene the material will be use in.
  62188. */
  62189. constructor(name: string, scene: Scene);
  62190. /**
  62191. * Return the currrent class name of the material.
  62192. */
  62193. getClassName(): string;
  62194. /**
  62195. * Makes a duplicate of the current material.
  62196. * @param name - name to use for the new material.
  62197. */
  62198. clone(name: string): PBRSpecularGlossinessMaterial;
  62199. /**
  62200. * Serialize the material to a parsable JSON object.
  62201. */
  62202. serialize(): any;
  62203. /**
  62204. * Parses a JSON object correponding to the serialize function.
  62205. */
  62206. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62207. }
  62208. }
  62209. declare module BABYLON {
  62210. /**
  62211. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62212. * It can help converting any input color in a desired output one. This can then be used to create effects
  62213. * from sepia, black and white to sixties or futuristic rendering...
  62214. *
  62215. * The only supported format is currently 3dl.
  62216. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62217. */
  62218. export class ColorGradingTexture extends BaseTexture {
  62219. /**
  62220. * The texture URL.
  62221. */
  62222. url: string;
  62223. /**
  62224. * Empty line regex stored for GC.
  62225. */
  62226. private static _noneEmptyLineRegex;
  62227. private _textureMatrix;
  62228. private _onLoad;
  62229. /**
  62230. * Instantiates a ColorGradingTexture from the following parameters.
  62231. *
  62232. * @param url The location of the color gradind data (currently only supporting 3dl)
  62233. * @param sceneOrEngine The scene or engine the texture will be used in
  62234. * @param onLoad defines a callback triggered when the texture has been loaded
  62235. */
  62236. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62237. /**
  62238. * Fires the onload event from the constructor if requested.
  62239. */
  62240. private _triggerOnLoad;
  62241. /**
  62242. * Returns the texture matrix used in most of the material.
  62243. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62244. */
  62245. getTextureMatrix(): Matrix;
  62246. /**
  62247. * Occurs when the file being loaded is a .3dl LUT file.
  62248. */
  62249. private load3dlTexture;
  62250. /**
  62251. * Starts the loading process of the texture.
  62252. */
  62253. private loadTexture;
  62254. /**
  62255. * Clones the color gradind texture.
  62256. */
  62257. clone(): ColorGradingTexture;
  62258. /**
  62259. * Called during delayed load for textures.
  62260. */
  62261. delayLoad(): void;
  62262. /**
  62263. * Parses a color grading texture serialized by Babylon.
  62264. * @param parsedTexture The texture information being parsedTexture
  62265. * @param scene The scene to load the texture in
  62266. * @param rootUrl The root url of the data assets to load
  62267. * @return A color gradind texture
  62268. */
  62269. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62270. /**
  62271. * Serializes the LUT texture to json format.
  62272. */
  62273. serialize(): any;
  62274. }
  62275. }
  62276. declare module BABYLON {
  62277. /**
  62278. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62279. */
  62280. export class EquiRectangularCubeTexture extends BaseTexture {
  62281. /** The six faces of the cube. */
  62282. private static _FacesMapping;
  62283. private _noMipmap;
  62284. private _onLoad;
  62285. private _onError;
  62286. /** The size of the cubemap. */
  62287. private _size;
  62288. /** The buffer of the image. */
  62289. private _buffer;
  62290. /** The width of the input image. */
  62291. private _width;
  62292. /** The height of the input image. */
  62293. private _height;
  62294. /** The URL to the image. */
  62295. url: string;
  62296. /**
  62297. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62298. * @param url The location of the image
  62299. * @param scene The scene the texture will be used in
  62300. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62301. * @param noMipmap Forces to not generate the mipmap if true
  62302. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62303. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62304. * @param onLoad — defines a callback called when texture is loaded
  62305. * @param onError — defines a callback called if there is an error
  62306. */
  62307. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62308. /**
  62309. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62310. */
  62311. private loadImage;
  62312. /**
  62313. * Convert the image buffer into a cubemap and create a CubeTexture.
  62314. */
  62315. private loadTexture;
  62316. /**
  62317. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62318. * @param buffer The ArrayBuffer that should be converted.
  62319. * @returns The buffer as Float32Array.
  62320. */
  62321. private getFloat32ArrayFromArrayBuffer;
  62322. /**
  62323. * Get the current class name of the texture useful for serialization or dynamic coding.
  62324. * @returns "EquiRectangularCubeTexture"
  62325. */
  62326. getClassName(): string;
  62327. /**
  62328. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62329. * @returns A clone of the current EquiRectangularCubeTexture.
  62330. */
  62331. clone(): EquiRectangularCubeTexture;
  62332. }
  62333. }
  62334. declare module BABYLON {
  62335. /**
  62336. * Defines the options related to the creation of an HtmlElementTexture
  62337. */
  62338. export interface IHtmlElementTextureOptions {
  62339. /**
  62340. * Defines wether mip maps should be created or not.
  62341. */
  62342. generateMipMaps?: boolean;
  62343. /**
  62344. * Defines the sampling mode of the texture.
  62345. */
  62346. samplingMode?: number;
  62347. /**
  62348. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62349. */
  62350. engine: Nullable<ThinEngine>;
  62351. /**
  62352. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62353. */
  62354. scene: Nullable<Scene>;
  62355. }
  62356. /**
  62357. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62358. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62359. * is automatically managed.
  62360. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62361. * in your application.
  62362. *
  62363. * As the update is not automatic, you need to call them manually.
  62364. */
  62365. export class HtmlElementTexture extends BaseTexture {
  62366. /**
  62367. * The texture URL.
  62368. */
  62369. element: HTMLVideoElement | HTMLCanvasElement;
  62370. private static readonly DefaultOptions;
  62371. private _textureMatrix;
  62372. private _isVideo;
  62373. private _generateMipMaps;
  62374. private _samplingMode;
  62375. /**
  62376. * Instantiates a HtmlElementTexture from the following parameters.
  62377. *
  62378. * @param name Defines the name of the texture
  62379. * @param element Defines the video or canvas the texture is filled with
  62380. * @param options Defines the other none mandatory texture creation options
  62381. */
  62382. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62383. private _createInternalTexture;
  62384. /**
  62385. * Returns the texture matrix used in most of the material.
  62386. */
  62387. getTextureMatrix(): Matrix;
  62388. /**
  62389. * Updates the content of the texture.
  62390. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62391. */
  62392. update(invertY?: Nullable<boolean>): void;
  62393. }
  62394. }
  62395. declare module BABYLON {
  62396. /**
  62397. * Based on jsTGALoader - Javascript loader for TGA file
  62398. * By Vincent Thibault
  62399. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62400. */
  62401. export class TGATools {
  62402. private static _TYPE_INDEXED;
  62403. private static _TYPE_RGB;
  62404. private static _TYPE_GREY;
  62405. private static _TYPE_RLE_INDEXED;
  62406. private static _TYPE_RLE_RGB;
  62407. private static _TYPE_RLE_GREY;
  62408. private static _ORIGIN_MASK;
  62409. private static _ORIGIN_SHIFT;
  62410. private static _ORIGIN_BL;
  62411. private static _ORIGIN_BR;
  62412. private static _ORIGIN_UL;
  62413. private static _ORIGIN_UR;
  62414. /**
  62415. * Gets the header of a TGA file
  62416. * @param data defines the TGA data
  62417. * @returns the header
  62418. */
  62419. static GetTGAHeader(data: Uint8Array): any;
  62420. /**
  62421. * Uploads TGA content to a Babylon Texture
  62422. * @hidden
  62423. */
  62424. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62425. /** @hidden */
  62426. 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;
  62427. /** @hidden */
  62428. 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;
  62429. /** @hidden */
  62430. 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;
  62431. /** @hidden */
  62432. 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;
  62433. /** @hidden */
  62434. 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;
  62435. /** @hidden */
  62436. 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;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Implementation of the TGA Texture Loader.
  62442. * @hidden
  62443. */
  62444. export class _TGATextureLoader implements IInternalTextureLoader {
  62445. /**
  62446. * Defines wether the loader supports cascade loading the different faces.
  62447. */
  62448. readonly supportCascades: boolean;
  62449. /**
  62450. * This returns if the loader support the current file information.
  62451. * @param extension defines the file extension of the file being loaded
  62452. * @returns true if the loader can load the specified file
  62453. */
  62454. canLoad(extension: string): boolean;
  62455. /**
  62456. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62457. * @param data contains the texture data
  62458. * @param texture defines the BabylonJS internal texture
  62459. * @param createPolynomials will be true if polynomials have been requested
  62460. * @param onLoad defines the callback to trigger once the texture is ready
  62461. * @param onError defines the callback to trigger in case of error
  62462. */
  62463. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62464. /**
  62465. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62466. * @param data contains the texture data
  62467. * @param texture defines the BabylonJS internal texture
  62468. * @param callback defines the method to call once ready to upload
  62469. */
  62470. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62471. }
  62472. }
  62473. declare module BABYLON {
  62474. /**
  62475. * Info about the .basis files
  62476. */
  62477. class BasisFileInfo {
  62478. /**
  62479. * If the file has alpha
  62480. */
  62481. hasAlpha: boolean;
  62482. /**
  62483. * Info about each image of the basis file
  62484. */
  62485. images: Array<{
  62486. levels: Array<{
  62487. width: number;
  62488. height: number;
  62489. transcodedPixels: ArrayBufferView;
  62490. }>;
  62491. }>;
  62492. }
  62493. /**
  62494. * Result of transcoding a basis file
  62495. */
  62496. class TranscodeResult {
  62497. /**
  62498. * Info about the .basis file
  62499. */
  62500. fileInfo: BasisFileInfo;
  62501. /**
  62502. * Format to use when loading the file
  62503. */
  62504. format: number;
  62505. }
  62506. /**
  62507. * Configuration options for the Basis transcoder
  62508. */
  62509. export class BasisTranscodeConfiguration {
  62510. /**
  62511. * Supported compression formats used to determine the supported output format of the transcoder
  62512. */
  62513. supportedCompressionFormats?: {
  62514. /**
  62515. * etc1 compression format
  62516. */
  62517. etc1?: boolean;
  62518. /**
  62519. * s3tc compression format
  62520. */
  62521. s3tc?: boolean;
  62522. /**
  62523. * pvrtc compression format
  62524. */
  62525. pvrtc?: boolean;
  62526. /**
  62527. * etc2 compression format
  62528. */
  62529. etc2?: boolean;
  62530. };
  62531. /**
  62532. * If mipmap levels should be loaded for transcoded images (Default: true)
  62533. */
  62534. loadMipmapLevels?: boolean;
  62535. /**
  62536. * Index of a single image to load (Default: all images)
  62537. */
  62538. loadSingleImage?: number;
  62539. }
  62540. /**
  62541. * Used to load .Basis files
  62542. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62543. */
  62544. export class BasisTools {
  62545. private static _IgnoreSupportedFormats;
  62546. /**
  62547. * URL to use when loading the basis transcoder
  62548. */
  62549. static JSModuleURL: string;
  62550. /**
  62551. * URL to use when loading the wasm module for the transcoder
  62552. */
  62553. static WasmModuleURL: string;
  62554. /**
  62555. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62556. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62557. * @returns internal format corresponding to the Basis format
  62558. */
  62559. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62560. private static _WorkerPromise;
  62561. private static _Worker;
  62562. private static _actionId;
  62563. private static _CreateWorkerAsync;
  62564. /**
  62565. * Transcodes a loaded image file to compressed pixel data
  62566. * @param data image data to transcode
  62567. * @param config configuration options for the transcoding
  62568. * @returns a promise resulting in the transcoded image
  62569. */
  62570. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62571. /**
  62572. * Loads a texture from the transcode result
  62573. * @param texture texture load to
  62574. * @param transcodeResult the result of transcoding the basis file to load from
  62575. */
  62576. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62577. }
  62578. }
  62579. declare module BABYLON {
  62580. /**
  62581. * Loader for .basis file format
  62582. */
  62583. export class _BasisTextureLoader implements IInternalTextureLoader {
  62584. /**
  62585. * Defines whether the loader supports cascade loading the different faces.
  62586. */
  62587. readonly supportCascades: boolean;
  62588. /**
  62589. * This returns if the loader support the current file information.
  62590. * @param extension defines the file extension of the file being loaded
  62591. * @returns true if the loader can load the specified file
  62592. */
  62593. canLoad(extension: string): boolean;
  62594. /**
  62595. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62596. * @param data contains the texture data
  62597. * @param texture defines the BabylonJS internal texture
  62598. * @param createPolynomials will be true if polynomials have been requested
  62599. * @param onLoad defines the callback to trigger once the texture is ready
  62600. * @param onError defines the callback to trigger in case of error
  62601. */
  62602. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62603. /**
  62604. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62605. * @param data contains the texture data
  62606. * @param texture defines the BabylonJS internal texture
  62607. * @param callback defines the method to call once ready to upload
  62608. */
  62609. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62610. }
  62611. }
  62612. declare module BABYLON {
  62613. /**
  62614. * Defines the basic options interface of a TexturePacker Frame
  62615. */
  62616. export interface ITexturePackerFrame {
  62617. /**
  62618. * The frame ID
  62619. */
  62620. id: number;
  62621. /**
  62622. * The frames Scale
  62623. */
  62624. scale: Vector2;
  62625. /**
  62626. * The Frames offset
  62627. */
  62628. offset: Vector2;
  62629. }
  62630. /**
  62631. * This is a support class for frame Data on texture packer sets.
  62632. */
  62633. export class TexturePackerFrame implements ITexturePackerFrame {
  62634. /**
  62635. * The frame ID
  62636. */
  62637. id: number;
  62638. /**
  62639. * The frames Scale
  62640. */
  62641. scale: Vector2;
  62642. /**
  62643. * The Frames offset
  62644. */
  62645. offset: Vector2;
  62646. /**
  62647. * Initializes a texture package frame.
  62648. * @param id The numerical frame identifier
  62649. * @param scale Scalar Vector2 for UV frame
  62650. * @param offset Vector2 for the frame position in UV units.
  62651. * @returns TexturePackerFrame
  62652. */
  62653. constructor(id: number, scale: Vector2, offset: Vector2);
  62654. }
  62655. }
  62656. declare module BABYLON {
  62657. /**
  62658. * Defines the basic options interface of a TexturePacker
  62659. */
  62660. export interface ITexturePackerOptions {
  62661. /**
  62662. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62663. */
  62664. map?: string[];
  62665. /**
  62666. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62667. */
  62668. uvsIn?: string;
  62669. /**
  62670. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62671. */
  62672. uvsOut?: string;
  62673. /**
  62674. * number representing the layout style. Defaults to LAYOUT_STRIP
  62675. */
  62676. layout?: number;
  62677. /**
  62678. * number of columns if using custom column count layout(2). This defaults to 4.
  62679. */
  62680. colnum?: number;
  62681. /**
  62682. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62683. */
  62684. updateInputMeshes?: boolean;
  62685. /**
  62686. * boolean flag to dispose all the source textures. Defaults to true.
  62687. */
  62688. disposeSources?: boolean;
  62689. /**
  62690. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62691. */
  62692. fillBlanks?: boolean;
  62693. /**
  62694. * string value representing the context fill style color. Defaults to 'black'.
  62695. */
  62696. customFillColor?: string;
  62697. /**
  62698. * Width and Height Value of each Frame in the TexturePacker Sets
  62699. */
  62700. frameSize?: number;
  62701. /**
  62702. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62703. */
  62704. paddingRatio?: number;
  62705. /**
  62706. * Number that declares the fill method for the padding gutter.
  62707. */
  62708. paddingMode?: number;
  62709. /**
  62710. * If in SUBUV_COLOR padding mode what color to use.
  62711. */
  62712. paddingColor?: Color3 | Color4;
  62713. }
  62714. /**
  62715. * Defines the basic interface of a TexturePacker JSON File
  62716. */
  62717. export interface ITexturePackerJSON {
  62718. /**
  62719. * The frame ID
  62720. */
  62721. name: string;
  62722. /**
  62723. * The base64 channel data
  62724. */
  62725. sets: any;
  62726. /**
  62727. * The options of the Packer
  62728. */
  62729. options: ITexturePackerOptions;
  62730. /**
  62731. * The frame data of the Packer
  62732. */
  62733. frames: Array<number>;
  62734. }
  62735. /**
  62736. * This is a support class that generates a series of packed texture sets.
  62737. * @see https://doc.babylonjs.com/babylon101/materials
  62738. */
  62739. export class TexturePacker {
  62740. /** Packer Layout Constant 0 */
  62741. static readonly LAYOUT_STRIP: number;
  62742. /** Packer Layout Constant 1 */
  62743. static readonly LAYOUT_POWER2: number;
  62744. /** Packer Layout Constant 2 */
  62745. static readonly LAYOUT_COLNUM: number;
  62746. /** Packer Layout Constant 0 */
  62747. static readonly SUBUV_WRAP: number;
  62748. /** Packer Layout Constant 1 */
  62749. static readonly SUBUV_EXTEND: number;
  62750. /** Packer Layout Constant 2 */
  62751. static readonly SUBUV_COLOR: number;
  62752. /** The Name of the Texture Package */
  62753. name: string;
  62754. /** The scene scope of the TexturePacker */
  62755. scene: Scene;
  62756. /** The Meshes to target */
  62757. meshes: AbstractMesh[];
  62758. /** Arguments passed with the Constructor */
  62759. options: ITexturePackerOptions;
  62760. /** The promise that is started upon initialization */
  62761. promise: Nullable<Promise<TexturePacker | string>>;
  62762. /** The Container object for the channel sets that are generated */
  62763. sets: object;
  62764. /** The Container array for the frames that are generated */
  62765. frames: TexturePackerFrame[];
  62766. /** The expected number of textures the system is parsing. */
  62767. private _expecting;
  62768. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62769. private _paddingValue;
  62770. /**
  62771. * Initializes a texture package series from an array of meshes or a single mesh.
  62772. * @param name The name of the package
  62773. * @param meshes The target meshes to compose the package from
  62774. * @param options The arguments that texture packer should follow while building.
  62775. * @param scene The scene which the textures are scoped to.
  62776. * @returns TexturePacker
  62777. */
  62778. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62779. /**
  62780. * Starts the package process
  62781. * @param resolve The promises resolution function
  62782. * @returns TexturePacker
  62783. */
  62784. private _createFrames;
  62785. /**
  62786. * Calculates the Size of the Channel Sets
  62787. * @returns Vector2
  62788. */
  62789. private _calculateSize;
  62790. /**
  62791. * Calculates the UV data for the frames.
  62792. * @param baseSize the base frameSize
  62793. * @param padding the base frame padding
  62794. * @param dtSize size of the Dynamic Texture for that channel
  62795. * @param dtUnits is 1/dtSize
  62796. * @param update flag to update the input meshes
  62797. */
  62798. private _calculateMeshUVFrames;
  62799. /**
  62800. * Calculates the frames Offset.
  62801. * @param index of the frame
  62802. * @returns Vector2
  62803. */
  62804. private _getFrameOffset;
  62805. /**
  62806. * Updates a Mesh to the frame data
  62807. * @param mesh that is the target
  62808. * @param frameID or the frame index
  62809. */
  62810. private _updateMeshUV;
  62811. /**
  62812. * Updates a Meshes materials to use the texture packer channels
  62813. * @param m is the mesh to target
  62814. * @param force all channels on the packer to be set.
  62815. */
  62816. private _updateTextureReferences;
  62817. /**
  62818. * Public method to set a Mesh to a frame
  62819. * @param m that is the target
  62820. * @param frameID or the frame index
  62821. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62822. */
  62823. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62824. /**
  62825. * Starts the async promise to compile the texture packer.
  62826. * @returns Promise<void>
  62827. */
  62828. processAsync(): Promise<void>;
  62829. /**
  62830. * Disposes all textures associated with this packer
  62831. */
  62832. dispose(): void;
  62833. /**
  62834. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62835. * @param imageType is the image type to use.
  62836. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62837. */
  62838. download(imageType?: string, quality?: number): void;
  62839. /**
  62840. * Public method to load a texturePacker JSON file.
  62841. * @param data of the JSON file in string format.
  62842. */
  62843. updateFromJSON(data: string): void;
  62844. }
  62845. }
  62846. declare module BABYLON {
  62847. /**
  62848. * 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.
  62849. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62850. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62851. */
  62852. export class CustomProceduralTexture extends ProceduralTexture {
  62853. private _animate;
  62854. private _time;
  62855. private _config;
  62856. private _texturePath;
  62857. /**
  62858. * Instantiates a new Custom Procedural Texture.
  62859. * 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.
  62860. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62861. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62862. * @param name Define the name of the texture
  62863. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62864. * @param size Define the size of the texture to create
  62865. * @param scene Define the scene the texture belongs to
  62866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62867. * @param generateMipMaps Define if the texture should creates mip maps or not
  62868. */
  62869. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62870. private _loadJson;
  62871. /**
  62872. * Is the texture ready to be used ? (rendered at least once)
  62873. * @returns true if ready, otherwise, false.
  62874. */
  62875. isReady(): boolean;
  62876. /**
  62877. * Render the texture to its associated render target.
  62878. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62879. */
  62880. render(useCameraPostProcess?: boolean): void;
  62881. /**
  62882. * Update the list of dependant textures samplers in the shader.
  62883. */
  62884. updateTextures(): void;
  62885. /**
  62886. * Update the uniform values of the procedural texture in the shader.
  62887. */
  62888. updateShaderUniforms(): void;
  62889. /**
  62890. * Define if the texture animates or not.
  62891. */
  62892. get animate(): boolean;
  62893. set animate(value: boolean);
  62894. }
  62895. }
  62896. declare module BABYLON {
  62897. /** @hidden */
  62898. export var noisePixelShader: {
  62899. name: string;
  62900. shader: string;
  62901. };
  62902. }
  62903. declare module BABYLON {
  62904. /**
  62905. * Class used to generate noise procedural textures
  62906. */
  62907. export class NoiseProceduralTexture extends ProceduralTexture {
  62908. /** Gets or sets the start time (default is 0) */
  62909. time: number;
  62910. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62911. brightness: number;
  62912. /** Defines the number of octaves to process */
  62913. octaves: number;
  62914. /** Defines the level of persistence (0.8 by default) */
  62915. persistence: number;
  62916. /** Gets or sets animation speed factor (default is 1) */
  62917. animationSpeedFactor: number;
  62918. /**
  62919. * Creates a new NoiseProceduralTexture
  62920. * @param name defines the name fo the texture
  62921. * @param size defines the size of the texture (default is 256)
  62922. * @param scene defines the hosting scene
  62923. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62924. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62925. */
  62926. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62927. private _updateShaderUniforms;
  62928. protected _getDefines(): string;
  62929. /** Generate the current state of the procedural texture */
  62930. render(useCameraPostProcess?: boolean): void;
  62931. /**
  62932. * Serializes this noise procedural texture
  62933. * @returns a serialized noise procedural texture object
  62934. */
  62935. serialize(): any;
  62936. /**
  62937. * Clone the texture.
  62938. * @returns the cloned texture
  62939. */
  62940. clone(): NoiseProceduralTexture;
  62941. /**
  62942. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62943. * @param parsedTexture defines parsed texture data
  62944. * @param scene defines the current scene
  62945. * @param rootUrl defines the root URL containing noise procedural texture information
  62946. * @returns a parsed NoiseProceduralTexture
  62947. */
  62948. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * Raw cube texture where the raw buffers are passed in
  62954. */
  62955. export class RawCubeTexture extends CubeTexture {
  62956. /**
  62957. * Creates a cube texture where the raw buffers are passed in.
  62958. * @param scene defines the scene the texture is attached to
  62959. * @param data defines the array of data to use to create each face
  62960. * @param size defines the size of the textures
  62961. * @param format defines the format of the data
  62962. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62963. * @param generateMipMaps defines if the engine should generate the mip levels
  62964. * @param invertY defines if data must be stored with Y axis inverted
  62965. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62966. * @param compression defines the compression used (null by default)
  62967. */
  62968. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62969. /**
  62970. * Updates the raw cube texture.
  62971. * @param data defines the data to store
  62972. * @param format defines the data format
  62973. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62974. * @param invertY defines if data must be stored with Y axis inverted
  62975. * @param compression defines the compression used (null by default)
  62976. * @param level defines which level of the texture to update
  62977. */
  62978. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62979. /**
  62980. * Updates a raw cube texture with RGBD encoded data.
  62981. * @param data defines the array of data [mipmap][face] to use to create each face
  62982. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62983. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62984. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62985. * @returns a promsie that resolves when the operation is complete
  62986. */
  62987. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62988. /**
  62989. * Clones the raw cube texture.
  62990. * @return a new cube texture
  62991. */
  62992. clone(): CubeTexture;
  62993. /** @hidden */
  62994. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62995. }
  62996. }
  62997. declare module BABYLON {
  62998. /**
  62999. * Class used to store 2D array textures containing user data
  63000. */
  63001. export class RawTexture2DArray extends Texture {
  63002. /** Gets or sets the texture format to use */
  63003. format: number;
  63004. /**
  63005. * Create a new RawTexture2DArray
  63006. * @param data defines the data of the texture
  63007. * @param width defines the width of the texture
  63008. * @param height defines the height of the texture
  63009. * @param depth defines the number of layers of the texture
  63010. * @param format defines the texture format to use
  63011. * @param scene defines the hosting scene
  63012. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63013. * @param invertY defines if texture must be stored with Y axis inverted
  63014. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63015. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63016. */
  63017. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63018. /** Gets or sets the texture format to use */
  63019. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63020. /**
  63021. * Update the texture with new data
  63022. * @param data defines the data to store in the texture
  63023. */
  63024. update(data: ArrayBufferView): void;
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Class used to store 3D textures containing user data
  63030. */
  63031. export class RawTexture3D extends Texture {
  63032. /** Gets or sets the texture format to use */
  63033. format: number;
  63034. /**
  63035. * Create a new RawTexture3D
  63036. * @param data defines the data of the texture
  63037. * @param width defines the width of the texture
  63038. * @param height defines the height of the texture
  63039. * @param depth defines the depth of the texture
  63040. * @param format defines the texture format to use
  63041. * @param scene defines the hosting scene
  63042. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63043. * @param invertY defines if texture must be stored with Y axis inverted
  63044. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63045. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63046. */
  63047. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63048. /** Gets or sets the texture format to use */
  63049. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63050. /**
  63051. * Update the texture with new data
  63052. * @param data defines the data to store in the texture
  63053. */
  63054. update(data: ArrayBufferView): void;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * Creates a refraction texture used by refraction channel of the standard material.
  63060. * It is like a mirror but to see through a material.
  63061. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63062. */
  63063. export class RefractionTexture extends RenderTargetTexture {
  63064. /**
  63065. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63066. * 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.
  63067. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63068. */
  63069. refractionPlane: Plane;
  63070. /**
  63071. * Define how deep under the surface we should see.
  63072. */
  63073. depth: number;
  63074. /**
  63075. * Creates a refraction texture used by refraction channel of the standard material.
  63076. * It is like a mirror but to see through a material.
  63077. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63078. * @param name Define the texture name
  63079. * @param size Define the size of the underlying texture
  63080. * @param scene Define the scene the refraction belongs to
  63081. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63082. */
  63083. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63084. /**
  63085. * Clone the refraction texture.
  63086. * @returns the cloned texture
  63087. */
  63088. clone(): RefractionTexture;
  63089. /**
  63090. * Serialize the texture to a JSON representation you could use in Parse later on
  63091. * @returns the serialized JSON representation
  63092. */
  63093. serialize(): any;
  63094. }
  63095. }
  63096. declare module BABYLON {
  63097. /**
  63098. * Block used to add support for vertex skinning (bones)
  63099. */
  63100. export class BonesBlock extends NodeMaterialBlock {
  63101. /**
  63102. * Creates a new BonesBlock
  63103. * @param name defines the block name
  63104. */
  63105. constructor(name: string);
  63106. /**
  63107. * Initialize the block and prepare the context for build
  63108. * @param state defines the state that will be used for the build
  63109. */
  63110. initialize(state: NodeMaterialBuildState): void;
  63111. /**
  63112. * Gets the current class name
  63113. * @returns the class name
  63114. */
  63115. getClassName(): string;
  63116. /**
  63117. * Gets the matrix indices input component
  63118. */
  63119. get matricesIndices(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the matrix weights input component
  63122. */
  63123. get matricesWeights(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the extra matrix indices input component
  63126. */
  63127. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the extra matrix weights input component
  63130. */
  63131. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the world input component
  63134. */
  63135. get world(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the output component
  63138. */
  63139. get output(): NodeMaterialConnectionPoint;
  63140. autoConfigure(material: NodeMaterial): void;
  63141. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63144. protected _buildBlock(state: NodeMaterialBuildState): this;
  63145. }
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * Block used to add support for instances
  63150. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63151. */
  63152. export class InstancesBlock extends NodeMaterialBlock {
  63153. /**
  63154. * Creates a new InstancesBlock
  63155. * @param name defines the block name
  63156. */
  63157. constructor(name: string);
  63158. /**
  63159. * Gets the current class name
  63160. * @returns the class name
  63161. */
  63162. getClassName(): string;
  63163. /**
  63164. * Gets the first world row input component
  63165. */
  63166. get world0(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the second world row input component
  63169. */
  63170. get world1(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the third world row input component
  63173. */
  63174. get world2(): NodeMaterialConnectionPoint;
  63175. /**
  63176. * Gets the forth world row input component
  63177. */
  63178. get world3(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the world input component
  63181. */
  63182. get world(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the output component
  63185. */
  63186. get output(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the isntanceID component
  63189. */
  63190. get instanceID(): NodeMaterialConnectionPoint;
  63191. autoConfigure(material: NodeMaterial): void;
  63192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63193. protected _buildBlock(state: NodeMaterialBuildState): this;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Block used to add morph targets support to vertex shader
  63199. */
  63200. export class MorphTargetsBlock extends NodeMaterialBlock {
  63201. private _repeatableContentAnchor;
  63202. /**
  63203. * Create a new MorphTargetsBlock
  63204. * @param name defines the block name
  63205. */
  63206. constructor(name: string);
  63207. /**
  63208. * Gets the current class name
  63209. * @returns the class name
  63210. */
  63211. getClassName(): string;
  63212. /**
  63213. * Gets the position input component
  63214. */
  63215. get position(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the normal input component
  63218. */
  63219. get normal(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the tangent input component
  63222. */
  63223. get tangent(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the tangent input component
  63226. */
  63227. get uv(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the position output component
  63230. */
  63231. get positionOutput(): NodeMaterialConnectionPoint;
  63232. /**
  63233. * Gets the normal output component
  63234. */
  63235. get normalOutput(): NodeMaterialConnectionPoint;
  63236. /**
  63237. * Gets the tangent output component
  63238. */
  63239. get tangentOutput(): NodeMaterialConnectionPoint;
  63240. /**
  63241. * Gets the tangent output component
  63242. */
  63243. get uvOutput(): NodeMaterialConnectionPoint;
  63244. initialize(state: NodeMaterialBuildState): void;
  63245. autoConfigure(material: NodeMaterial): void;
  63246. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63247. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63248. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63249. protected _buildBlock(state: NodeMaterialBuildState): this;
  63250. }
  63251. }
  63252. declare module BABYLON {
  63253. /**
  63254. * Block used to get data information from a light
  63255. */
  63256. export class LightInformationBlock extends NodeMaterialBlock {
  63257. private _lightDataUniformName;
  63258. private _lightColorUniformName;
  63259. private _lightTypeDefineName;
  63260. /**
  63261. * Gets or sets the light associated with this block
  63262. */
  63263. light: Nullable<Light>;
  63264. /**
  63265. * Creates a new LightInformationBlock
  63266. * @param name defines the block name
  63267. */
  63268. constructor(name: string);
  63269. /**
  63270. * Gets the current class name
  63271. * @returns the class name
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Gets the world position input component
  63276. */
  63277. get worldPosition(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the direction output component
  63280. */
  63281. get direction(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the direction output component
  63284. */
  63285. get color(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the direction output component
  63288. */
  63289. get intensity(): NodeMaterialConnectionPoint;
  63290. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63292. protected _buildBlock(state: NodeMaterialBuildState): this;
  63293. serialize(): any;
  63294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63295. }
  63296. }
  63297. declare module BABYLON {
  63298. /**
  63299. * Block used to add image processing support to fragment shader
  63300. */
  63301. export class ImageProcessingBlock extends NodeMaterialBlock {
  63302. /**
  63303. * Create a new ImageProcessingBlock
  63304. * @param name defines the block name
  63305. */
  63306. constructor(name: string);
  63307. /**
  63308. * Gets the current class name
  63309. * @returns the class name
  63310. */
  63311. getClassName(): string;
  63312. /**
  63313. * Gets the color input component
  63314. */
  63315. get color(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the output component
  63318. */
  63319. get output(): NodeMaterialConnectionPoint;
  63320. /**
  63321. * Initialize the block and prepare the context for build
  63322. * @param state defines the state that will be used for the build
  63323. */
  63324. initialize(state: NodeMaterialBuildState): void;
  63325. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63327. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63328. protected _buildBlock(state: NodeMaterialBuildState): this;
  63329. }
  63330. }
  63331. declare module BABYLON {
  63332. /**
  63333. * Block used to pertub normals based on a normal map
  63334. */
  63335. export class PerturbNormalBlock extends NodeMaterialBlock {
  63336. private _tangentSpaceParameterName;
  63337. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63338. invertX: boolean;
  63339. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63340. invertY: boolean;
  63341. /**
  63342. * Create a new PerturbNormalBlock
  63343. * @param name defines the block name
  63344. */
  63345. constructor(name: string);
  63346. /**
  63347. * Gets the current class name
  63348. * @returns the class name
  63349. */
  63350. getClassName(): string;
  63351. /**
  63352. * Gets the world position input component
  63353. */
  63354. get worldPosition(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the world normal input component
  63357. */
  63358. get worldNormal(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the world tangent input component
  63361. */
  63362. get worldTangent(): NodeMaterialConnectionPoint;
  63363. /**
  63364. * Gets the uv input component
  63365. */
  63366. get uv(): NodeMaterialConnectionPoint;
  63367. /**
  63368. * Gets the normal map color input component
  63369. */
  63370. get normalMapColor(): NodeMaterialConnectionPoint;
  63371. /**
  63372. * Gets the strength input component
  63373. */
  63374. get strength(): NodeMaterialConnectionPoint;
  63375. /**
  63376. * Gets the output component
  63377. */
  63378. get output(): NodeMaterialConnectionPoint;
  63379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63380. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63381. autoConfigure(material: NodeMaterial): void;
  63382. protected _buildBlock(state: NodeMaterialBuildState): this;
  63383. protected _dumpPropertiesCode(): string;
  63384. serialize(): any;
  63385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63386. }
  63387. }
  63388. declare module BABYLON {
  63389. /**
  63390. * Block used to discard a pixel if a value is smaller than a cutoff
  63391. */
  63392. export class DiscardBlock extends NodeMaterialBlock {
  63393. /**
  63394. * Create a new DiscardBlock
  63395. * @param name defines the block name
  63396. */
  63397. constructor(name: string);
  63398. /**
  63399. * Gets the current class name
  63400. * @returns the class name
  63401. */
  63402. getClassName(): string;
  63403. /**
  63404. * Gets the color input component
  63405. */
  63406. get value(): NodeMaterialConnectionPoint;
  63407. /**
  63408. * Gets the cutoff input component
  63409. */
  63410. get cutoff(): NodeMaterialConnectionPoint;
  63411. protected _buildBlock(state: NodeMaterialBuildState): this;
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /**
  63416. * Block used to test if the fragment shader is front facing
  63417. */
  63418. export class FrontFacingBlock extends NodeMaterialBlock {
  63419. /**
  63420. * Creates a new FrontFacingBlock
  63421. * @param name defines the block name
  63422. */
  63423. constructor(name: string);
  63424. /**
  63425. * Gets the current class name
  63426. * @returns the class name
  63427. */
  63428. getClassName(): string;
  63429. /**
  63430. * Gets the output component
  63431. */
  63432. get output(): NodeMaterialConnectionPoint;
  63433. protected _buildBlock(state: NodeMaterialBuildState): this;
  63434. }
  63435. }
  63436. declare module BABYLON {
  63437. /**
  63438. * Block used to get the derivative value on x and y of a given input
  63439. */
  63440. export class DerivativeBlock extends NodeMaterialBlock {
  63441. /**
  63442. * Create a new DerivativeBlock
  63443. * @param name defines the block name
  63444. */
  63445. constructor(name: string);
  63446. /**
  63447. * Gets the current class name
  63448. * @returns the class name
  63449. */
  63450. getClassName(): string;
  63451. /**
  63452. * Gets the input component
  63453. */
  63454. get input(): NodeMaterialConnectionPoint;
  63455. /**
  63456. * Gets the derivative output on x
  63457. */
  63458. get dx(): NodeMaterialConnectionPoint;
  63459. /**
  63460. * Gets the derivative output on y
  63461. */
  63462. get dy(): NodeMaterialConnectionPoint;
  63463. protected _buildBlock(state: NodeMaterialBuildState): this;
  63464. }
  63465. }
  63466. declare module BABYLON {
  63467. /**
  63468. * Block used to make gl_FragCoord available
  63469. */
  63470. export class FragCoordBlock extends NodeMaterialBlock {
  63471. /**
  63472. * Creates a new FragCoordBlock
  63473. * @param name defines the block name
  63474. */
  63475. constructor(name: string);
  63476. /**
  63477. * Gets the current class name
  63478. * @returns the class name
  63479. */
  63480. getClassName(): string;
  63481. /**
  63482. * Gets the xy component
  63483. */
  63484. get xy(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the xyz component
  63487. */
  63488. get xyz(): NodeMaterialConnectionPoint;
  63489. /**
  63490. * Gets the xyzw component
  63491. */
  63492. get xyzw(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the x component
  63495. */
  63496. get x(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the y component
  63499. */
  63500. get y(): NodeMaterialConnectionPoint;
  63501. /**
  63502. * Gets the z component
  63503. */
  63504. get z(): NodeMaterialConnectionPoint;
  63505. /**
  63506. * Gets the w component
  63507. */
  63508. get output(): NodeMaterialConnectionPoint;
  63509. protected writeOutputs(state: NodeMaterialBuildState): string;
  63510. protected _buildBlock(state: NodeMaterialBuildState): this;
  63511. }
  63512. }
  63513. declare module BABYLON {
  63514. /**
  63515. * Block used to get the screen sizes
  63516. */
  63517. export class ScreenSizeBlock extends NodeMaterialBlock {
  63518. private _varName;
  63519. private _scene;
  63520. /**
  63521. * Creates a new ScreenSizeBlock
  63522. * @param name defines the block name
  63523. */
  63524. constructor(name: string);
  63525. /**
  63526. * Gets the current class name
  63527. * @returns the class name
  63528. */
  63529. getClassName(): string;
  63530. /**
  63531. * Gets the xy component
  63532. */
  63533. get xy(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the x component
  63536. */
  63537. get x(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the y component
  63540. */
  63541. get y(): NodeMaterialConnectionPoint;
  63542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63543. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this;
  63545. }
  63546. }
  63547. declare module BABYLON {
  63548. /**
  63549. * Block used to add support for scene fog
  63550. */
  63551. export class FogBlock extends NodeMaterialBlock {
  63552. private _fogDistanceName;
  63553. private _fogParameters;
  63554. /**
  63555. * Create a new FogBlock
  63556. * @param name defines the block name
  63557. */
  63558. constructor(name: string);
  63559. /**
  63560. * Gets the current class name
  63561. * @returns the class name
  63562. */
  63563. getClassName(): string;
  63564. /**
  63565. * Gets the world position input component
  63566. */
  63567. get worldPosition(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the view input component
  63570. */
  63571. get view(): NodeMaterialConnectionPoint;
  63572. /**
  63573. * Gets the color input component
  63574. */
  63575. get input(): NodeMaterialConnectionPoint;
  63576. /**
  63577. * Gets the fog color input component
  63578. */
  63579. get fogColor(): NodeMaterialConnectionPoint;
  63580. /**
  63581. * Gets the output component
  63582. */
  63583. get output(): NodeMaterialConnectionPoint;
  63584. autoConfigure(material: NodeMaterial): void;
  63585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63587. protected _buildBlock(state: NodeMaterialBuildState): this;
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * Block used to add light in the fragment shader
  63593. */
  63594. export class LightBlock extends NodeMaterialBlock {
  63595. private _lightId;
  63596. /**
  63597. * Gets or sets the light associated with this block
  63598. */
  63599. light: Nullable<Light>;
  63600. /**
  63601. * Create a new LightBlock
  63602. * @param name defines the block name
  63603. */
  63604. constructor(name: string);
  63605. /**
  63606. * Gets the current class name
  63607. * @returns the class name
  63608. */
  63609. getClassName(): string;
  63610. /**
  63611. * Gets the world position input component
  63612. */
  63613. get worldPosition(): NodeMaterialConnectionPoint;
  63614. /**
  63615. * Gets the world normal input component
  63616. */
  63617. get worldNormal(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the camera (or eye) position component
  63620. */
  63621. get cameraPosition(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the glossiness component
  63624. */
  63625. get glossiness(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the glossinness power component
  63628. */
  63629. get glossPower(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the diffuse color component
  63632. */
  63633. get diffuseColor(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the specular color component
  63636. */
  63637. get specularColor(): NodeMaterialConnectionPoint;
  63638. /**
  63639. * Gets the diffuse output component
  63640. */
  63641. get diffuseOutput(): NodeMaterialConnectionPoint;
  63642. /**
  63643. * Gets the specular output component
  63644. */
  63645. get specularOutput(): NodeMaterialConnectionPoint;
  63646. /**
  63647. * Gets the shadow output component
  63648. */
  63649. get shadow(): NodeMaterialConnectionPoint;
  63650. autoConfigure(material: NodeMaterial): void;
  63651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63652. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63654. private _injectVertexCode;
  63655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63656. serialize(): any;
  63657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63658. }
  63659. }
  63660. declare module BABYLON {
  63661. /**
  63662. * Block used to read a reflection texture from a sampler
  63663. */
  63664. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63665. /**
  63666. * Create a new ReflectionTextureBlock
  63667. * @param name defines the block name
  63668. */
  63669. constructor(name: string);
  63670. /**
  63671. * Gets the current class name
  63672. * @returns the class name
  63673. */
  63674. getClassName(): string;
  63675. /**
  63676. * Gets the world position input component
  63677. */
  63678. get position(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the world position input component
  63681. */
  63682. get worldPosition(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the world normal input component
  63685. */
  63686. get worldNormal(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the world input component
  63689. */
  63690. get world(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the camera (or eye) position component
  63693. */
  63694. get cameraPosition(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the view input component
  63697. */
  63698. get view(): NodeMaterialConnectionPoint;
  63699. /**
  63700. * Gets the rgb output component
  63701. */
  63702. get rgb(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the rgba output component
  63705. */
  63706. get rgba(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the r output component
  63709. */
  63710. get r(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the g output component
  63713. */
  63714. get g(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the b output component
  63717. */
  63718. get b(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the a output component
  63721. */
  63722. get a(): NodeMaterialConnectionPoint;
  63723. autoConfigure(material: NodeMaterial): void;
  63724. protected _buildBlock(state: NodeMaterialBuildState): this;
  63725. }
  63726. }
  63727. declare module BABYLON {
  63728. /**
  63729. * Block used to add 2 vectors
  63730. */
  63731. export class AddBlock extends NodeMaterialBlock {
  63732. /**
  63733. * Creates a new AddBlock
  63734. * @param name defines the block name
  63735. */
  63736. constructor(name: string);
  63737. /**
  63738. * Gets the current class name
  63739. * @returns the class name
  63740. */
  63741. getClassName(): string;
  63742. /**
  63743. * Gets the left operand input component
  63744. */
  63745. get left(): NodeMaterialConnectionPoint;
  63746. /**
  63747. * Gets the right operand input component
  63748. */
  63749. get right(): NodeMaterialConnectionPoint;
  63750. /**
  63751. * Gets the output component
  63752. */
  63753. get output(): NodeMaterialConnectionPoint;
  63754. protected _buildBlock(state: NodeMaterialBuildState): this;
  63755. }
  63756. }
  63757. declare module BABYLON {
  63758. /**
  63759. * Block used to scale a vector by a float
  63760. */
  63761. export class ScaleBlock extends NodeMaterialBlock {
  63762. /**
  63763. * Creates a new ScaleBlock
  63764. * @param name defines the block name
  63765. */
  63766. constructor(name: string);
  63767. /**
  63768. * Gets the current class name
  63769. * @returns the class name
  63770. */
  63771. getClassName(): string;
  63772. /**
  63773. * Gets the input component
  63774. */
  63775. get input(): NodeMaterialConnectionPoint;
  63776. /**
  63777. * Gets the factor input component
  63778. */
  63779. get factor(): NodeMaterialConnectionPoint;
  63780. /**
  63781. * Gets the output component
  63782. */
  63783. get output(): NodeMaterialConnectionPoint;
  63784. protected _buildBlock(state: NodeMaterialBuildState): this;
  63785. }
  63786. }
  63787. declare module BABYLON {
  63788. /**
  63789. * Block used to clamp a float
  63790. */
  63791. export class ClampBlock extends NodeMaterialBlock {
  63792. /** Gets or sets the minimum range */
  63793. minimum: number;
  63794. /** Gets or sets the maximum range */
  63795. maximum: number;
  63796. /**
  63797. * Creates a new ClampBlock
  63798. * @param name defines the block name
  63799. */
  63800. constructor(name: string);
  63801. /**
  63802. * Gets the current class name
  63803. * @returns the class name
  63804. */
  63805. getClassName(): string;
  63806. /**
  63807. * Gets the value input component
  63808. */
  63809. get value(): NodeMaterialConnectionPoint;
  63810. /**
  63811. * Gets the output component
  63812. */
  63813. get output(): NodeMaterialConnectionPoint;
  63814. protected _buildBlock(state: NodeMaterialBuildState): this;
  63815. protected _dumpPropertiesCode(): string;
  63816. serialize(): any;
  63817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63818. }
  63819. }
  63820. declare module BABYLON {
  63821. /**
  63822. * Block used to apply a cross product between 2 vectors
  63823. */
  63824. export class CrossBlock extends NodeMaterialBlock {
  63825. /**
  63826. * Creates a new CrossBlock
  63827. * @param name defines the block name
  63828. */
  63829. constructor(name: string);
  63830. /**
  63831. * Gets the current class name
  63832. * @returns the class name
  63833. */
  63834. getClassName(): string;
  63835. /**
  63836. * Gets the left operand input component
  63837. */
  63838. get left(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the right operand input component
  63841. */
  63842. get right(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the output component
  63845. */
  63846. get output(): NodeMaterialConnectionPoint;
  63847. protected _buildBlock(state: NodeMaterialBuildState): this;
  63848. }
  63849. }
  63850. declare module BABYLON {
  63851. /**
  63852. * Block used to apply a dot product between 2 vectors
  63853. */
  63854. export class DotBlock extends NodeMaterialBlock {
  63855. /**
  63856. * Creates a new DotBlock
  63857. * @param name defines the block name
  63858. */
  63859. constructor(name: string);
  63860. /**
  63861. * Gets the current class name
  63862. * @returns the class name
  63863. */
  63864. getClassName(): string;
  63865. /**
  63866. * Gets the left operand input component
  63867. */
  63868. get left(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the right operand input component
  63871. */
  63872. get right(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the output component
  63875. */
  63876. get output(): NodeMaterialConnectionPoint;
  63877. protected _buildBlock(state: NodeMaterialBuildState): this;
  63878. }
  63879. }
  63880. declare module BABYLON {
  63881. /**
  63882. * Block used to normalize a vector
  63883. */
  63884. export class NormalizeBlock extends NodeMaterialBlock {
  63885. /**
  63886. * Creates a new NormalizeBlock
  63887. * @param name defines the block name
  63888. */
  63889. constructor(name: string);
  63890. /**
  63891. * Gets the current class name
  63892. * @returns the class name
  63893. */
  63894. getClassName(): string;
  63895. /**
  63896. * Gets the input component
  63897. */
  63898. get input(): NodeMaterialConnectionPoint;
  63899. /**
  63900. * Gets the output component
  63901. */
  63902. get output(): NodeMaterialConnectionPoint;
  63903. protected _buildBlock(state: NodeMaterialBuildState): this;
  63904. }
  63905. }
  63906. declare module BABYLON {
  63907. /**
  63908. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63909. */
  63910. export class ColorMergerBlock extends NodeMaterialBlock {
  63911. /**
  63912. * Create a new ColorMergerBlock
  63913. * @param name defines the block name
  63914. */
  63915. constructor(name: string);
  63916. /**
  63917. * Gets the current class name
  63918. * @returns the class name
  63919. */
  63920. getClassName(): string;
  63921. /**
  63922. * Gets the rgb component (input)
  63923. */
  63924. get rgbIn(): NodeMaterialConnectionPoint;
  63925. /**
  63926. * Gets the r component (input)
  63927. */
  63928. get r(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the g component (input)
  63931. */
  63932. get g(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the b component (input)
  63935. */
  63936. get b(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the a component (input)
  63939. */
  63940. get a(): NodeMaterialConnectionPoint;
  63941. /**
  63942. * Gets the rgba component (output)
  63943. */
  63944. get rgba(): NodeMaterialConnectionPoint;
  63945. /**
  63946. * Gets the rgb component (output)
  63947. */
  63948. get rgbOut(): NodeMaterialConnectionPoint;
  63949. /**
  63950. * Gets the rgb component (output)
  63951. * @deprecated Please use rgbOut instead.
  63952. */
  63953. get rgb(): NodeMaterialConnectionPoint;
  63954. protected _buildBlock(state: NodeMaterialBuildState): this;
  63955. }
  63956. }
  63957. declare module BABYLON {
  63958. /**
  63959. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63960. */
  63961. export class VectorSplitterBlock extends NodeMaterialBlock {
  63962. /**
  63963. * Create a new VectorSplitterBlock
  63964. * @param name defines the block name
  63965. */
  63966. constructor(name: string);
  63967. /**
  63968. * Gets the current class name
  63969. * @returns the class name
  63970. */
  63971. getClassName(): string;
  63972. /**
  63973. * Gets the xyzw component (input)
  63974. */
  63975. get xyzw(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the xyz component (input)
  63978. */
  63979. get xyzIn(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the xy component (input)
  63982. */
  63983. get xyIn(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the xyz component (output)
  63986. */
  63987. get xyzOut(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the xy component (output)
  63990. */
  63991. get xyOut(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the x component (output)
  63994. */
  63995. get x(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the y component (output)
  63998. */
  63999. get y(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the z component (output)
  64002. */
  64003. get z(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the w component (output)
  64006. */
  64007. get w(): NodeMaterialConnectionPoint;
  64008. protected _inputRename(name: string): string;
  64009. protected _outputRename(name: string): string;
  64010. protected _buildBlock(state: NodeMaterialBuildState): this;
  64011. }
  64012. }
  64013. declare module BABYLON {
  64014. /**
  64015. * Block used to lerp between 2 values
  64016. */
  64017. export class LerpBlock extends NodeMaterialBlock {
  64018. /**
  64019. * Creates a new LerpBlock
  64020. * @param name defines the block name
  64021. */
  64022. constructor(name: string);
  64023. /**
  64024. * Gets the current class name
  64025. * @returns the class name
  64026. */
  64027. getClassName(): string;
  64028. /**
  64029. * Gets the left operand input component
  64030. */
  64031. get left(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the right operand input component
  64034. */
  64035. get right(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the gradient operand input component
  64038. */
  64039. get gradient(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the output component
  64042. */
  64043. get output(): NodeMaterialConnectionPoint;
  64044. protected _buildBlock(state: NodeMaterialBuildState): this;
  64045. }
  64046. }
  64047. declare module BABYLON {
  64048. /**
  64049. * Block used to divide 2 vectors
  64050. */
  64051. export class DivideBlock extends NodeMaterialBlock {
  64052. /**
  64053. * Creates a new DivideBlock
  64054. * @param name defines the block name
  64055. */
  64056. constructor(name: string);
  64057. /**
  64058. * Gets the current class name
  64059. * @returns the class name
  64060. */
  64061. getClassName(): string;
  64062. /**
  64063. * Gets the left operand input component
  64064. */
  64065. get left(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the right operand input component
  64068. */
  64069. get right(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the output component
  64072. */
  64073. get output(): NodeMaterialConnectionPoint;
  64074. protected _buildBlock(state: NodeMaterialBuildState): this;
  64075. }
  64076. }
  64077. declare module BABYLON {
  64078. /**
  64079. * Block used to subtract 2 vectors
  64080. */
  64081. export class SubtractBlock extends NodeMaterialBlock {
  64082. /**
  64083. * Creates a new SubtractBlock
  64084. * @param name defines the block name
  64085. */
  64086. constructor(name: string);
  64087. /**
  64088. * Gets the current class name
  64089. * @returns the class name
  64090. */
  64091. getClassName(): string;
  64092. /**
  64093. * Gets the left operand input component
  64094. */
  64095. get left(): NodeMaterialConnectionPoint;
  64096. /**
  64097. * Gets the right operand input component
  64098. */
  64099. get right(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the output component
  64102. */
  64103. get output(): NodeMaterialConnectionPoint;
  64104. protected _buildBlock(state: NodeMaterialBuildState): this;
  64105. }
  64106. }
  64107. declare module BABYLON {
  64108. /**
  64109. * Block used to step a value
  64110. */
  64111. export class StepBlock extends NodeMaterialBlock {
  64112. /**
  64113. * Creates a new StepBlock
  64114. * @param name defines the block name
  64115. */
  64116. constructor(name: string);
  64117. /**
  64118. * Gets the current class name
  64119. * @returns the class name
  64120. */
  64121. getClassName(): string;
  64122. /**
  64123. * Gets the value operand input component
  64124. */
  64125. get value(): NodeMaterialConnectionPoint;
  64126. /**
  64127. * Gets the edge operand input component
  64128. */
  64129. get edge(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the output component
  64132. */
  64133. get output(): NodeMaterialConnectionPoint;
  64134. protected _buildBlock(state: NodeMaterialBuildState): this;
  64135. }
  64136. }
  64137. declare module BABYLON {
  64138. /**
  64139. * Block used to get the opposite (1 - x) of a value
  64140. */
  64141. export class OneMinusBlock extends NodeMaterialBlock {
  64142. /**
  64143. * Creates a new OneMinusBlock
  64144. * @param name defines the block name
  64145. */
  64146. constructor(name: string);
  64147. /**
  64148. * Gets the current class name
  64149. * @returns the class name
  64150. */
  64151. getClassName(): string;
  64152. /**
  64153. * Gets the input component
  64154. */
  64155. get input(): NodeMaterialConnectionPoint;
  64156. /**
  64157. * Gets the output component
  64158. */
  64159. get output(): NodeMaterialConnectionPoint;
  64160. protected _buildBlock(state: NodeMaterialBuildState): this;
  64161. }
  64162. }
  64163. declare module BABYLON {
  64164. /**
  64165. * Block used to get the view direction
  64166. */
  64167. export class ViewDirectionBlock extends NodeMaterialBlock {
  64168. /**
  64169. * Creates a new ViewDirectionBlock
  64170. * @param name defines the block name
  64171. */
  64172. constructor(name: string);
  64173. /**
  64174. * Gets the current class name
  64175. * @returns the class name
  64176. */
  64177. getClassName(): string;
  64178. /**
  64179. * Gets the world position component
  64180. */
  64181. get worldPosition(): NodeMaterialConnectionPoint;
  64182. /**
  64183. * Gets the camera position component
  64184. */
  64185. get cameraPosition(): NodeMaterialConnectionPoint;
  64186. /**
  64187. * Gets the output component
  64188. */
  64189. get output(): NodeMaterialConnectionPoint;
  64190. autoConfigure(material: NodeMaterial): void;
  64191. protected _buildBlock(state: NodeMaterialBuildState): this;
  64192. }
  64193. }
  64194. declare module BABYLON {
  64195. /**
  64196. * Block used to compute fresnel value
  64197. */
  64198. export class FresnelBlock extends NodeMaterialBlock {
  64199. /**
  64200. * Create a new FresnelBlock
  64201. * @param name defines the block name
  64202. */
  64203. constructor(name: string);
  64204. /**
  64205. * Gets the current class name
  64206. * @returns the class name
  64207. */
  64208. getClassName(): string;
  64209. /**
  64210. * Gets the world normal input component
  64211. */
  64212. get worldNormal(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the view direction input component
  64215. */
  64216. get viewDirection(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Gets the bias input component
  64219. */
  64220. get bias(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Gets the camera (or eye) position component
  64223. */
  64224. get power(): NodeMaterialConnectionPoint;
  64225. /**
  64226. * Gets the fresnel output component
  64227. */
  64228. get fresnel(): NodeMaterialConnectionPoint;
  64229. autoConfigure(material: NodeMaterial): void;
  64230. protected _buildBlock(state: NodeMaterialBuildState): this;
  64231. }
  64232. }
  64233. declare module BABYLON {
  64234. /**
  64235. * Block used to get the max of 2 values
  64236. */
  64237. export class MaxBlock extends NodeMaterialBlock {
  64238. /**
  64239. * Creates a new MaxBlock
  64240. * @param name defines the block name
  64241. */
  64242. constructor(name: string);
  64243. /**
  64244. * Gets the current class name
  64245. * @returns the class name
  64246. */
  64247. getClassName(): string;
  64248. /**
  64249. * Gets the left operand input component
  64250. */
  64251. get left(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the right operand input component
  64254. */
  64255. get right(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the output component
  64258. */
  64259. get output(): NodeMaterialConnectionPoint;
  64260. protected _buildBlock(state: NodeMaterialBuildState): this;
  64261. }
  64262. }
  64263. declare module BABYLON {
  64264. /**
  64265. * Block used to get the min of 2 values
  64266. */
  64267. export class MinBlock extends NodeMaterialBlock {
  64268. /**
  64269. * Creates a new MinBlock
  64270. * @param name defines the block name
  64271. */
  64272. constructor(name: string);
  64273. /**
  64274. * Gets the current class name
  64275. * @returns the class name
  64276. */
  64277. getClassName(): string;
  64278. /**
  64279. * Gets the left operand input component
  64280. */
  64281. get left(): NodeMaterialConnectionPoint;
  64282. /**
  64283. * Gets the right operand input component
  64284. */
  64285. get right(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the output component
  64288. */
  64289. get output(): NodeMaterialConnectionPoint;
  64290. protected _buildBlock(state: NodeMaterialBuildState): this;
  64291. }
  64292. }
  64293. declare module BABYLON {
  64294. /**
  64295. * Block used to get the distance between 2 values
  64296. */
  64297. export class DistanceBlock extends NodeMaterialBlock {
  64298. /**
  64299. * Creates a new DistanceBlock
  64300. * @param name defines the block name
  64301. */
  64302. constructor(name: string);
  64303. /**
  64304. * Gets the current class name
  64305. * @returns the class name
  64306. */
  64307. getClassName(): string;
  64308. /**
  64309. * Gets the left operand input component
  64310. */
  64311. get left(): NodeMaterialConnectionPoint;
  64312. /**
  64313. * Gets the right operand input component
  64314. */
  64315. get right(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the output component
  64318. */
  64319. get output(): NodeMaterialConnectionPoint;
  64320. protected _buildBlock(state: NodeMaterialBuildState): this;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Block used to get the length of a vector
  64326. */
  64327. export class LengthBlock extends NodeMaterialBlock {
  64328. /**
  64329. * Creates a new LengthBlock
  64330. * @param name defines the block name
  64331. */
  64332. constructor(name: string);
  64333. /**
  64334. * Gets the current class name
  64335. * @returns the class name
  64336. */
  64337. getClassName(): string;
  64338. /**
  64339. * Gets the value input component
  64340. */
  64341. get value(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the output component
  64344. */
  64345. get output(): NodeMaterialConnectionPoint;
  64346. protected _buildBlock(state: NodeMaterialBuildState): this;
  64347. }
  64348. }
  64349. declare module BABYLON {
  64350. /**
  64351. * Block used to get negative version of a value (i.e. x * -1)
  64352. */
  64353. export class NegateBlock extends NodeMaterialBlock {
  64354. /**
  64355. * Creates a new NegateBlock
  64356. * @param name defines the block name
  64357. */
  64358. constructor(name: string);
  64359. /**
  64360. * Gets the current class name
  64361. * @returns the class name
  64362. */
  64363. getClassName(): string;
  64364. /**
  64365. * Gets the value input component
  64366. */
  64367. get value(): NodeMaterialConnectionPoint;
  64368. /**
  64369. * Gets the output component
  64370. */
  64371. get output(): NodeMaterialConnectionPoint;
  64372. protected _buildBlock(state: NodeMaterialBuildState): this;
  64373. }
  64374. }
  64375. declare module BABYLON {
  64376. /**
  64377. * Block used to get the value of the first parameter raised to the power of the second
  64378. */
  64379. export class PowBlock extends NodeMaterialBlock {
  64380. /**
  64381. * Creates a new PowBlock
  64382. * @param name defines the block name
  64383. */
  64384. constructor(name: string);
  64385. /**
  64386. * Gets the current class name
  64387. * @returns the class name
  64388. */
  64389. getClassName(): string;
  64390. /**
  64391. * Gets the value operand input component
  64392. */
  64393. get value(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the power operand input component
  64396. */
  64397. get power(): NodeMaterialConnectionPoint;
  64398. /**
  64399. * Gets the output component
  64400. */
  64401. get output(): NodeMaterialConnectionPoint;
  64402. protected _buildBlock(state: NodeMaterialBuildState): this;
  64403. }
  64404. }
  64405. declare module BABYLON {
  64406. /**
  64407. * Block used to get a random number
  64408. */
  64409. export class RandomNumberBlock extends NodeMaterialBlock {
  64410. /**
  64411. * Creates a new RandomNumberBlock
  64412. * @param name defines the block name
  64413. */
  64414. constructor(name: string);
  64415. /**
  64416. * Gets the current class name
  64417. * @returns the class name
  64418. */
  64419. getClassName(): string;
  64420. /**
  64421. * Gets the seed input component
  64422. */
  64423. get seed(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the output component
  64426. */
  64427. get output(): NodeMaterialConnectionPoint;
  64428. protected _buildBlock(state: NodeMaterialBuildState): this;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * Block used to compute arc tangent of 2 values
  64434. */
  64435. export class ArcTan2Block extends NodeMaterialBlock {
  64436. /**
  64437. * Creates a new ArcTan2Block
  64438. * @param name defines the block name
  64439. */
  64440. constructor(name: string);
  64441. /**
  64442. * Gets the current class name
  64443. * @returns the class name
  64444. */
  64445. getClassName(): string;
  64446. /**
  64447. * Gets the x operand input component
  64448. */
  64449. get x(): NodeMaterialConnectionPoint;
  64450. /**
  64451. * Gets the y operand input component
  64452. */
  64453. get y(): NodeMaterialConnectionPoint;
  64454. /**
  64455. * Gets the output component
  64456. */
  64457. get output(): NodeMaterialConnectionPoint;
  64458. protected _buildBlock(state: NodeMaterialBuildState): this;
  64459. }
  64460. }
  64461. declare module BABYLON {
  64462. /**
  64463. * Block used to smooth step a value
  64464. */
  64465. export class SmoothStepBlock extends NodeMaterialBlock {
  64466. /**
  64467. * Creates a new SmoothStepBlock
  64468. * @param name defines the block name
  64469. */
  64470. constructor(name: string);
  64471. /**
  64472. * Gets the current class name
  64473. * @returns the class name
  64474. */
  64475. getClassName(): string;
  64476. /**
  64477. * Gets the value operand input component
  64478. */
  64479. get value(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the first edge operand input component
  64482. */
  64483. get edge0(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the second edge operand input component
  64486. */
  64487. get edge1(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the output component
  64490. */
  64491. get output(): NodeMaterialConnectionPoint;
  64492. protected _buildBlock(state: NodeMaterialBuildState): this;
  64493. }
  64494. }
  64495. declare module BABYLON {
  64496. /**
  64497. * Block used to get the reciprocal (1 / x) of a value
  64498. */
  64499. export class ReciprocalBlock extends NodeMaterialBlock {
  64500. /**
  64501. * Creates a new ReciprocalBlock
  64502. * @param name defines the block name
  64503. */
  64504. constructor(name: string);
  64505. /**
  64506. * Gets the current class name
  64507. * @returns the class name
  64508. */
  64509. getClassName(): string;
  64510. /**
  64511. * Gets the input component
  64512. */
  64513. get input(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the output component
  64516. */
  64517. get output(): NodeMaterialConnectionPoint;
  64518. protected _buildBlock(state: NodeMaterialBuildState): this;
  64519. }
  64520. }
  64521. declare module BABYLON {
  64522. /**
  64523. * Block used to replace a color by another one
  64524. */
  64525. export class ReplaceColorBlock extends NodeMaterialBlock {
  64526. /**
  64527. * Creates a new ReplaceColorBlock
  64528. * @param name defines the block name
  64529. */
  64530. constructor(name: string);
  64531. /**
  64532. * Gets the current class name
  64533. * @returns the class name
  64534. */
  64535. getClassName(): string;
  64536. /**
  64537. * Gets the value input component
  64538. */
  64539. get value(): NodeMaterialConnectionPoint;
  64540. /**
  64541. * Gets the reference input component
  64542. */
  64543. get reference(): NodeMaterialConnectionPoint;
  64544. /**
  64545. * Gets the distance input component
  64546. */
  64547. get distance(): NodeMaterialConnectionPoint;
  64548. /**
  64549. * Gets the replacement input component
  64550. */
  64551. get replacement(): NodeMaterialConnectionPoint;
  64552. /**
  64553. * Gets the output component
  64554. */
  64555. get output(): NodeMaterialConnectionPoint;
  64556. protected _buildBlock(state: NodeMaterialBuildState): this;
  64557. }
  64558. }
  64559. declare module BABYLON {
  64560. /**
  64561. * Block used to posterize a value
  64562. * @see https://en.wikipedia.org/wiki/Posterization
  64563. */
  64564. export class PosterizeBlock extends NodeMaterialBlock {
  64565. /**
  64566. * Creates a new PosterizeBlock
  64567. * @param name defines the block name
  64568. */
  64569. constructor(name: string);
  64570. /**
  64571. * Gets the current class name
  64572. * @returns the class name
  64573. */
  64574. getClassName(): string;
  64575. /**
  64576. * Gets the value input component
  64577. */
  64578. get value(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the steps input component
  64581. */
  64582. get steps(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the output component
  64585. */
  64586. get output(): NodeMaterialConnectionPoint;
  64587. protected _buildBlock(state: NodeMaterialBuildState): this;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /**
  64592. * Operations supported by the Wave block
  64593. */
  64594. export enum WaveBlockKind {
  64595. /** SawTooth */
  64596. SawTooth = 0,
  64597. /** Square */
  64598. Square = 1,
  64599. /** Triangle */
  64600. Triangle = 2
  64601. }
  64602. /**
  64603. * Block used to apply wave operation to floats
  64604. */
  64605. export class WaveBlock extends NodeMaterialBlock {
  64606. /**
  64607. * Gets or sets the kibnd of wave to be applied by the block
  64608. */
  64609. kind: WaveBlockKind;
  64610. /**
  64611. * Creates a new WaveBlock
  64612. * @param name defines the block name
  64613. */
  64614. constructor(name: string);
  64615. /**
  64616. * Gets the current class name
  64617. * @returns the class name
  64618. */
  64619. getClassName(): string;
  64620. /**
  64621. * Gets the input component
  64622. */
  64623. get input(): NodeMaterialConnectionPoint;
  64624. /**
  64625. * Gets the output component
  64626. */
  64627. get output(): NodeMaterialConnectionPoint;
  64628. protected _buildBlock(state: NodeMaterialBuildState): this;
  64629. serialize(): any;
  64630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64631. }
  64632. }
  64633. declare module BABYLON {
  64634. /**
  64635. * Class used to store a color step for the GradientBlock
  64636. */
  64637. export class GradientBlockColorStep {
  64638. private _step;
  64639. /**
  64640. * Gets value indicating which step this color is associated with (between 0 and 1)
  64641. */
  64642. get step(): number;
  64643. /**
  64644. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64645. */
  64646. set step(val: number);
  64647. private _color;
  64648. /**
  64649. * Gets the color associated with this step
  64650. */
  64651. get color(): Color3;
  64652. /**
  64653. * Sets the color associated with this step
  64654. */
  64655. set color(val: Color3);
  64656. /**
  64657. * Creates a new GradientBlockColorStep
  64658. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64659. * @param color defines the color associated with this step
  64660. */
  64661. constructor(step: number, color: Color3);
  64662. }
  64663. /**
  64664. * Block used to return a color from a gradient based on an input value between 0 and 1
  64665. */
  64666. export class GradientBlock extends NodeMaterialBlock {
  64667. /**
  64668. * Gets or sets the list of color steps
  64669. */
  64670. colorSteps: GradientBlockColorStep[];
  64671. /** Gets an observable raised when the value is changed */
  64672. onValueChangedObservable: Observable<GradientBlock>;
  64673. /** calls observable when the value is changed*/
  64674. colorStepsUpdated(): void;
  64675. /**
  64676. * Creates a new GradientBlock
  64677. * @param name defines the block name
  64678. */
  64679. constructor(name: string);
  64680. /**
  64681. * Gets the current class name
  64682. * @returns the class name
  64683. */
  64684. getClassName(): string;
  64685. /**
  64686. * Gets the gradient input component
  64687. */
  64688. get gradient(): NodeMaterialConnectionPoint;
  64689. /**
  64690. * Gets the output component
  64691. */
  64692. get output(): NodeMaterialConnectionPoint;
  64693. private _writeColorConstant;
  64694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64695. serialize(): any;
  64696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64697. protected _dumpPropertiesCode(): string;
  64698. }
  64699. }
  64700. declare module BABYLON {
  64701. /**
  64702. * Block used to normalize lerp between 2 values
  64703. */
  64704. export class NLerpBlock extends NodeMaterialBlock {
  64705. /**
  64706. * Creates a new NLerpBlock
  64707. * @param name defines the block name
  64708. */
  64709. constructor(name: string);
  64710. /**
  64711. * Gets the current class name
  64712. * @returns the class name
  64713. */
  64714. getClassName(): string;
  64715. /**
  64716. * Gets the left operand input component
  64717. */
  64718. get left(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the right operand input component
  64721. */
  64722. get right(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the gradient operand input component
  64725. */
  64726. get gradient(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the output component
  64729. */
  64730. get output(): NodeMaterialConnectionPoint;
  64731. protected _buildBlock(state: NodeMaterialBuildState): this;
  64732. }
  64733. }
  64734. declare module BABYLON {
  64735. /**
  64736. * block used to Generate a Worley Noise 3D Noise Pattern
  64737. */
  64738. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64739. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64740. manhattanDistance: boolean;
  64741. /**
  64742. * Creates a new WorleyNoise3DBlock
  64743. * @param name defines the block name
  64744. */
  64745. constructor(name: string);
  64746. /**
  64747. * Gets the current class name
  64748. * @returns the class name
  64749. */
  64750. getClassName(): string;
  64751. /**
  64752. * Gets the seed input component
  64753. */
  64754. get seed(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the jitter input component
  64757. */
  64758. get jitter(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the output component
  64761. */
  64762. get output(): NodeMaterialConnectionPoint;
  64763. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64764. /**
  64765. * Exposes the properties to the UI?
  64766. */
  64767. protected _dumpPropertiesCode(): string;
  64768. /**
  64769. * Exposes the properties to the Seralize?
  64770. */
  64771. serialize(): any;
  64772. /**
  64773. * Exposes the properties to the deseralize?
  64774. */
  64775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64776. }
  64777. }
  64778. declare module BABYLON {
  64779. /**
  64780. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64781. */
  64782. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64783. /**
  64784. * Creates a new SimplexPerlin3DBlock
  64785. * @param name defines the block name
  64786. */
  64787. constructor(name: string);
  64788. /**
  64789. * Gets the current class name
  64790. * @returns the class name
  64791. */
  64792. getClassName(): string;
  64793. /**
  64794. * Gets the seed operand input component
  64795. */
  64796. get seed(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the output component
  64799. */
  64800. get output(): NodeMaterialConnectionPoint;
  64801. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64802. }
  64803. }
  64804. declare module BABYLON {
  64805. /**
  64806. * Block used to blend normals
  64807. */
  64808. export class NormalBlendBlock extends NodeMaterialBlock {
  64809. /**
  64810. * Creates a new NormalBlendBlock
  64811. * @param name defines the block name
  64812. */
  64813. constructor(name: string);
  64814. /**
  64815. * Gets the current class name
  64816. * @returns the class name
  64817. */
  64818. getClassName(): string;
  64819. /**
  64820. * Gets the first input component
  64821. */
  64822. get normalMap0(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the second input component
  64825. */
  64826. get normalMap1(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the output component
  64829. */
  64830. get output(): NodeMaterialConnectionPoint;
  64831. protected _buildBlock(state: NodeMaterialBuildState): this;
  64832. }
  64833. }
  64834. declare module BABYLON {
  64835. /**
  64836. * Block used to rotate a 2d vector by a given angle
  64837. */
  64838. export class Rotate2dBlock extends NodeMaterialBlock {
  64839. /**
  64840. * Creates a new Rotate2dBlock
  64841. * @param name defines the block name
  64842. */
  64843. constructor(name: string);
  64844. /**
  64845. * Gets the current class name
  64846. * @returns the class name
  64847. */
  64848. getClassName(): string;
  64849. /**
  64850. * Gets the input vector
  64851. */
  64852. get input(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the input angle
  64855. */
  64856. get angle(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the output component
  64859. */
  64860. get output(): NodeMaterialConnectionPoint;
  64861. autoConfigure(material: NodeMaterial): void;
  64862. protected _buildBlock(state: NodeMaterialBuildState): this;
  64863. }
  64864. }
  64865. declare module BABYLON {
  64866. /**
  64867. * Block used to get the reflected vector from a direction and a normal
  64868. */
  64869. export class ReflectBlock extends NodeMaterialBlock {
  64870. /**
  64871. * Creates a new ReflectBlock
  64872. * @param name defines the block name
  64873. */
  64874. constructor(name: string);
  64875. /**
  64876. * Gets the current class name
  64877. * @returns the class name
  64878. */
  64879. getClassName(): string;
  64880. /**
  64881. * Gets the incident component
  64882. */
  64883. get incident(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the normal component
  64886. */
  64887. get normal(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the output component
  64890. */
  64891. get output(): NodeMaterialConnectionPoint;
  64892. protected _buildBlock(state: NodeMaterialBuildState): this;
  64893. }
  64894. }
  64895. declare module BABYLON {
  64896. /**
  64897. * Block used to get the refracted vector from a direction and a normal
  64898. */
  64899. export class RefractBlock extends NodeMaterialBlock {
  64900. /**
  64901. * Creates a new RefractBlock
  64902. * @param name defines the block name
  64903. */
  64904. constructor(name: string);
  64905. /**
  64906. * Gets the current class name
  64907. * @returns the class name
  64908. */
  64909. getClassName(): string;
  64910. /**
  64911. * Gets the incident component
  64912. */
  64913. get incident(): NodeMaterialConnectionPoint;
  64914. /**
  64915. * Gets the normal component
  64916. */
  64917. get normal(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the index of refraction component
  64920. */
  64921. get ior(): NodeMaterialConnectionPoint;
  64922. /**
  64923. * Gets the output component
  64924. */
  64925. get output(): NodeMaterialConnectionPoint;
  64926. protected _buildBlock(state: NodeMaterialBuildState): this;
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * Block used to desaturate a color
  64932. */
  64933. export class DesaturateBlock extends NodeMaterialBlock {
  64934. /**
  64935. * Creates a new DesaturateBlock
  64936. * @param name defines the block name
  64937. */
  64938. constructor(name: string);
  64939. /**
  64940. * Gets the current class name
  64941. * @returns the class name
  64942. */
  64943. getClassName(): string;
  64944. /**
  64945. * Gets the color operand input component
  64946. */
  64947. get color(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the level operand input component
  64950. */
  64951. get level(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the output component
  64954. */
  64955. get output(): NodeMaterialConnectionPoint;
  64956. protected _buildBlock(state: NodeMaterialBuildState): this;
  64957. }
  64958. }
  64959. declare module BABYLON {
  64960. /**
  64961. * Block used to implement the ambient occlusion module of the PBR material
  64962. */
  64963. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64964. /**
  64965. * Create a new AmbientOcclusionBlock
  64966. * @param name defines the block name
  64967. */
  64968. constructor(name: string);
  64969. /**
  64970. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64971. */
  64972. useAmbientInGrayScale: boolean;
  64973. /**
  64974. * Initialize the block and prepare the context for build
  64975. * @param state defines the state that will be used for the build
  64976. */
  64977. initialize(state: NodeMaterialBuildState): void;
  64978. /**
  64979. * Gets the current class name
  64980. * @returns the class name
  64981. */
  64982. getClassName(): string;
  64983. /**
  64984. * Gets the texture input component
  64985. */
  64986. get texture(): NodeMaterialConnectionPoint;
  64987. /**
  64988. * Gets the texture intensity component
  64989. */
  64990. get intensity(): NodeMaterialConnectionPoint;
  64991. /**
  64992. * Gets the direct light intensity input component
  64993. */
  64994. get directLightIntensity(): NodeMaterialConnectionPoint;
  64995. /**
  64996. * Gets the ambient occlusion object output component
  64997. */
  64998. get ambientOcc(): NodeMaterialConnectionPoint;
  64999. /**
  65000. * Gets the main code of the block (fragment side)
  65001. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65002. * @returns the shader code
  65003. */
  65004. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65006. protected _buildBlock(state: NodeMaterialBuildState): this;
  65007. protected _dumpPropertiesCode(): string;
  65008. serialize(): any;
  65009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65010. }
  65011. }
  65012. declare module BABYLON {
  65013. /**
  65014. * Block used to implement the reflection module of the PBR material
  65015. */
  65016. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65017. /** @hidden */
  65018. _defineLODReflectionAlpha: string;
  65019. /** @hidden */
  65020. _defineLinearSpecularReflection: string;
  65021. private _vEnvironmentIrradianceName;
  65022. /** @hidden */
  65023. _vReflectionMicrosurfaceInfosName: string;
  65024. /** @hidden */
  65025. _vReflectionInfosName: string;
  65026. /** @hidden */
  65027. _vReflectionFilteringInfoName: string;
  65028. private _scene;
  65029. /**
  65030. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65031. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65032. * It's less burden on the user side in the editor part.
  65033. */
  65034. /** @hidden */
  65035. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65036. /** @hidden */
  65037. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65038. /** @hidden */
  65039. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65040. /**
  65041. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65042. * diffuse part of the IBL.
  65043. */
  65044. useSphericalHarmonics: boolean;
  65045. /**
  65046. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65047. */
  65048. forceIrradianceInFragment: boolean;
  65049. /**
  65050. * Create a new ReflectionBlock
  65051. * @param name defines the block name
  65052. */
  65053. constructor(name: string);
  65054. /**
  65055. * Gets the current class name
  65056. * @returns the class name
  65057. */
  65058. getClassName(): string;
  65059. /**
  65060. * Gets the position input component
  65061. */
  65062. get position(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the world position input component
  65065. */
  65066. get worldPosition(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the world normal input component
  65069. */
  65070. get worldNormal(): NodeMaterialConnectionPoint;
  65071. /**
  65072. * Gets the world input component
  65073. */
  65074. get world(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the camera (or eye) position component
  65077. */
  65078. get cameraPosition(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the view input component
  65081. */
  65082. get view(): NodeMaterialConnectionPoint;
  65083. /**
  65084. * Gets the color input component
  65085. */
  65086. get color(): NodeMaterialConnectionPoint;
  65087. /**
  65088. * Gets the reflection object output component
  65089. */
  65090. get reflection(): NodeMaterialConnectionPoint;
  65091. /**
  65092. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65093. */
  65094. get hasTexture(): boolean;
  65095. /**
  65096. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65097. */
  65098. get reflectionColor(): string;
  65099. protected _getTexture(): Nullable<BaseTexture>;
  65100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65102. /**
  65103. * Gets the code to inject in the vertex shader
  65104. * @param state current state of the node material building
  65105. * @returns the shader code
  65106. */
  65107. handleVertexSide(state: NodeMaterialBuildState): string;
  65108. /**
  65109. * Gets the main code of the block (fragment side)
  65110. * @param state current state of the node material building
  65111. * @param normalVarName name of the existing variable corresponding to the normal
  65112. * @returns the shader code
  65113. */
  65114. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65115. protected _buildBlock(state: NodeMaterialBuildState): this;
  65116. protected _dumpPropertiesCode(): string;
  65117. serialize(): any;
  65118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65119. }
  65120. }
  65121. declare module BABYLON {
  65122. /**
  65123. * Block used to implement the sheen module of the PBR material
  65124. */
  65125. export class SheenBlock extends NodeMaterialBlock {
  65126. /**
  65127. * Create a new SheenBlock
  65128. * @param name defines the block name
  65129. */
  65130. constructor(name: string);
  65131. /**
  65132. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65133. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65134. * making it easier to setup and tweak the effect
  65135. */
  65136. albedoScaling: boolean;
  65137. /**
  65138. * Defines if the sheen is linked to the sheen color.
  65139. */
  65140. linkSheenWithAlbedo: boolean;
  65141. /**
  65142. * Initialize the block and prepare the context for build
  65143. * @param state defines the state that will be used for the build
  65144. */
  65145. initialize(state: NodeMaterialBuildState): void;
  65146. /**
  65147. * Gets the current class name
  65148. * @returns the class name
  65149. */
  65150. getClassName(): string;
  65151. /**
  65152. * Gets the intensity input component
  65153. */
  65154. get intensity(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the color input component
  65157. */
  65158. get color(): NodeMaterialConnectionPoint;
  65159. /**
  65160. * Gets the roughness input component
  65161. */
  65162. get roughness(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the sheen object output component
  65165. */
  65166. get sheen(): NodeMaterialConnectionPoint;
  65167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65168. /**
  65169. * Gets the main code of the block (fragment side)
  65170. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65171. * @returns the shader code
  65172. */
  65173. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65174. protected _buildBlock(state: NodeMaterialBuildState): this;
  65175. protected _dumpPropertiesCode(): string;
  65176. serialize(): any;
  65177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. /**
  65182. * Block used to implement the reflectivity module of the PBR material
  65183. */
  65184. export class ReflectivityBlock extends NodeMaterialBlock {
  65185. private _metallicReflectanceColor;
  65186. private _metallicF0Factor;
  65187. /** @hidden */
  65188. _vMetallicReflectanceFactorsName: string;
  65189. /**
  65190. * The property below is set by the main PBR block prior to calling methods of this class.
  65191. */
  65192. /** @hidden */
  65193. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65194. /**
  65195. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65196. */
  65197. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65198. /**
  65199. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65200. */
  65201. useMetallnessFromMetallicTextureBlue: boolean;
  65202. /**
  65203. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65204. */
  65205. useRoughnessFromMetallicTextureAlpha: boolean;
  65206. /**
  65207. * Specifies if the metallic texture contains the roughness information in its green channel.
  65208. */
  65209. useRoughnessFromMetallicTextureGreen: boolean;
  65210. /**
  65211. * Create a new ReflectivityBlock
  65212. * @param name defines the block name
  65213. */
  65214. constructor(name: string);
  65215. /**
  65216. * Initialize the block and prepare the context for build
  65217. * @param state defines the state that will be used for the build
  65218. */
  65219. initialize(state: NodeMaterialBuildState): void;
  65220. /**
  65221. * Gets the current class name
  65222. * @returns the class name
  65223. */
  65224. getClassName(): string;
  65225. /**
  65226. * Gets the metallic input component
  65227. */
  65228. get metallic(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the roughness input component
  65231. */
  65232. get roughness(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the texture input component
  65235. */
  65236. get texture(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the reflectivity object output component
  65239. */
  65240. get reflectivity(): NodeMaterialConnectionPoint;
  65241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65242. /**
  65243. * Gets the main code of the block (fragment side)
  65244. * @param state current state of the node material building
  65245. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65246. * @returns the shader code
  65247. */
  65248. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65249. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65250. protected _buildBlock(state: NodeMaterialBuildState): this;
  65251. protected _dumpPropertiesCode(): string;
  65252. serialize(): any;
  65253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65254. }
  65255. }
  65256. declare module BABYLON {
  65257. /**
  65258. * Block used to implement the anisotropy module of the PBR material
  65259. */
  65260. export class AnisotropyBlock extends NodeMaterialBlock {
  65261. /**
  65262. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65263. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65264. * It's less burden on the user side in the editor part.
  65265. */
  65266. /** @hidden */
  65267. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65268. /** @hidden */
  65269. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65270. /**
  65271. * Create a new AnisotropyBlock
  65272. * @param name defines the block name
  65273. */
  65274. constructor(name: string);
  65275. /**
  65276. * Initialize the block and prepare the context for build
  65277. * @param state defines the state that will be used for the build
  65278. */
  65279. initialize(state: NodeMaterialBuildState): void;
  65280. /**
  65281. * Gets the current class name
  65282. * @returns the class name
  65283. */
  65284. getClassName(): string;
  65285. /**
  65286. * Gets the intensity input component
  65287. */
  65288. get intensity(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the direction input component
  65291. */
  65292. get direction(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the texture input component
  65295. */
  65296. get texture(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the uv input component
  65299. */
  65300. get uv(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the worldTangent input component
  65303. */
  65304. get worldTangent(): NodeMaterialConnectionPoint;
  65305. /**
  65306. * Gets the anisotropy object output component
  65307. */
  65308. get anisotropy(): NodeMaterialConnectionPoint;
  65309. private _generateTBNSpace;
  65310. /**
  65311. * Gets the main code of the block (fragment side)
  65312. * @param state current state of the node material building
  65313. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65314. * @returns the shader code
  65315. */
  65316. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65318. protected _buildBlock(state: NodeMaterialBuildState): this;
  65319. }
  65320. }
  65321. declare module BABYLON {
  65322. /**
  65323. * Block used to implement the clear coat module of the PBR material
  65324. */
  65325. export class ClearCoatBlock extends NodeMaterialBlock {
  65326. private _scene;
  65327. /**
  65328. * Create a new ClearCoatBlock
  65329. * @param name defines the block name
  65330. */
  65331. constructor(name: string);
  65332. /**
  65333. * Initialize the block and prepare the context for build
  65334. * @param state defines the state that will be used for the build
  65335. */
  65336. initialize(state: NodeMaterialBuildState): void;
  65337. /**
  65338. * Gets the current class name
  65339. * @returns the class name
  65340. */
  65341. getClassName(): string;
  65342. /**
  65343. * Gets the intensity input component
  65344. */
  65345. get intensity(): NodeMaterialConnectionPoint;
  65346. /**
  65347. * Gets the roughness input component
  65348. */
  65349. get roughness(): NodeMaterialConnectionPoint;
  65350. /**
  65351. * Gets the ior input component
  65352. */
  65353. get ior(): NodeMaterialConnectionPoint;
  65354. /**
  65355. * Gets the texture input component
  65356. */
  65357. get texture(): NodeMaterialConnectionPoint;
  65358. /**
  65359. * Gets the bump texture input component
  65360. */
  65361. get bumpTexture(): NodeMaterialConnectionPoint;
  65362. /**
  65363. * Gets the uv input component
  65364. */
  65365. get uv(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the tint color input component
  65368. */
  65369. get tintColor(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the tint "at distance" input component
  65372. */
  65373. get tintAtDistance(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the tint thickness input component
  65376. */
  65377. get tintThickness(): NodeMaterialConnectionPoint;
  65378. /**
  65379. * Gets the world tangent input component
  65380. */
  65381. get worldTangent(): NodeMaterialConnectionPoint;
  65382. /**
  65383. * Gets the clear coat object output component
  65384. */
  65385. get clearcoat(): NodeMaterialConnectionPoint;
  65386. autoConfigure(material: NodeMaterial): void;
  65387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65389. private _generateTBNSpace;
  65390. /**
  65391. * Gets the main code of the block (fragment side)
  65392. * @param state current state of the node material building
  65393. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65394. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65395. * @param worldPosVarName name of the variable holding the world position
  65396. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65397. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65398. * @param worldNormalVarName name of the variable holding the world normal
  65399. * @returns the shader code
  65400. */
  65401. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65402. protected _buildBlock(state: NodeMaterialBuildState): this;
  65403. }
  65404. }
  65405. declare module BABYLON {
  65406. /**
  65407. * Block used to implement the sub surface module of the PBR material
  65408. */
  65409. export class SubSurfaceBlock extends NodeMaterialBlock {
  65410. /**
  65411. * Create a new SubSurfaceBlock
  65412. * @param name defines the block name
  65413. */
  65414. constructor(name: string);
  65415. /**
  65416. * Stores the intensity of the different subsurface effects in the thickness texture.
  65417. * * the green channel is the translucency intensity.
  65418. * * the blue channel is the scattering intensity.
  65419. * * the alpha channel is the refraction intensity.
  65420. */
  65421. useMaskFromThicknessTexture: boolean;
  65422. /**
  65423. * Initialize the block and prepare the context for build
  65424. * @param state defines the state that will be used for the build
  65425. */
  65426. initialize(state: NodeMaterialBuildState): void;
  65427. /**
  65428. * Gets the current class name
  65429. * @returns the class name
  65430. */
  65431. getClassName(): string;
  65432. /**
  65433. * Gets the min thickness input component
  65434. */
  65435. get minThickness(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the max thickness input component
  65438. */
  65439. get maxThickness(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the thickness texture component
  65442. */
  65443. get thicknessTexture(): NodeMaterialConnectionPoint;
  65444. /**
  65445. * Gets the tint color input component
  65446. */
  65447. get tintColor(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the translucency intensity input component
  65450. */
  65451. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65452. /**
  65453. * Gets the translucency diffusion distance input component
  65454. */
  65455. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65456. /**
  65457. * Gets the refraction object parameters
  65458. */
  65459. get refraction(): NodeMaterialConnectionPoint;
  65460. /**
  65461. * Gets the sub surface object output component
  65462. */
  65463. get subsurface(): NodeMaterialConnectionPoint;
  65464. autoConfigure(material: NodeMaterial): void;
  65465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65466. /**
  65467. * Gets the main code of the block (fragment side)
  65468. * @param state current state of the node material building
  65469. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65470. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65471. * @param worldPosVarName name of the variable holding the world position
  65472. * @returns the shader code
  65473. */
  65474. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65475. protected _buildBlock(state: NodeMaterialBuildState): this;
  65476. }
  65477. }
  65478. declare module BABYLON {
  65479. /**
  65480. * Block used to implement the PBR metallic/roughness model
  65481. */
  65482. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65483. /**
  65484. * Gets or sets the light associated with this block
  65485. */
  65486. light: Nullable<Light>;
  65487. private _lightId;
  65488. private _scene;
  65489. private _environmentBRDFTexture;
  65490. private _environmentBrdfSamplerName;
  65491. private _vNormalWName;
  65492. private _invertNormalName;
  65493. /**
  65494. * Create a new ReflectionBlock
  65495. * @param name defines the block name
  65496. */
  65497. constructor(name: string);
  65498. /**
  65499. * Intensity of the direct lights e.g. the four lights available in your scene.
  65500. * This impacts both the direct diffuse and specular highlights.
  65501. */
  65502. directIntensity: number;
  65503. /**
  65504. * Intensity of the environment e.g. how much the environment will light the object
  65505. * either through harmonics for rough material or through the refelction for shiny ones.
  65506. */
  65507. environmentIntensity: number;
  65508. /**
  65509. * This is a special control allowing the reduction of the specular highlights coming from the
  65510. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65511. */
  65512. specularIntensity: number;
  65513. /**
  65514. * Defines the falloff type used in this material.
  65515. * It by default is Physical.
  65516. */
  65517. lightFalloff: number;
  65518. /**
  65519. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65520. */
  65521. useAlphaFromAlbedoTexture: boolean;
  65522. /**
  65523. * Specifies that alpha test should be used
  65524. */
  65525. useAlphaTest: boolean;
  65526. /**
  65527. * Defines the alpha limits in alpha test mode.
  65528. */
  65529. alphaTestCutoff: number;
  65530. /**
  65531. * Specifies that alpha blending should be used
  65532. */
  65533. useAlphaBlending: boolean;
  65534. /**
  65535. * Defines if the alpha value should be determined via the rgb values.
  65536. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65537. */
  65538. opacityRGB: boolean;
  65539. /**
  65540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65542. */
  65543. useRadianceOverAlpha: boolean;
  65544. /**
  65545. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65546. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65547. */
  65548. useSpecularOverAlpha: boolean;
  65549. /**
  65550. * Enables specular anti aliasing in the PBR shader.
  65551. * It will both interacts on the Geometry for analytical and IBL lighting.
  65552. * It also prefilter the roughness map based on the bump values.
  65553. */
  65554. enableSpecularAntiAliasing: boolean;
  65555. /**
  65556. * Enables realtime filtering on the texture.
  65557. */
  65558. realTimeFiltering: boolean;
  65559. /**
  65560. * Quality switch for realtime filtering
  65561. */
  65562. realTimeFilteringQuality: number;
  65563. /**
  65564. * Defines if the material uses energy conservation.
  65565. */
  65566. useEnergyConservation: boolean;
  65567. /**
  65568. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65569. * too much the area relying on ambient texture to define their ambient occlusion.
  65570. */
  65571. useRadianceOcclusion: boolean;
  65572. /**
  65573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65574. * makes the reflect vector face the model (under horizon).
  65575. */
  65576. useHorizonOcclusion: boolean;
  65577. /**
  65578. * If set to true, no lighting calculations will be applied.
  65579. */
  65580. unlit: boolean;
  65581. /**
  65582. * Force normal to face away from face.
  65583. */
  65584. forceNormalForward: boolean;
  65585. /**
  65586. * Defines the material debug mode.
  65587. * It helps seeing only some components of the material while troubleshooting.
  65588. */
  65589. debugMode: number;
  65590. /**
  65591. * Specify from where on screen the debug mode should start.
  65592. * The value goes from -1 (full screen) to 1 (not visible)
  65593. * It helps with side by side comparison against the final render
  65594. * This defaults to 0
  65595. */
  65596. debugLimit: number;
  65597. /**
  65598. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65599. * You can use the factor to better multiply the final value.
  65600. */
  65601. debugFactor: number;
  65602. /**
  65603. * Initialize the block and prepare the context for build
  65604. * @param state defines the state that will be used for the build
  65605. */
  65606. initialize(state: NodeMaterialBuildState): void;
  65607. /**
  65608. * Gets the current class name
  65609. * @returns the class name
  65610. */
  65611. getClassName(): string;
  65612. /**
  65613. * Gets the world position input component
  65614. */
  65615. get worldPosition(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the world normal input component
  65618. */
  65619. get worldNormal(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the perturbed normal input component
  65622. */
  65623. get perturbedNormal(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the camera position input component
  65626. */
  65627. get cameraPosition(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the base color input component
  65630. */
  65631. get baseColor(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the opacity texture input component
  65634. */
  65635. get opacityTexture(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the ambient color input component
  65638. */
  65639. get ambientColor(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the reflectivity object parameters
  65642. */
  65643. get reflectivity(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the ambient occlusion object parameters
  65646. */
  65647. get ambientOcc(): NodeMaterialConnectionPoint;
  65648. /**
  65649. * Gets the reflection object parameters
  65650. */
  65651. get reflection(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the sheen object parameters
  65654. */
  65655. get sheen(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the clear coat object parameters
  65658. */
  65659. get clearcoat(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the sub surface object parameters
  65662. */
  65663. get subsurface(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the anisotropy object parameters
  65666. */
  65667. get anisotropy(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the ambient output component
  65670. */
  65671. get ambient(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the diffuse output component
  65674. */
  65675. get diffuse(): NodeMaterialConnectionPoint;
  65676. /**
  65677. * Gets the specular output component
  65678. */
  65679. get specular(): NodeMaterialConnectionPoint;
  65680. /**
  65681. * Gets the sheen output component
  65682. */
  65683. get sheenDir(): NodeMaterialConnectionPoint;
  65684. /**
  65685. * Gets the clear coat output component
  65686. */
  65687. get clearcoatDir(): NodeMaterialConnectionPoint;
  65688. /**
  65689. * Gets the indirect diffuse output component
  65690. */
  65691. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65692. /**
  65693. * Gets the indirect specular output component
  65694. */
  65695. get specularIndirect(): NodeMaterialConnectionPoint;
  65696. /**
  65697. * Gets the indirect sheen output component
  65698. */
  65699. get sheenIndirect(): NodeMaterialConnectionPoint;
  65700. /**
  65701. * Gets the indirect clear coat output component
  65702. */
  65703. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65704. /**
  65705. * Gets the refraction output component
  65706. */
  65707. get refraction(): NodeMaterialConnectionPoint;
  65708. /**
  65709. * Gets the global lighting output component
  65710. */
  65711. get lighting(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the shadow output component
  65714. */
  65715. get shadow(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the alpha output component
  65718. */
  65719. get alpha(): NodeMaterialConnectionPoint;
  65720. autoConfigure(material: NodeMaterial): void;
  65721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65722. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65724. private _injectVertexCode;
  65725. /**
  65726. * Gets the code corresponding to the albedo/opacity module
  65727. * @returns the shader code
  65728. */
  65729. getAlbedoOpacityCode(): string;
  65730. protected _buildBlock(state: NodeMaterialBuildState): this;
  65731. protected _dumpPropertiesCode(): string;
  65732. serialize(): any;
  65733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65734. }
  65735. }
  65736. declare module BABYLON {
  65737. /**
  65738. * Block used to compute value of one parameter modulo another
  65739. */
  65740. export class ModBlock extends NodeMaterialBlock {
  65741. /**
  65742. * Creates a new ModBlock
  65743. * @param name defines the block name
  65744. */
  65745. constructor(name: string);
  65746. /**
  65747. * Gets the current class name
  65748. * @returns the class name
  65749. */
  65750. getClassName(): string;
  65751. /**
  65752. * Gets the left operand input component
  65753. */
  65754. get left(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the right operand input component
  65757. */
  65758. get right(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the output component
  65761. */
  65762. get output(): NodeMaterialConnectionPoint;
  65763. protected _buildBlock(state: NodeMaterialBuildState): this;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * Configuration for Draco compression
  65769. */
  65770. export interface IDracoCompressionConfiguration {
  65771. /**
  65772. * Configuration for the decoder.
  65773. */
  65774. decoder: {
  65775. /**
  65776. * The url to the WebAssembly module.
  65777. */
  65778. wasmUrl?: string;
  65779. /**
  65780. * The url to the WebAssembly binary.
  65781. */
  65782. wasmBinaryUrl?: string;
  65783. /**
  65784. * The url to the fallback JavaScript module.
  65785. */
  65786. fallbackUrl?: string;
  65787. };
  65788. }
  65789. /**
  65790. * Draco compression (https://google.github.io/draco/)
  65791. *
  65792. * This class wraps the Draco module.
  65793. *
  65794. * **Encoder**
  65795. *
  65796. * The encoder is not currently implemented.
  65797. *
  65798. * **Decoder**
  65799. *
  65800. * 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.
  65801. *
  65802. * To update the configuration, use the following code:
  65803. * ```javascript
  65804. * DracoCompression.Configuration = {
  65805. * decoder: {
  65806. * wasmUrl: "<url to the WebAssembly library>",
  65807. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65808. * fallbackUrl: "<url to the fallback JavaScript library>",
  65809. * }
  65810. * };
  65811. * ```
  65812. *
  65813. * 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.
  65814. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65815. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65816. *
  65817. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65818. * ```javascript
  65819. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65820. * ```
  65821. *
  65822. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65823. */
  65824. export class DracoCompression implements IDisposable {
  65825. private _workerPoolPromise?;
  65826. private _decoderModulePromise?;
  65827. /**
  65828. * The configuration. Defaults to the following urls:
  65829. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65830. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65831. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65832. */
  65833. static Configuration: IDracoCompressionConfiguration;
  65834. /**
  65835. * Returns true if the decoder configuration is available.
  65836. */
  65837. static get DecoderAvailable(): boolean;
  65838. /**
  65839. * Default number of workers to create when creating the draco compression object.
  65840. */
  65841. static DefaultNumWorkers: number;
  65842. private static GetDefaultNumWorkers;
  65843. private static _Default;
  65844. /**
  65845. * Default instance for the draco compression object.
  65846. */
  65847. static get Default(): DracoCompression;
  65848. /**
  65849. * Constructor
  65850. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65851. */
  65852. constructor(numWorkers?: number);
  65853. /**
  65854. * Stop all async operations and release resources.
  65855. */
  65856. dispose(): void;
  65857. /**
  65858. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65859. * @returns a promise that resolves when ready
  65860. */
  65861. whenReadyAsync(): Promise<void>;
  65862. /**
  65863. * Decode Draco compressed mesh data to vertex data.
  65864. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65865. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65866. * @returns A promise that resolves with the decoded vertex data
  65867. */
  65868. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65869. [kind: string]: number;
  65870. }): Promise<VertexData>;
  65871. }
  65872. }
  65873. declare module BABYLON {
  65874. /**
  65875. * Class for building Constructive Solid Geometry
  65876. */
  65877. export class CSG {
  65878. private polygons;
  65879. /**
  65880. * The world matrix
  65881. */
  65882. matrix: Matrix;
  65883. /**
  65884. * Stores the position
  65885. */
  65886. position: Vector3;
  65887. /**
  65888. * Stores the rotation
  65889. */
  65890. rotation: Vector3;
  65891. /**
  65892. * Stores the rotation quaternion
  65893. */
  65894. rotationQuaternion: Nullable<Quaternion>;
  65895. /**
  65896. * Stores the scaling vector
  65897. */
  65898. scaling: Vector3;
  65899. /**
  65900. * Convert the Mesh to CSG
  65901. * @param mesh The Mesh to convert to CSG
  65902. * @returns A new CSG from the Mesh
  65903. */
  65904. static FromMesh(mesh: Mesh): CSG;
  65905. /**
  65906. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65907. * @param polygons Polygons used to construct a CSG solid
  65908. */
  65909. private static FromPolygons;
  65910. /**
  65911. * Clones, or makes a deep copy, of the CSG
  65912. * @returns A new CSG
  65913. */
  65914. clone(): CSG;
  65915. /**
  65916. * Unions this CSG with another CSG
  65917. * @param csg The CSG to union against this CSG
  65918. * @returns The unioned CSG
  65919. */
  65920. union(csg: CSG): CSG;
  65921. /**
  65922. * Unions this CSG with another CSG in place
  65923. * @param csg The CSG to union against this CSG
  65924. */
  65925. unionInPlace(csg: CSG): void;
  65926. /**
  65927. * Subtracts this CSG with another CSG
  65928. * @param csg The CSG to subtract against this CSG
  65929. * @returns A new CSG
  65930. */
  65931. subtract(csg: CSG): CSG;
  65932. /**
  65933. * Subtracts this CSG with another CSG in place
  65934. * @param csg The CSG to subtact against this CSG
  65935. */
  65936. subtractInPlace(csg: CSG): void;
  65937. /**
  65938. * Intersect this CSG with another CSG
  65939. * @param csg The CSG to intersect against this CSG
  65940. * @returns A new CSG
  65941. */
  65942. intersect(csg: CSG): CSG;
  65943. /**
  65944. * Intersects this CSG with another CSG in place
  65945. * @param csg The CSG to intersect against this CSG
  65946. */
  65947. intersectInPlace(csg: CSG): void;
  65948. /**
  65949. * Return a new CSG solid with solid and empty space switched. This solid is
  65950. * not modified.
  65951. * @returns A new CSG solid with solid and empty space switched
  65952. */
  65953. inverse(): CSG;
  65954. /**
  65955. * Inverses the CSG in place
  65956. */
  65957. inverseInPlace(): void;
  65958. /**
  65959. * This is used to keep meshes transformations so they can be restored
  65960. * when we build back a Babylon Mesh
  65961. * NB : All CSG operations are performed in world coordinates
  65962. * @param csg The CSG to copy the transform attributes from
  65963. * @returns This CSG
  65964. */
  65965. copyTransformAttributes(csg: CSG): CSG;
  65966. /**
  65967. * Build Raw mesh from CSG
  65968. * Coordinates here are in world space
  65969. * @param name The name of the mesh geometry
  65970. * @param scene The Scene
  65971. * @param keepSubMeshes Specifies if the submeshes should be kept
  65972. * @returns A new Mesh
  65973. */
  65974. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65975. /**
  65976. * Build Mesh from CSG taking material and transforms into account
  65977. * @param name The name of the Mesh
  65978. * @param material The material of the Mesh
  65979. * @param scene The Scene
  65980. * @param keepSubMeshes Specifies if submeshes should be kept
  65981. * @returns The new Mesh
  65982. */
  65983. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65984. }
  65985. }
  65986. declare module BABYLON {
  65987. /**
  65988. * Class used to create a trail following a mesh
  65989. */
  65990. export class TrailMesh extends Mesh {
  65991. private _generator;
  65992. private _autoStart;
  65993. private _running;
  65994. private _diameter;
  65995. private _length;
  65996. private _sectionPolygonPointsCount;
  65997. private _sectionVectors;
  65998. private _sectionNormalVectors;
  65999. private _beforeRenderObserver;
  66000. /**
  66001. * @constructor
  66002. * @param name The value used by scene.getMeshByName() to do a lookup.
  66003. * @param generator The mesh or transform node to generate a trail.
  66004. * @param scene The scene to add this mesh to.
  66005. * @param diameter Diameter of trailing mesh. Default is 1.
  66006. * @param length Length of trailing mesh. Default is 60.
  66007. * @param autoStart Automatically start trailing mesh. Default true.
  66008. */
  66009. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66010. /**
  66011. * "TrailMesh"
  66012. * @returns "TrailMesh"
  66013. */
  66014. getClassName(): string;
  66015. private _createMesh;
  66016. /**
  66017. * Start trailing mesh.
  66018. */
  66019. start(): void;
  66020. /**
  66021. * Stop trailing mesh.
  66022. */
  66023. stop(): void;
  66024. /**
  66025. * Update trailing mesh geometry.
  66026. */
  66027. update(): void;
  66028. /**
  66029. * Returns a new TrailMesh object.
  66030. * @param name is a string, the name given to the new mesh
  66031. * @param newGenerator use new generator object for cloned trail mesh
  66032. * @returns a new mesh
  66033. */
  66034. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66035. /**
  66036. * Serializes this trail mesh
  66037. * @param serializationObject object to write serialization to
  66038. */
  66039. serialize(serializationObject: any): void;
  66040. /**
  66041. * Parses a serialized trail mesh
  66042. * @param parsedMesh the serialized mesh
  66043. * @param scene the scene to create the trail mesh in
  66044. * @returns the created trail mesh
  66045. */
  66046. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66047. }
  66048. }
  66049. declare module BABYLON {
  66050. /**
  66051. * Class containing static functions to help procedurally build meshes
  66052. */
  66053. export class TiledBoxBuilder {
  66054. /**
  66055. * Creates a box mesh
  66056. * 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)
  66057. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66059. * * 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
  66060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66061. * @param name defines the name of the mesh
  66062. * @param options defines the options used to create the mesh
  66063. * @param scene defines the hosting scene
  66064. * @returns the box mesh
  66065. */
  66066. static CreateTiledBox(name: string, options: {
  66067. pattern?: number;
  66068. width?: number;
  66069. height?: number;
  66070. depth?: number;
  66071. tileSize?: number;
  66072. tileWidth?: number;
  66073. tileHeight?: number;
  66074. alignHorizontal?: number;
  66075. alignVertical?: number;
  66076. faceUV?: Vector4[];
  66077. faceColors?: Color4[];
  66078. sideOrientation?: number;
  66079. updatable?: boolean;
  66080. }, scene?: Nullable<Scene>): Mesh;
  66081. }
  66082. }
  66083. declare module BABYLON {
  66084. /**
  66085. * Class containing static functions to help procedurally build meshes
  66086. */
  66087. export class TorusKnotBuilder {
  66088. /**
  66089. * Creates a torus knot mesh
  66090. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66091. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66092. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66093. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66095. * * 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
  66096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66097. * @param name defines the name of the mesh
  66098. * @param options defines the options used to create the mesh
  66099. * @param scene defines the hosting scene
  66100. * @returns the torus knot mesh
  66101. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66102. */
  66103. static CreateTorusKnot(name: string, options: {
  66104. radius?: number;
  66105. tube?: number;
  66106. radialSegments?: number;
  66107. tubularSegments?: number;
  66108. p?: number;
  66109. q?: number;
  66110. updatable?: boolean;
  66111. sideOrientation?: number;
  66112. frontUVs?: Vector4;
  66113. backUVs?: Vector4;
  66114. }, scene: any): Mesh;
  66115. }
  66116. }
  66117. declare module BABYLON {
  66118. /**
  66119. * Polygon
  66120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66121. */
  66122. export class Polygon {
  66123. /**
  66124. * Creates a rectangle
  66125. * @param xmin bottom X coord
  66126. * @param ymin bottom Y coord
  66127. * @param xmax top X coord
  66128. * @param ymax top Y coord
  66129. * @returns points that make the resulting rectation
  66130. */
  66131. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66132. /**
  66133. * Creates a circle
  66134. * @param radius radius of circle
  66135. * @param cx scale in x
  66136. * @param cy scale in y
  66137. * @param numberOfSides number of sides that make up the circle
  66138. * @returns points that make the resulting circle
  66139. */
  66140. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66141. /**
  66142. * Creates a polygon from input string
  66143. * @param input Input polygon data
  66144. * @returns the parsed points
  66145. */
  66146. static Parse(input: string): Vector2[];
  66147. /**
  66148. * Starts building a polygon from x and y coordinates
  66149. * @param x x coordinate
  66150. * @param y y coordinate
  66151. * @returns the started path2
  66152. */
  66153. static StartingAt(x: number, y: number): Path2;
  66154. }
  66155. /**
  66156. * Builds a polygon
  66157. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66158. */
  66159. export class PolygonMeshBuilder {
  66160. private _points;
  66161. private _outlinepoints;
  66162. private _holes;
  66163. private _name;
  66164. private _scene;
  66165. private _epoints;
  66166. private _eholes;
  66167. private _addToepoint;
  66168. /**
  66169. * Babylon reference to the earcut plugin.
  66170. */
  66171. bjsEarcut: any;
  66172. /**
  66173. * Creates a PolygonMeshBuilder
  66174. * @param name name of the builder
  66175. * @param contours Path of the polygon
  66176. * @param scene scene to add to when creating the mesh
  66177. * @param earcutInjection can be used to inject your own earcut reference
  66178. */
  66179. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66180. /**
  66181. * Adds a whole within the polygon
  66182. * @param hole Array of points defining the hole
  66183. * @returns this
  66184. */
  66185. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66186. /**
  66187. * Creates the polygon
  66188. * @param updatable If the mesh should be updatable
  66189. * @param depth The depth of the mesh created
  66190. * @returns the created mesh
  66191. */
  66192. build(updatable?: boolean, depth?: number): Mesh;
  66193. /**
  66194. * Creates the polygon
  66195. * @param depth The depth of the mesh created
  66196. * @returns the created VertexData
  66197. */
  66198. buildVertexData(depth?: number): VertexData;
  66199. /**
  66200. * Adds a side to the polygon
  66201. * @param positions points that make the polygon
  66202. * @param normals normals of the polygon
  66203. * @param uvs uvs of the polygon
  66204. * @param indices indices of the polygon
  66205. * @param bounds bounds of the polygon
  66206. * @param points points of the polygon
  66207. * @param depth depth of the polygon
  66208. * @param flip flip of the polygon
  66209. */
  66210. private addSide;
  66211. }
  66212. }
  66213. declare module BABYLON {
  66214. /**
  66215. * Class containing static functions to help procedurally build meshes
  66216. */
  66217. export class PolygonBuilder {
  66218. /**
  66219. * Creates a polygon mesh
  66220. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66221. * * 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
  66222. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66224. * * 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)
  66225. * * Remember you can only change the shape positions, not their number when updating a polygon
  66226. * @param name defines the name of the mesh
  66227. * @param options defines the options used to create the mesh
  66228. * @param scene defines the hosting scene
  66229. * @param earcutInjection can be used to inject your own earcut reference
  66230. * @returns the polygon mesh
  66231. */
  66232. static CreatePolygon(name: string, options: {
  66233. shape: Vector3[];
  66234. holes?: Vector3[][];
  66235. depth?: number;
  66236. faceUV?: Vector4[];
  66237. faceColors?: Color4[];
  66238. updatable?: boolean;
  66239. sideOrientation?: number;
  66240. frontUVs?: Vector4;
  66241. backUVs?: Vector4;
  66242. wrap?: boolean;
  66243. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66244. /**
  66245. * Creates an extruded polygon mesh, with depth in the Y direction.
  66246. * * 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)
  66247. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66248. * @param name defines the name of the mesh
  66249. * @param options defines the options used to create the mesh
  66250. * @param scene defines the hosting scene
  66251. * @param earcutInjection can be used to inject your own earcut reference
  66252. * @returns the polygon mesh
  66253. */
  66254. static ExtrudePolygon(name: string, options: {
  66255. shape: Vector3[];
  66256. holes?: Vector3[][];
  66257. depth?: number;
  66258. faceUV?: Vector4[];
  66259. faceColors?: Color4[];
  66260. updatable?: boolean;
  66261. sideOrientation?: number;
  66262. frontUVs?: Vector4;
  66263. backUVs?: Vector4;
  66264. wrap?: boolean;
  66265. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66266. }
  66267. }
  66268. declare module BABYLON {
  66269. /**
  66270. * Class containing static functions to help procedurally build meshes
  66271. */
  66272. export class LatheBuilder {
  66273. /**
  66274. * Creates lathe mesh.
  66275. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66276. * * 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
  66277. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66278. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66279. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66280. * * 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
  66281. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66282. * * 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
  66283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66284. * * 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
  66285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66287. * @param name defines the name of the mesh
  66288. * @param options defines the options used to create the mesh
  66289. * @param scene defines the hosting scene
  66290. * @returns the lathe mesh
  66291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66292. */
  66293. static CreateLathe(name: string, options: {
  66294. shape: Vector3[];
  66295. radius?: number;
  66296. tessellation?: number;
  66297. clip?: number;
  66298. arc?: number;
  66299. closed?: boolean;
  66300. updatable?: boolean;
  66301. sideOrientation?: number;
  66302. frontUVs?: Vector4;
  66303. backUVs?: Vector4;
  66304. cap?: number;
  66305. invertUV?: boolean;
  66306. }, scene?: Nullable<Scene>): Mesh;
  66307. }
  66308. }
  66309. declare module BABYLON {
  66310. /**
  66311. * Class containing static functions to help procedurally build meshes
  66312. */
  66313. export class TiledPlaneBuilder {
  66314. /**
  66315. * Creates a tiled plane mesh
  66316. * * The parameter `pattern` will, depending on value, do nothing or
  66317. * * * flip (reflect about central vertical) alternate tiles across and up
  66318. * * * flip every tile on alternate rows
  66319. * * * rotate (180 degs) alternate tiles across and up
  66320. * * * rotate every tile on alternate rows
  66321. * * * flip and rotate alternate tiles across and up
  66322. * * * flip and rotate every tile on alternate rows
  66323. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66324. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66325. * * 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
  66326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66327. * * 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)
  66328. * * 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)
  66329. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66330. * @param name defines the name of the mesh
  66331. * @param options defines the options used to create the mesh
  66332. * @param scene defines the hosting scene
  66333. * @returns the box mesh
  66334. */
  66335. static CreateTiledPlane(name: string, options: {
  66336. pattern?: number;
  66337. tileSize?: number;
  66338. tileWidth?: number;
  66339. tileHeight?: number;
  66340. size?: number;
  66341. width?: number;
  66342. height?: number;
  66343. alignHorizontal?: number;
  66344. alignVertical?: number;
  66345. sideOrientation?: number;
  66346. frontUVs?: Vector4;
  66347. backUVs?: Vector4;
  66348. updatable?: boolean;
  66349. }, scene?: Nullable<Scene>): Mesh;
  66350. }
  66351. }
  66352. declare module BABYLON {
  66353. /**
  66354. * Class containing static functions to help procedurally build meshes
  66355. */
  66356. export class TubeBuilder {
  66357. /**
  66358. * Creates a tube mesh.
  66359. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66360. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66361. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66362. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66363. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66364. * * 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)
  66365. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66366. * * 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
  66367. * * 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
  66368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66369. * * 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
  66370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66372. * @param name defines the name of the mesh
  66373. * @param options defines the options used to create the mesh
  66374. * @param scene defines the hosting scene
  66375. * @returns the tube mesh
  66376. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66377. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66378. */
  66379. static CreateTube(name: string, options: {
  66380. path: Vector3[];
  66381. radius?: number;
  66382. tessellation?: number;
  66383. radiusFunction?: {
  66384. (i: number, distance: number): number;
  66385. };
  66386. cap?: number;
  66387. arc?: number;
  66388. updatable?: boolean;
  66389. sideOrientation?: number;
  66390. frontUVs?: Vector4;
  66391. backUVs?: Vector4;
  66392. instance?: Mesh;
  66393. invertUV?: boolean;
  66394. }, scene?: Nullable<Scene>): Mesh;
  66395. }
  66396. }
  66397. declare module BABYLON {
  66398. /**
  66399. * Class containing static functions to help procedurally build meshes
  66400. */
  66401. export class IcoSphereBuilder {
  66402. /**
  66403. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66404. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66405. * * 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`)
  66406. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66407. * * 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
  66408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66409. * * 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
  66410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66411. * @param name defines the name of the mesh
  66412. * @param options defines the options used to create the mesh
  66413. * @param scene defines the hosting scene
  66414. * @returns the icosahedron mesh
  66415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66416. */
  66417. static CreateIcoSphere(name: string, options: {
  66418. radius?: number;
  66419. radiusX?: number;
  66420. radiusY?: number;
  66421. radiusZ?: number;
  66422. flat?: boolean;
  66423. subdivisions?: number;
  66424. sideOrientation?: number;
  66425. frontUVs?: Vector4;
  66426. backUVs?: Vector4;
  66427. updatable?: boolean;
  66428. }, scene?: Nullable<Scene>): Mesh;
  66429. }
  66430. }
  66431. declare module BABYLON {
  66432. /**
  66433. * Class containing static functions to help procedurally build meshes
  66434. */
  66435. export class DecalBuilder {
  66436. /**
  66437. * Creates a decal mesh.
  66438. * 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
  66439. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66440. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66441. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66442. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66443. * @param name defines the name of the mesh
  66444. * @param sourceMesh defines the mesh where the decal must be applied
  66445. * @param options defines the options used to create the mesh
  66446. * @param scene defines the hosting scene
  66447. * @returns the decal mesh
  66448. * @see https://doc.babylonjs.com/how_to/decals
  66449. */
  66450. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66451. position?: Vector3;
  66452. normal?: Vector3;
  66453. size?: Vector3;
  66454. angle?: number;
  66455. }): Mesh;
  66456. }
  66457. }
  66458. declare module BABYLON {
  66459. /**
  66460. * Class containing static functions to help procedurally build meshes
  66461. */
  66462. export class MeshBuilder {
  66463. /**
  66464. * Creates a box mesh
  66465. * * The parameter `size` sets the size (float) of each box side (default 1)
  66466. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66467. * * 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)
  66468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66470. * * 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
  66471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66472. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66473. * @param name defines the name of the mesh
  66474. * @param options defines the options used to create the mesh
  66475. * @param scene defines the hosting scene
  66476. * @returns the box mesh
  66477. */
  66478. static CreateBox(name: string, options: {
  66479. size?: number;
  66480. width?: number;
  66481. height?: number;
  66482. depth?: number;
  66483. faceUV?: Vector4[];
  66484. faceColors?: Color4[];
  66485. sideOrientation?: number;
  66486. frontUVs?: Vector4;
  66487. backUVs?: Vector4;
  66488. wrap?: boolean;
  66489. topBaseAt?: number;
  66490. bottomBaseAt?: number;
  66491. updatable?: boolean;
  66492. }, scene?: Nullable<Scene>): Mesh;
  66493. /**
  66494. * Creates a tiled box mesh
  66495. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66497. * @param name defines the name of the mesh
  66498. * @param options defines the options used to create the mesh
  66499. * @param scene defines the hosting scene
  66500. * @returns the tiled box mesh
  66501. */
  66502. static CreateTiledBox(name: string, options: {
  66503. pattern?: number;
  66504. size?: number;
  66505. width?: number;
  66506. height?: number;
  66507. depth: number;
  66508. tileSize?: number;
  66509. tileWidth?: number;
  66510. tileHeight?: number;
  66511. faceUV?: Vector4[];
  66512. faceColors?: Color4[];
  66513. alignHorizontal?: number;
  66514. alignVertical?: number;
  66515. sideOrientation?: number;
  66516. updatable?: boolean;
  66517. }, scene?: Nullable<Scene>): Mesh;
  66518. /**
  66519. * Creates a sphere mesh
  66520. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66521. * * 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`)
  66522. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66523. * * 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
  66524. * * 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)
  66525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66526. * * 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
  66527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66528. * @param name defines the name of the mesh
  66529. * @param options defines the options used to create the mesh
  66530. * @param scene defines the hosting scene
  66531. * @returns the sphere mesh
  66532. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66533. */
  66534. static CreateSphere(name: string, options: {
  66535. segments?: number;
  66536. diameter?: number;
  66537. diameterX?: number;
  66538. diameterY?: number;
  66539. diameterZ?: number;
  66540. arc?: number;
  66541. slice?: number;
  66542. sideOrientation?: number;
  66543. frontUVs?: Vector4;
  66544. backUVs?: Vector4;
  66545. updatable?: boolean;
  66546. }, scene?: Nullable<Scene>): Mesh;
  66547. /**
  66548. * Creates a plane polygonal mesh. By default, this is a disc
  66549. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66550. * * 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
  66551. * * 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
  66552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66553. * * 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
  66554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66555. * @param name defines the name of the mesh
  66556. * @param options defines the options used to create the mesh
  66557. * @param scene defines the hosting scene
  66558. * @returns the plane polygonal mesh
  66559. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66560. */
  66561. static CreateDisc(name: string, options: {
  66562. radius?: number;
  66563. tessellation?: number;
  66564. arc?: number;
  66565. updatable?: boolean;
  66566. sideOrientation?: number;
  66567. frontUVs?: Vector4;
  66568. backUVs?: Vector4;
  66569. }, scene?: Nullable<Scene>): Mesh;
  66570. /**
  66571. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66572. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66573. * * 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`)
  66574. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66575. * * 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
  66576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66577. * * 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
  66578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66579. * @param name defines the name of the mesh
  66580. * @param options defines the options used to create the mesh
  66581. * @param scene defines the hosting scene
  66582. * @returns the icosahedron mesh
  66583. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66584. */
  66585. static CreateIcoSphere(name: string, options: {
  66586. radius?: number;
  66587. radiusX?: number;
  66588. radiusY?: number;
  66589. radiusZ?: number;
  66590. flat?: boolean;
  66591. subdivisions?: number;
  66592. sideOrientation?: number;
  66593. frontUVs?: Vector4;
  66594. backUVs?: Vector4;
  66595. updatable?: boolean;
  66596. }, scene?: Nullable<Scene>): Mesh;
  66597. /**
  66598. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66599. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66600. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66601. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66602. * * 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
  66603. * * 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
  66604. * * 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
  66605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66606. * * 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
  66607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66608. * * 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
  66609. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66610. * * 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
  66611. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66613. * @param name defines the name of the mesh
  66614. * @param options defines the options used to create the mesh
  66615. * @param scene defines the hosting scene
  66616. * @returns the ribbon mesh
  66617. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66619. */
  66620. static CreateRibbon(name: string, options: {
  66621. pathArray: Vector3[][];
  66622. closeArray?: boolean;
  66623. closePath?: boolean;
  66624. offset?: number;
  66625. updatable?: boolean;
  66626. sideOrientation?: number;
  66627. frontUVs?: Vector4;
  66628. backUVs?: Vector4;
  66629. instance?: Mesh;
  66630. invertUV?: boolean;
  66631. uvs?: Vector2[];
  66632. colors?: Color4[];
  66633. }, scene?: Nullable<Scene>): Mesh;
  66634. /**
  66635. * Creates a cylinder or a cone mesh
  66636. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66637. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66638. * * 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.
  66639. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66640. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66641. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66642. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66643. * * 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).
  66644. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66645. * * 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).
  66646. * * 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
  66647. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66648. * * 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
  66649. * * 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.
  66650. * * If `enclose` is false, a ring surface is one element.
  66651. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66652. * * 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
  66653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66654. * * 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
  66655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66656. * @param name defines the name of the mesh
  66657. * @param options defines the options used to create the mesh
  66658. * @param scene defines the hosting scene
  66659. * @returns the cylinder mesh
  66660. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66661. */
  66662. static CreateCylinder(name: string, options: {
  66663. height?: number;
  66664. diameterTop?: number;
  66665. diameterBottom?: number;
  66666. diameter?: number;
  66667. tessellation?: number;
  66668. subdivisions?: number;
  66669. arc?: number;
  66670. faceColors?: Color4[];
  66671. faceUV?: Vector4[];
  66672. updatable?: boolean;
  66673. hasRings?: boolean;
  66674. enclose?: boolean;
  66675. cap?: number;
  66676. sideOrientation?: number;
  66677. frontUVs?: Vector4;
  66678. backUVs?: Vector4;
  66679. }, scene?: Nullable<Scene>): Mesh;
  66680. /**
  66681. * Creates a torus mesh
  66682. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66683. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66684. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66686. * * 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
  66687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66688. * @param name defines the name of the mesh
  66689. * @param options defines the options used to create the mesh
  66690. * @param scene defines the hosting scene
  66691. * @returns the torus mesh
  66692. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66693. */
  66694. static CreateTorus(name: string, options: {
  66695. diameter?: number;
  66696. thickness?: number;
  66697. tessellation?: number;
  66698. updatable?: boolean;
  66699. sideOrientation?: number;
  66700. frontUVs?: Vector4;
  66701. backUVs?: Vector4;
  66702. }, scene?: Nullable<Scene>): Mesh;
  66703. /**
  66704. * Creates a torus knot mesh
  66705. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66706. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66707. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66708. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66710. * * 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
  66711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66712. * @param name defines the name of the mesh
  66713. * @param options defines the options used to create the mesh
  66714. * @param scene defines the hosting scene
  66715. * @returns the torus knot mesh
  66716. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66717. */
  66718. static CreateTorusKnot(name: string, options: {
  66719. radius?: number;
  66720. tube?: number;
  66721. radialSegments?: number;
  66722. tubularSegments?: number;
  66723. p?: number;
  66724. q?: number;
  66725. updatable?: boolean;
  66726. sideOrientation?: number;
  66727. frontUVs?: Vector4;
  66728. backUVs?: Vector4;
  66729. }, scene?: Nullable<Scene>): Mesh;
  66730. /**
  66731. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66732. * * 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
  66733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66734. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66735. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66736. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66737. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66738. * * 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
  66739. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66742. * @param name defines the name of the new line system
  66743. * @param options defines the options used to create the line system
  66744. * @param scene defines the hosting scene
  66745. * @returns a new line system mesh
  66746. */
  66747. static CreateLineSystem(name: string, options: {
  66748. lines: Vector3[][];
  66749. updatable?: boolean;
  66750. instance?: Nullable<LinesMesh>;
  66751. colors?: Nullable<Color4[][]>;
  66752. useVertexAlpha?: boolean;
  66753. }, scene: Nullable<Scene>): LinesMesh;
  66754. /**
  66755. * Creates a line mesh
  66756. * 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
  66757. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66758. * * The parameter `points` is an array successive Vector3
  66759. * * 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
  66760. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66761. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66762. * * When updating an instance, remember that only point positions can change, not the number of points
  66763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66765. * @param name defines the name of the new line system
  66766. * @param options defines the options used to create the line system
  66767. * @param scene defines the hosting scene
  66768. * @returns a new line mesh
  66769. */
  66770. static CreateLines(name: string, options: {
  66771. points: Vector3[];
  66772. updatable?: boolean;
  66773. instance?: Nullable<LinesMesh>;
  66774. colors?: Color4[];
  66775. useVertexAlpha?: boolean;
  66776. }, scene?: Nullable<Scene>): LinesMesh;
  66777. /**
  66778. * Creates a dashed line mesh
  66779. * * 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
  66780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66781. * * The parameter `points` is an array successive Vector3
  66782. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66783. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66784. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66785. * * 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
  66786. * * When updating an instance, remember that only point positions can change, not the number of points
  66787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66788. * @param name defines the name of the mesh
  66789. * @param options defines the options used to create the mesh
  66790. * @param scene defines the hosting scene
  66791. * @returns the dashed line mesh
  66792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66793. */
  66794. static CreateDashedLines(name: string, options: {
  66795. points: Vector3[];
  66796. dashSize?: number;
  66797. gapSize?: number;
  66798. dashNb?: number;
  66799. updatable?: boolean;
  66800. instance?: LinesMesh;
  66801. }, scene?: Nullable<Scene>): LinesMesh;
  66802. /**
  66803. * 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.
  66804. * * 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.
  66805. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66806. * * 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.
  66807. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66808. * * 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
  66809. * * 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
  66810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66812. * * 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
  66813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66815. * @param name defines the name of the mesh
  66816. * @param options defines the options used to create the mesh
  66817. * @param scene defines the hosting scene
  66818. * @returns the extruded shape mesh
  66819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66821. */
  66822. static ExtrudeShape(name: string, options: {
  66823. shape: Vector3[];
  66824. path: Vector3[];
  66825. scale?: number;
  66826. rotation?: number;
  66827. cap?: number;
  66828. updatable?: boolean;
  66829. sideOrientation?: number;
  66830. frontUVs?: Vector4;
  66831. backUVs?: Vector4;
  66832. instance?: Mesh;
  66833. invertUV?: boolean;
  66834. }, scene?: Nullable<Scene>): Mesh;
  66835. /**
  66836. * Creates an custom extruded shape mesh.
  66837. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66838. * * 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.
  66839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66840. * * 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
  66841. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66842. * * 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
  66843. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66844. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66845. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66846. * * 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
  66847. * * 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
  66848. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66850. * * 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
  66851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66853. * @param name defines the name of the mesh
  66854. * @param options defines the options used to create the mesh
  66855. * @param scene defines the hosting scene
  66856. * @returns the custom extruded shape mesh
  66857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66860. */
  66861. static ExtrudeShapeCustom(name: string, options: {
  66862. shape: Vector3[];
  66863. path: Vector3[];
  66864. scaleFunction?: any;
  66865. rotationFunction?: any;
  66866. ribbonCloseArray?: boolean;
  66867. ribbonClosePath?: boolean;
  66868. cap?: number;
  66869. updatable?: boolean;
  66870. sideOrientation?: number;
  66871. frontUVs?: Vector4;
  66872. backUVs?: Vector4;
  66873. instance?: Mesh;
  66874. invertUV?: boolean;
  66875. }, scene?: Nullable<Scene>): Mesh;
  66876. /**
  66877. * Creates lathe mesh.
  66878. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66879. * * 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
  66880. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66881. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66882. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66883. * * 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
  66884. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66885. * * 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
  66886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66887. * * 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
  66888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66890. * @param name defines the name of the mesh
  66891. * @param options defines the options used to create the mesh
  66892. * @param scene defines the hosting scene
  66893. * @returns the lathe mesh
  66894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66895. */
  66896. static CreateLathe(name: string, options: {
  66897. shape: Vector3[];
  66898. radius?: number;
  66899. tessellation?: number;
  66900. clip?: number;
  66901. arc?: number;
  66902. closed?: boolean;
  66903. updatable?: boolean;
  66904. sideOrientation?: number;
  66905. frontUVs?: Vector4;
  66906. backUVs?: Vector4;
  66907. cap?: number;
  66908. invertUV?: boolean;
  66909. }, scene?: Nullable<Scene>): Mesh;
  66910. /**
  66911. * Creates a tiled plane mesh
  66912. * * You can set a limited pattern arrangement with the tiles
  66913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66914. * * 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
  66915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66916. * @param name defines the name of the mesh
  66917. * @param options defines the options used to create the mesh
  66918. * @param scene defines the hosting scene
  66919. * @returns the plane mesh
  66920. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66921. */
  66922. static CreateTiledPlane(name: string, options: {
  66923. pattern?: number;
  66924. tileSize?: number;
  66925. tileWidth?: number;
  66926. tileHeight?: number;
  66927. size?: number;
  66928. width?: number;
  66929. height?: number;
  66930. alignHorizontal?: number;
  66931. alignVertical?: number;
  66932. sideOrientation?: number;
  66933. frontUVs?: Vector4;
  66934. backUVs?: Vector4;
  66935. updatable?: boolean;
  66936. }, scene?: Nullable<Scene>): Mesh;
  66937. /**
  66938. * Creates a plane mesh
  66939. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66940. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66941. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66943. * * 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
  66944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66945. * @param name defines the name of the mesh
  66946. * @param options defines the options used to create the mesh
  66947. * @param scene defines the hosting scene
  66948. * @returns the plane mesh
  66949. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66950. */
  66951. static CreatePlane(name: string, options: {
  66952. size?: number;
  66953. width?: number;
  66954. height?: number;
  66955. sideOrientation?: number;
  66956. frontUVs?: Vector4;
  66957. backUVs?: Vector4;
  66958. updatable?: boolean;
  66959. sourcePlane?: Plane;
  66960. }, scene?: Nullable<Scene>): Mesh;
  66961. /**
  66962. * Creates a ground mesh
  66963. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66964. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66966. * @param name defines the name of the mesh
  66967. * @param options defines the options used to create the mesh
  66968. * @param scene defines the hosting scene
  66969. * @returns the ground mesh
  66970. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66971. */
  66972. static CreateGround(name: string, options: {
  66973. width?: number;
  66974. height?: number;
  66975. subdivisions?: number;
  66976. subdivisionsX?: number;
  66977. subdivisionsY?: number;
  66978. updatable?: boolean;
  66979. }, scene?: Nullable<Scene>): Mesh;
  66980. /**
  66981. * Creates a tiled ground mesh
  66982. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66983. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66984. * * 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
  66985. * * 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
  66986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66987. * @param name defines the name of the mesh
  66988. * @param options defines the options used to create the mesh
  66989. * @param scene defines the hosting scene
  66990. * @returns the tiled ground mesh
  66991. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66992. */
  66993. static CreateTiledGround(name: string, options: {
  66994. xmin: number;
  66995. zmin: number;
  66996. xmax: number;
  66997. zmax: number;
  66998. subdivisions?: {
  66999. w: number;
  67000. h: number;
  67001. };
  67002. precision?: {
  67003. w: number;
  67004. h: number;
  67005. };
  67006. updatable?: boolean;
  67007. }, scene?: Nullable<Scene>): Mesh;
  67008. /**
  67009. * Creates a ground mesh from a height map
  67010. * * The parameter `url` sets the URL of the height map image resource.
  67011. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67012. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67013. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67014. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67015. * * 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.
  67016. * * 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).
  67017. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67019. * @param name defines the name of the mesh
  67020. * @param url defines the url to the height map
  67021. * @param options defines the options used to create the mesh
  67022. * @param scene defines the hosting scene
  67023. * @returns the ground mesh
  67024. * @see https://doc.babylonjs.com/babylon101/height_map
  67025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67026. */
  67027. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67028. width?: number;
  67029. height?: number;
  67030. subdivisions?: number;
  67031. minHeight?: number;
  67032. maxHeight?: number;
  67033. colorFilter?: Color3;
  67034. alphaFilter?: number;
  67035. updatable?: boolean;
  67036. onReady?: (mesh: GroundMesh) => void;
  67037. }, scene?: Nullable<Scene>): GroundMesh;
  67038. /**
  67039. * Creates a polygon mesh
  67040. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67041. * * 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
  67042. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67044. * * 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)
  67045. * * Remember you can only change the shape positions, not their number when updating a polygon
  67046. * @param name defines the name of the mesh
  67047. * @param options defines the options used to create the mesh
  67048. * @param scene defines the hosting scene
  67049. * @param earcutInjection can be used to inject your own earcut reference
  67050. * @returns the polygon mesh
  67051. */
  67052. static CreatePolygon(name: string, options: {
  67053. shape: Vector3[];
  67054. holes?: Vector3[][];
  67055. depth?: number;
  67056. faceUV?: Vector4[];
  67057. faceColors?: Color4[];
  67058. updatable?: boolean;
  67059. sideOrientation?: number;
  67060. frontUVs?: Vector4;
  67061. backUVs?: Vector4;
  67062. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67063. /**
  67064. * Creates an extruded polygon mesh, with depth in the Y direction.
  67065. * * 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)
  67066. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67067. * @param name defines the name of the mesh
  67068. * @param options defines the options used to create the mesh
  67069. * @param scene defines the hosting scene
  67070. * @param earcutInjection can be used to inject your own earcut reference
  67071. * @returns the polygon mesh
  67072. */
  67073. static ExtrudePolygon(name: string, options: {
  67074. shape: Vector3[];
  67075. holes?: Vector3[][];
  67076. depth?: number;
  67077. faceUV?: Vector4[];
  67078. faceColors?: Color4[];
  67079. updatable?: boolean;
  67080. sideOrientation?: number;
  67081. frontUVs?: Vector4;
  67082. backUVs?: Vector4;
  67083. wrap?: boolean;
  67084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67085. /**
  67086. * Creates a tube mesh.
  67087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67092. * * 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)
  67093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67094. * * 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
  67095. * * 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
  67096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67097. * * 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
  67098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67100. * @param name defines the name of the mesh
  67101. * @param options defines the options used to create the mesh
  67102. * @param scene defines the hosting scene
  67103. * @returns the tube mesh
  67104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67106. */
  67107. static CreateTube(name: string, options: {
  67108. path: Vector3[];
  67109. radius?: number;
  67110. tessellation?: number;
  67111. radiusFunction?: {
  67112. (i: number, distance: number): number;
  67113. };
  67114. cap?: number;
  67115. arc?: number;
  67116. updatable?: boolean;
  67117. sideOrientation?: number;
  67118. frontUVs?: Vector4;
  67119. backUVs?: Vector4;
  67120. instance?: Mesh;
  67121. invertUV?: boolean;
  67122. }, scene?: Nullable<Scene>): Mesh;
  67123. /**
  67124. * Creates a polyhedron mesh
  67125. * * 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
  67126. * * The parameter `size` (positive float, default 1) sets the polygon size
  67127. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67128. * * 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`
  67129. * * 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
  67130. * * 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)`)
  67131. * * 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
  67132. * * 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
  67133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67134. * * 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
  67135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67136. * @param name defines the name of the mesh
  67137. * @param options defines the options used to create the mesh
  67138. * @param scene defines the hosting scene
  67139. * @returns the polyhedron mesh
  67140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67141. */
  67142. static CreatePolyhedron(name: string, options: {
  67143. type?: number;
  67144. size?: number;
  67145. sizeX?: number;
  67146. sizeY?: number;
  67147. sizeZ?: number;
  67148. custom?: any;
  67149. faceUV?: Vector4[];
  67150. faceColors?: Color4[];
  67151. flat?: boolean;
  67152. updatable?: boolean;
  67153. sideOrientation?: number;
  67154. frontUVs?: Vector4;
  67155. backUVs?: Vector4;
  67156. }, scene?: Nullable<Scene>): Mesh;
  67157. /**
  67158. * Creates a decal mesh.
  67159. * 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
  67160. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67161. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67162. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67163. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67164. * @param name defines the name of the mesh
  67165. * @param sourceMesh defines the mesh where the decal must be applied
  67166. * @param options defines the options used to create the mesh
  67167. * @param scene defines the hosting scene
  67168. * @returns the decal mesh
  67169. * @see https://doc.babylonjs.com/how_to/decals
  67170. */
  67171. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67172. position?: Vector3;
  67173. normal?: Vector3;
  67174. size?: Vector3;
  67175. angle?: number;
  67176. }): Mesh;
  67177. /**
  67178. * Creates a Capsule Mesh
  67179. * @param name defines the name of the mesh.
  67180. * @param options the constructors options used to shape the mesh.
  67181. * @param scene defines the scene the mesh is scoped to.
  67182. * @returns the capsule mesh
  67183. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67184. */
  67185. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67186. }
  67187. }
  67188. declare module BABYLON {
  67189. /**
  67190. * A simplifier interface for future simplification implementations
  67191. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67192. */
  67193. export interface ISimplifier {
  67194. /**
  67195. * Simplification of a given mesh according to the given settings.
  67196. * Since this requires computation, it is assumed that the function runs async.
  67197. * @param settings The settings of the simplification, including quality and distance
  67198. * @param successCallback A callback that will be called after the mesh was simplified.
  67199. * @param errorCallback in case of an error, this callback will be called. optional.
  67200. */
  67201. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67202. }
  67203. /**
  67204. * Expected simplification settings.
  67205. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67206. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67207. */
  67208. export interface ISimplificationSettings {
  67209. /**
  67210. * Gets or sets the expected quality
  67211. */
  67212. quality: number;
  67213. /**
  67214. * Gets or sets the distance when this optimized version should be used
  67215. */
  67216. distance: number;
  67217. /**
  67218. * Gets an already optimized mesh
  67219. */
  67220. optimizeMesh?: boolean;
  67221. }
  67222. /**
  67223. * Class used to specify simplification options
  67224. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67225. */
  67226. export class SimplificationSettings implements ISimplificationSettings {
  67227. /** expected quality */
  67228. quality: number;
  67229. /** distance when this optimized version should be used */
  67230. distance: number;
  67231. /** already optimized mesh */
  67232. optimizeMesh?: boolean | undefined;
  67233. /**
  67234. * Creates a SimplificationSettings
  67235. * @param quality expected quality
  67236. * @param distance distance when this optimized version should be used
  67237. * @param optimizeMesh already optimized mesh
  67238. */
  67239. constructor(
  67240. /** expected quality */
  67241. quality: number,
  67242. /** distance when this optimized version should be used */
  67243. distance: number,
  67244. /** already optimized mesh */
  67245. optimizeMesh?: boolean | undefined);
  67246. }
  67247. /**
  67248. * Interface used to define a simplification task
  67249. */
  67250. export interface ISimplificationTask {
  67251. /**
  67252. * Array of settings
  67253. */
  67254. settings: Array<ISimplificationSettings>;
  67255. /**
  67256. * Simplification type
  67257. */
  67258. simplificationType: SimplificationType;
  67259. /**
  67260. * Mesh to simplify
  67261. */
  67262. mesh: Mesh;
  67263. /**
  67264. * Callback called on success
  67265. */
  67266. successCallback?: () => void;
  67267. /**
  67268. * Defines if parallel processing can be used
  67269. */
  67270. parallelProcessing: boolean;
  67271. }
  67272. /**
  67273. * Queue used to order the simplification tasks
  67274. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67275. */
  67276. export class SimplificationQueue {
  67277. private _simplificationArray;
  67278. /**
  67279. * Gets a boolean indicating that the process is still running
  67280. */
  67281. running: boolean;
  67282. /**
  67283. * Creates a new queue
  67284. */
  67285. constructor();
  67286. /**
  67287. * Adds a new simplification task
  67288. * @param task defines a task to add
  67289. */
  67290. addTask(task: ISimplificationTask): void;
  67291. /**
  67292. * Execute next task
  67293. */
  67294. executeNext(): void;
  67295. /**
  67296. * Execute a simplification task
  67297. * @param task defines the task to run
  67298. */
  67299. runSimplification(task: ISimplificationTask): void;
  67300. private getSimplifier;
  67301. }
  67302. /**
  67303. * The implemented types of simplification
  67304. * At the moment only Quadratic Error Decimation is implemented
  67305. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67306. */
  67307. export enum SimplificationType {
  67308. /** Quadratic error decimation */
  67309. QUADRATIC = 0
  67310. }
  67311. /**
  67312. * An implementation of the Quadratic Error simplification algorithm.
  67313. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67314. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67315. * @author RaananW
  67316. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67317. */
  67318. export class QuadraticErrorSimplification implements ISimplifier {
  67319. private _mesh;
  67320. private triangles;
  67321. private vertices;
  67322. private references;
  67323. private _reconstructedMesh;
  67324. /** Gets or sets the number pf sync interations */
  67325. syncIterations: number;
  67326. /** Gets or sets the aggressiveness of the simplifier */
  67327. aggressiveness: number;
  67328. /** Gets or sets the number of allowed iterations for decimation */
  67329. decimationIterations: number;
  67330. /** Gets or sets the espilon to use for bounding box computation */
  67331. boundingBoxEpsilon: number;
  67332. /**
  67333. * Creates a new QuadraticErrorSimplification
  67334. * @param _mesh defines the target mesh
  67335. */
  67336. constructor(_mesh: Mesh);
  67337. /**
  67338. * Simplification of a given mesh according to the given settings.
  67339. * Since this requires computation, it is assumed that the function runs async.
  67340. * @param settings The settings of the simplification, including quality and distance
  67341. * @param successCallback A callback that will be called after the mesh was simplified.
  67342. */
  67343. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67344. private runDecimation;
  67345. private initWithMesh;
  67346. private init;
  67347. private reconstructMesh;
  67348. private initDecimatedMesh;
  67349. private isFlipped;
  67350. private updateTriangles;
  67351. private identifyBorder;
  67352. private updateMesh;
  67353. private vertexError;
  67354. private calculateError;
  67355. }
  67356. }
  67357. declare module BABYLON {
  67358. interface Scene {
  67359. /** @hidden (Backing field) */
  67360. _simplificationQueue: SimplificationQueue;
  67361. /**
  67362. * Gets or sets the simplification queue attached to the scene
  67363. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67364. */
  67365. simplificationQueue: SimplificationQueue;
  67366. }
  67367. interface Mesh {
  67368. /**
  67369. * Simplify the mesh according to the given array of settings.
  67370. * Function will return immediately and will simplify async
  67371. * @param settings a collection of simplification settings
  67372. * @param parallelProcessing should all levels calculate parallel or one after the other
  67373. * @param simplificationType the type of simplification to run
  67374. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67375. * @returns the current mesh
  67376. */
  67377. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67378. }
  67379. /**
  67380. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67381. * created in a scene
  67382. */
  67383. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67384. /**
  67385. * The component name helpfull to identify the component in the list of scene components.
  67386. */
  67387. readonly name: string;
  67388. /**
  67389. * The scene the component belongs to.
  67390. */
  67391. scene: Scene;
  67392. /**
  67393. * Creates a new instance of the component for the given scene
  67394. * @param scene Defines the scene to register the component in
  67395. */
  67396. constructor(scene: Scene);
  67397. /**
  67398. * Registers the component in a given scene
  67399. */
  67400. register(): void;
  67401. /**
  67402. * Rebuilds the elements related to this component in case of
  67403. * context lost for instance.
  67404. */
  67405. rebuild(): void;
  67406. /**
  67407. * Disposes the component and the associated ressources
  67408. */
  67409. dispose(): void;
  67410. private _beforeCameraUpdate;
  67411. }
  67412. }
  67413. declare module BABYLON {
  67414. interface Mesh {
  67415. /**
  67416. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67417. */
  67418. thinInstanceEnablePicking: boolean;
  67419. /**
  67420. * Creates a new thin instance
  67421. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67422. * @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
  67423. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67424. */
  67425. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67426. /**
  67427. * Adds the transformation (matrix) of the current mesh as a thin instance
  67428. * @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
  67429. * @returns the thin instance index number
  67430. */
  67431. thinInstanceAddSelf(refresh: boolean): number;
  67432. /**
  67433. * Registers a custom attribute to be used with thin instances
  67434. * @param kind name of the attribute
  67435. * @param stride size in floats of the attribute
  67436. */
  67437. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67438. /**
  67439. * Sets the matrix of a thin instance
  67440. * @param index index of the thin instance
  67441. * @param matrix matrix to set
  67442. * @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
  67443. */
  67444. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67445. /**
  67446. * Sets the value of a custom attribute for a thin instance
  67447. * @param kind name of the attribute
  67448. * @param index index of the thin instance
  67449. * @param value value to set
  67450. * @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
  67451. */
  67452. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67453. /**
  67454. * 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.
  67455. */
  67456. thinInstanceCount: number;
  67457. /**
  67458. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67459. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67460. * @param buffer buffer to set
  67461. * @param stride size in floats of each value of the buffer
  67462. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67463. */
  67464. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67465. /**
  67466. * Gets the list of world matrices
  67467. * @return an array containing all the world matrices from the thin instances
  67468. */
  67469. thinInstanceGetWorldMatrices(): Matrix[];
  67470. /**
  67471. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67472. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67473. */
  67474. thinInstanceBufferUpdated(kind: string): void;
  67475. /**
  67476. * Applies a partial update to a buffer directly on the GPU
  67477. * 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
  67478. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67479. * @param data the data to set in the GPU buffer
  67480. * @param offset the offset in the GPU buffer where to update the data
  67481. */
  67482. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67483. /**
  67484. * Refreshes the bounding info, taking into account all the thin instances defined
  67485. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67486. */
  67487. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67488. /** @hidden */
  67489. _thinInstanceInitializeUserStorage(): void;
  67490. /** @hidden */
  67491. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67492. /** @hidden */
  67493. _userThinInstanceBuffersStorage: {
  67494. data: {
  67495. [key: string]: Float32Array;
  67496. };
  67497. sizes: {
  67498. [key: string]: number;
  67499. };
  67500. vertexBuffers: {
  67501. [key: string]: Nullable<VertexBuffer>;
  67502. };
  67503. strides: {
  67504. [key: string]: number;
  67505. };
  67506. };
  67507. }
  67508. }
  67509. declare module BABYLON {
  67510. /**
  67511. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67512. */
  67513. export interface INavigationEnginePlugin {
  67514. /**
  67515. * plugin name
  67516. */
  67517. name: string;
  67518. /**
  67519. * Creates a navigation mesh
  67520. * @param meshes array of all the geometry used to compute the navigatio mesh
  67521. * @param parameters bunch of parameters used to filter geometry
  67522. */
  67523. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67524. /**
  67525. * Create a navigation mesh debug mesh
  67526. * @param scene is where the mesh will be added
  67527. * @returns debug display mesh
  67528. */
  67529. createDebugNavMesh(scene: Scene): Mesh;
  67530. /**
  67531. * Get a navigation mesh constrained position, closest to the parameter position
  67532. * @param position world position
  67533. * @returns the closest point to position constrained by the navigation mesh
  67534. */
  67535. getClosestPoint(position: Vector3): Vector3;
  67536. /**
  67537. * Get a navigation mesh constrained position, closest to the parameter position
  67538. * @param position world position
  67539. * @param result output the closest point to position constrained by the navigation mesh
  67540. */
  67541. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67542. /**
  67543. * Get a navigation mesh constrained position, within a particular radius
  67544. * @param position world position
  67545. * @param maxRadius the maximum distance to the constrained world position
  67546. * @returns the closest point to position constrained by the navigation mesh
  67547. */
  67548. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67549. /**
  67550. * Get a navigation mesh constrained position, within a particular radius
  67551. * @param position world position
  67552. * @param maxRadius the maximum distance to the constrained world position
  67553. * @param result output the closest point to position constrained by the navigation mesh
  67554. */
  67555. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67556. /**
  67557. * Compute the final position from a segment made of destination-position
  67558. * @param position world position
  67559. * @param destination world position
  67560. * @returns the resulting point along the navmesh
  67561. */
  67562. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67563. /**
  67564. * Compute the final position from a segment made of destination-position
  67565. * @param position world position
  67566. * @param destination world position
  67567. * @param result output the resulting point along the navmesh
  67568. */
  67569. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67570. /**
  67571. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67572. * @param start world position
  67573. * @param end world position
  67574. * @returns array containing world position composing the path
  67575. */
  67576. computePath(start: Vector3, end: Vector3): Vector3[];
  67577. /**
  67578. * If this plugin is supported
  67579. * @returns true if plugin is supported
  67580. */
  67581. isSupported(): boolean;
  67582. /**
  67583. * Create a new Crowd so you can add agents
  67584. * @param maxAgents the maximum agent count in the crowd
  67585. * @param maxAgentRadius the maximum radius an agent can have
  67586. * @param scene to attach the crowd to
  67587. * @returns the crowd you can add agents to
  67588. */
  67589. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67590. /**
  67591. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67592. * The queries will try to find a solution within those bounds
  67593. * default is (1,1,1)
  67594. * @param extent x,y,z value that define the extent around the queries point of reference
  67595. */
  67596. setDefaultQueryExtent(extent: Vector3): void;
  67597. /**
  67598. * Get the Bounding box extent specified by setDefaultQueryExtent
  67599. * @returns the box extent values
  67600. */
  67601. getDefaultQueryExtent(): Vector3;
  67602. /**
  67603. * build the navmesh from a previously saved state using getNavmeshData
  67604. * @param data the Uint8Array returned by getNavmeshData
  67605. */
  67606. buildFromNavmeshData(data: Uint8Array): void;
  67607. /**
  67608. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67609. * @returns data the Uint8Array that can be saved and reused
  67610. */
  67611. getNavmeshData(): Uint8Array;
  67612. /**
  67613. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67614. * @param result output the box extent values
  67615. */
  67616. getDefaultQueryExtentToRef(result: Vector3): void;
  67617. /**
  67618. * Release all resources
  67619. */
  67620. dispose(): void;
  67621. }
  67622. /**
  67623. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67624. */
  67625. export interface ICrowd {
  67626. /**
  67627. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67628. * You can attach anything to that node. The node position is updated in the scene update tick.
  67629. * @param pos world position that will be constrained by the navigation mesh
  67630. * @param parameters agent parameters
  67631. * @param transform hooked to the agent that will be update by the scene
  67632. * @returns agent index
  67633. */
  67634. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67635. /**
  67636. * Returns the agent position in world space
  67637. * @param index agent index returned by addAgent
  67638. * @returns world space position
  67639. */
  67640. getAgentPosition(index: number): Vector3;
  67641. /**
  67642. * Gets the agent position result in world space
  67643. * @param index agent index returned by addAgent
  67644. * @param result output world space position
  67645. */
  67646. getAgentPositionToRef(index: number, result: Vector3): void;
  67647. /**
  67648. * Gets the agent velocity in world space
  67649. * @param index agent index returned by addAgent
  67650. * @returns world space velocity
  67651. */
  67652. getAgentVelocity(index: number): Vector3;
  67653. /**
  67654. * Gets the agent velocity result in world space
  67655. * @param index agent index returned by addAgent
  67656. * @param result output world space velocity
  67657. */
  67658. getAgentVelocityToRef(index: number, result: Vector3): void;
  67659. /**
  67660. * remove a particular agent previously created
  67661. * @param index agent index returned by addAgent
  67662. */
  67663. removeAgent(index: number): void;
  67664. /**
  67665. * get the list of all agents attached to this crowd
  67666. * @returns list of agent indices
  67667. */
  67668. getAgents(): number[];
  67669. /**
  67670. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67671. * @param deltaTime in seconds
  67672. */
  67673. update(deltaTime: number): void;
  67674. /**
  67675. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67676. * @param index agent index returned by addAgent
  67677. * @param destination targeted world position
  67678. */
  67679. agentGoto(index: number, destination: Vector3): void;
  67680. /**
  67681. * Teleport the agent to a new position
  67682. * @param index agent index returned by addAgent
  67683. * @param destination targeted world position
  67684. */
  67685. agentTeleport(index: number, destination: Vector3): void;
  67686. /**
  67687. * Update agent parameters
  67688. * @param index agent index returned by addAgent
  67689. * @param parameters agent parameters
  67690. */
  67691. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67692. /**
  67693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67694. * The queries will try to find a solution within those bounds
  67695. * default is (1,1,1)
  67696. * @param extent x,y,z value that define the extent around the queries point of reference
  67697. */
  67698. setDefaultQueryExtent(extent: Vector3): void;
  67699. /**
  67700. * Get the Bounding box extent specified by setDefaultQueryExtent
  67701. * @returns the box extent values
  67702. */
  67703. getDefaultQueryExtent(): Vector3;
  67704. /**
  67705. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67706. * @param result output the box extent values
  67707. */
  67708. getDefaultQueryExtentToRef(result: Vector3): void;
  67709. /**
  67710. * Release all resources
  67711. */
  67712. dispose(): void;
  67713. }
  67714. /**
  67715. * Configures an agent
  67716. */
  67717. export interface IAgentParameters {
  67718. /**
  67719. * Agent radius. [Limit: >= 0]
  67720. */
  67721. radius: number;
  67722. /**
  67723. * Agent height. [Limit: > 0]
  67724. */
  67725. height: number;
  67726. /**
  67727. * Maximum allowed acceleration. [Limit: >= 0]
  67728. */
  67729. maxAcceleration: number;
  67730. /**
  67731. * Maximum allowed speed. [Limit: >= 0]
  67732. */
  67733. maxSpeed: number;
  67734. /**
  67735. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67736. */
  67737. collisionQueryRange: number;
  67738. /**
  67739. * The path visibility optimization range. [Limit: > 0]
  67740. */
  67741. pathOptimizationRange: number;
  67742. /**
  67743. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67744. */
  67745. separationWeight: number;
  67746. }
  67747. /**
  67748. * Configures the navigation mesh creation
  67749. */
  67750. export interface INavMeshParameters {
  67751. /**
  67752. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67753. */
  67754. cs: number;
  67755. /**
  67756. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67757. */
  67758. ch: number;
  67759. /**
  67760. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67761. */
  67762. walkableSlopeAngle: number;
  67763. /**
  67764. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67765. * be considered walkable. [Limit: >= 3] [Units: vx]
  67766. */
  67767. walkableHeight: number;
  67768. /**
  67769. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67770. */
  67771. walkableClimb: number;
  67772. /**
  67773. * The distance to erode/shrink the walkable area of the heightfield away from
  67774. * obstructions. [Limit: >=0] [Units: vx]
  67775. */
  67776. walkableRadius: number;
  67777. /**
  67778. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67779. */
  67780. maxEdgeLen: number;
  67781. /**
  67782. * The maximum distance a simplfied contour's border edges should deviate
  67783. * the original raw contour. [Limit: >=0] [Units: vx]
  67784. */
  67785. maxSimplificationError: number;
  67786. /**
  67787. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67788. */
  67789. minRegionArea: number;
  67790. /**
  67791. * Any regions with a span count smaller than this value will, if possible,
  67792. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67793. */
  67794. mergeRegionArea: number;
  67795. /**
  67796. * The maximum number of vertices allowed for polygons generated during the
  67797. * contour to polygon conversion process. [Limit: >= 3]
  67798. */
  67799. maxVertsPerPoly: number;
  67800. /**
  67801. * Sets the sampling distance to use when generating the detail mesh.
  67802. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67803. */
  67804. detailSampleDist: number;
  67805. /**
  67806. * The maximum distance the detail mesh surface should deviate from heightfield
  67807. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67808. */
  67809. detailSampleMaxError: number;
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * RecastJS navigation plugin
  67815. */
  67816. export class RecastJSPlugin implements INavigationEnginePlugin {
  67817. /**
  67818. * Reference to the Recast library
  67819. */
  67820. bjsRECAST: any;
  67821. /**
  67822. * plugin name
  67823. */
  67824. name: string;
  67825. /**
  67826. * the first navmesh created. We might extend this to support multiple navmeshes
  67827. */
  67828. navMesh: any;
  67829. /**
  67830. * Initializes the recastJS plugin
  67831. * @param recastInjection can be used to inject your own recast reference
  67832. */
  67833. constructor(recastInjection?: any);
  67834. /**
  67835. * Creates a navigation mesh
  67836. * @param meshes array of all the geometry used to compute the navigatio mesh
  67837. * @param parameters bunch of parameters used to filter geometry
  67838. */
  67839. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67840. /**
  67841. * Create a navigation mesh debug mesh
  67842. * @param scene is where the mesh will be added
  67843. * @returns debug display mesh
  67844. */
  67845. createDebugNavMesh(scene: Scene): Mesh;
  67846. /**
  67847. * Get a navigation mesh constrained position, closest to the parameter position
  67848. * @param position world position
  67849. * @returns the closest point to position constrained by the navigation mesh
  67850. */
  67851. getClosestPoint(position: Vector3): Vector3;
  67852. /**
  67853. * Get a navigation mesh constrained position, closest to the parameter position
  67854. * @param position world position
  67855. * @param result output the closest point to position constrained by the navigation mesh
  67856. */
  67857. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67858. /**
  67859. * Get a navigation mesh constrained position, within a particular radius
  67860. * @param position world position
  67861. * @param maxRadius the maximum distance to the constrained world position
  67862. * @returns the closest point to position constrained by the navigation mesh
  67863. */
  67864. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67865. /**
  67866. * Get a navigation mesh constrained position, within a particular radius
  67867. * @param position world position
  67868. * @param maxRadius the maximum distance to the constrained world position
  67869. * @param result output the closest point to position constrained by the navigation mesh
  67870. */
  67871. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67872. /**
  67873. * Compute the final position from a segment made of destination-position
  67874. * @param position world position
  67875. * @param destination world position
  67876. * @returns the resulting point along the navmesh
  67877. */
  67878. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67879. /**
  67880. * Compute the final position from a segment made of destination-position
  67881. * @param position world position
  67882. * @param destination world position
  67883. * @param result output the resulting point along the navmesh
  67884. */
  67885. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67886. /**
  67887. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67888. * @param start world position
  67889. * @param end world position
  67890. * @returns array containing world position composing the path
  67891. */
  67892. computePath(start: Vector3, end: Vector3): Vector3[];
  67893. /**
  67894. * Create a new Crowd so you can add agents
  67895. * @param maxAgents the maximum agent count in the crowd
  67896. * @param maxAgentRadius the maximum radius an agent can have
  67897. * @param scene to attach the crowd to
  67898. * @returns the crowd you can add agents to
  67899. */
  67900. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67901. /**
  67902. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67903. * The queries will try to find a solution within those bounds
  67904. * default is (1,1,1)
  67905. * @param extent x,y,z value that define the extent around the queries point of reference
  67906. */
  67907. setDefaultQueryExtent(extent: Vector3): void;
  67908. /**
  67909. * Get the Bounding box extent specified by setDefaultQueryExtent
  67910. * @returns the box extent values
  67911. */
  67912. getDefaultQueryExtent(): Vector3;
  67913. /**
  67914. * build the navmesh from a previously saved state using getNavmeshData
  67915. * @param data the Uint8Array returned by getNavmeshData
  67916. */
  67917. buildFromNavmeshData(data: Uint8Array): void;
  67918. /**
  67919. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67920. * @returns data the Uint8Array that can be saved and reused
  67921. */
  67922. getNavmeshData(): Uint8Array;
  67923. /**
  67924. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67925. * @param result output the box extent values
  67926. */
  67927. getDefaultQueryExtentToRef(result: Vector3): void;
  67928. /**
  67929. * Disposes
  67930. */
  67931. dispose(): void;
  67932. /**
  67933. * If this plugin is supported
  67934. * @returns true if plugin is supported
  67935. */
  67936. isSupported(): boolean;
  67937. }
  67938. /**
  67939. * Recast detour crowd implementation
  67940. */
  67941. export class RecastJSCrowd implements ICrowd {
  67942. /**
  67943. * Recast/detour plugin
  67944. */
  67945. bjsRECASTPlugin: RecastJSPlugin;
  67946. /**
  67947. * Link to the detour crowd
  67948. */
  67949. recastCrowd: any;
  67950. /**
  67951. * One transform per agent
  67952. */
  67953. transforms: TransformNode[];
  67954. /**
  67955. * All agents created
  67956. */
  67957. agents: number[];
  67958. /**
  67959. * Link to the scene is kept to unregister the crowd from the scene
  67960. */
  67961. private _scene;
  67962. /**
  67963. * Observer for crowd updates
  67964. */
  67965. private _onBeforeAnimationsObserver;
  67966. /**
  67967. * Constructor
  67968. * @param plugin recastJS plugin
  67969. * @param maxAgents the maximum agent count in the crowd
  67970. * @param maxAgentRadius the maximum radius an agent can have
  67971. * @param scene to attach the crowd to
  67972. * @returns the crowd you can add agents to
  67973. */
  67974. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67975. /**
  67976. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67977. * You can attach anything to that node. The node position is updated in the scene update tick.
  67978. * @param pos world position that will be constrained by the navigation mesh
  67979. * @param parameters agent parameters
  67980. * @param transform hooked to the agent that will be update by the scene
  67981. * @returns agent index
  67982. */
  67983. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67984. /**
  67985. * Returns the agent position in world space
  67986. * @param index agent index returned by addAgent
  67987. * @returns world space position
  67988. */
  67989. getAgentPosition(index: number): Vector3;
  67990. /**
  67991. * Returns the agent position result in world space
  67992. * @param index agent index returned by addAgent
  67993. * @param result output world space position
  67994. */
  67995. getAgentPositionToRef(index: number, result: Vector3): void;
  67996. /**
  67997. * Returns the agent velocity in world space
  67998. * @param index agent index returned by addAgent
  67999. * @returns world space velocity
  68000. */
  68001. getAgentVelocity(index: number): Vector3;
  68002. /**
  68003. * Returns the agent velocity result in world space
  68004. * @param index agent index returned by addAgent
  68005. * @param result output world space velocity
  68006. */
  68007. getAgentVelocityToRef(index: number, result: Vector3): void;
  68008. /**
  68009. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68010. * @param index agent index returned by addAgent
  68011. * @param destination targeted world position
  68012. */
  68013. agentGoto(index: number, destination: Vector3): void;
  68014. /**
  68015. * Teleport the agent to a new position
  68016. * @param index agent index returned by addAgent
  68017. * @param destination targeted world position
  68018. */
  68019. agentTeleport(index: number, destination: Vector3): void;
  68020. /**
  68021. * Update agent parameters
  68022. * @param index agent index returned by addAgent
  68023. * @param parameters agent parameters
  68024. */
  68025. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68026. /**
  68027. * remove a particular agent previously created
  68028. * @param index agent index returned by addAgent
  68029. */
  68030. removeAgent(index: number): void;
  68031. /**
  68032. * get the list of all agents attached to this crowd
  68033. * @returns list of agent indices
  68034. */
  68035. getAgents(): number[];
  68036. /**
  68037. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68038. * @param deltaTime in seconds
  68039. */
  68040. update(deltaTime: number): void;
  68041. /**
  68042. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68043. * The queries will try to find a solution within those bounds
  68044. * default is (1,1,1)
  68045. * @param extent x,y,z value that define the extent around the queries point of reference
  68046. */
  68047. setDefaultQueryExtent(extent: Vector3): void;
  68048. /**
  68049. * Get the Bounding box extent specified by setDefaultQueryExtent
  68050. * @returns the box extent values
  68051. */
  68052. getDefaultQueryExtent(): Vector3;
  68053. /**
  68054. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68055. * @param result output the box extent values
  68056. */
  68057. getDefaultQueryExtentToRef(result: Vector3): void;
  68058. /**
  68059. * Release all resources
  68060. */
  68061. dispose(): void;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * Class used to enable access to IndexedDB
  68067. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68068. */
  68069. export class Database implements IOfflineProvider {
  68070. private _callbackManifestChecked;
  68071. private _currentSceneUrl;
  68072. private _db;
  68073. private _enableSceneOffline;
  68074. private _enableTexturesOffline;
  68075. private _manifestVersionFound;
  68076. private _mustUpdateRessources;
  68077. private _hasReachedQuota;
  68078. private _isSupported;
  68079. private _idbFactory;
  68080. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68081. private static IsUASupportingBlobStorage;
  68082. /**
  68083. * Gets a boolean indicating if Database storate is enabled (off by default)
  68084. */
  68085. static IDBStorageEnabled: boolean;
  68086. /**
  68087. * Gets a boolean indicating if scene must be saved in the database
  68088. */
  68089. get enableSceneOffline(): boolean;
  68090. /**
  68091. * Gets a boolean indicating if textures must be saved in the database
  68092. */
  68093. get enableTexturesOffline(): boolean;
  68094. /**
  68095. * Creates a new Database
  68096. * @param urlToScene defines the url to load the scene
  68097. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68098. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68099. */
  68100. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68101. private static _ParseURL;
  68102. private static _ReturnFullUrlLocation;
  68103. private _checkManifestFile;
  68104. /**
  68105. * Open the database and make it available
  68106. * @param successCallback defines the callback to call on success
  68107. * @param errorCallback defines the callback to call on error
  68108. */
  68109. open(successCallback: () => void, errorCallback: () => void): void;
  68110. /**
  68111. * Loads an image from the database
  68112. * @param url defines the url to load from
  68113. * @param image defines the target DOM image
  68114. */
  68115. loadImage(url: string, image: HTMLImageElement): void;
  68116. private _loadImageFromDBAsync;
  68117. private _saveImageIntoDBAsync;
  68118. private _checkVersionFromDB;
  68119. private _loadVersionFromDBAsync;
  68120. private _saveVersionIntoDBAsync;
  68121. /**
  68122. * Loads a file from database
  68123. * @param url defines the URL to load from
  68124. * @param sceneLoaded defines a callback to call on success
  68125. * @param progressCallBack defines a callback to call when progress changed
  68126. * @param errorCallback defines a callback to call on error
  68127. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68128. */
  68129. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68130. private _loadFileAsync;
  68131. private _saveFileAsync;
  68132. /**
  68133. * Validates if xhr data is correct
  68134. * @param xhr defines the request to validate
  68135. * @param dataType defines the expected data type
  68136. * @returns true if data is correct
  68137. */
  68138. private static _ValidateXHRData;
  68139. }
  68140. }
  68141. declare module BABYLON {
  68142. /** @hidden */
  68143. export var gpuUpdateParticlesPixelShader: {
  68144. name: string;
  68145. shader: string;
  68146. };
  68147. }
  68148. declare module BABYLON {
  68149. /** @hidden */
  68150. export var gpuUpdateParticlesVertexShader: {
  68151. name: string;
  68152. shader: string;
  68153. };
  68154. }
  68155. declare module BABYLON {
  68156. /** @hidden */
  68157. export var clipPlaneFragmentDeclaration2: {
  68158. name: string;
  68159. shader: string;
  68160. };
  68161. }
  68162. declare module BABYLON {
  68163. /** @hidden */
  68164. export var gpuRenderParticlesPixelShader: {
  68165. name: string;
  68166. shader: string;
  68167. };
  68168. }
  68169. declare module BABYLON {
  68170. /** @hidden */
  68171. export var clipPlaneVertexDeclaration2: {
  68172. name: string;
  68173. shader: string;
  68174. };
  68175. }
  68176. declare module BABYLON {
  68177. /** @hidden */
  68178. export var gpuRenderParticlesVertexShader: {
  68179. name: string;
  68180. shader: string;
  68181. };
  68182. }
  68183. declare module BABYLON {
  68184. /**
  68185. * This represents a GPU particle system in Babylon
  68186. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68187. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68188. */
  68189. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68190. /**
  68191. * The layer mask we are rendering the particles through.
  68192. */
  68193. layerMask: number;
  68194. private _capacity;
  68195. private _activeCount;
  68196. private _currentActiveCount;
  68197. private _accumulatedCount;
  68198. private _renderEffect;
  68199. private _updateEffect;
  68200. private _buffer0;
  68201. private _buffer1;
  68202. private _spriteBuffer;
  68203. private _updateVAO;
  68204. private _renderVAO;
  68205. private _targetIndex;
  68206. private _sourceBuffer;
  68207. private _targetBuffer;
  68208. private _currentRenderId;
  68209. private _started;
  68210. private _stopped;
  68211. private _timeDelta;
  68212. private _randomTexture;
  68213. private _randomTexture2;
  68214. private _attributesStrideSize;
  68215. private _updateEffectOptions;
  68216. private _randomTextureSize;
  68217. private _actualFrame;
  68218. private _customEffect;
  68219. private readonly _rawTextureWidth;
  68220. /**
  68221. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68222. */
  68223. static get IsSupported(): boolean;
  68224. /**
  68225. * An event triggered when the system is disposed.
  68226. */
  68227. onDisposeObservable: Observable<IParticleSystem>;
  68228. /**
  68229. * An event triggered when the system is stopped
  68230. */
  68231. onStoppedObservable: Observable<IParticleSystem>;
  68232. /**
  68233. * Gets the maximum number of particles active at the same time.
  68234. * @returns The max number of active particles.
  68235. */
  68236. getCapacity(): number;
  68237. /**
  68238. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68239. * to override the particles.
  68240. */
  68241. forceDepthWrite: boolean;
  68242. /**
  68243. * Gets or set the number of active particles
  68244. */
  68245. get activeParticleCount(): number;
  68246. set activeParticleCount(value: number);
  68247. private _preWarmDone;
  68248. /**
  68249. * Specifies if the particles are updated in emitter local space or world space.
  68250. */
  68251. isLocal: boolean;
  68252. /** Gets or sets a matrix to use to compute projection */
  68253. defaultProjectionMatrix: Matrix;
  68254. /**
  68255. * Is this system ready to be used/rendered
  68256. * @return true if the system is ready
  68257. */
  68258. isReady(): boolean;
  68259. /**
  68260. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68261. * @returns True if it has been started, otherwise false.
  68262. */
  68263. isStarted(): boolean;
  68264. /**
  68265. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68266. * @returns True if it has been stopped, otherwise false.
  68267. */
  68268. isStopped(): boolean;
  68269. /**
  68270. * Gets a boolean indicating that the system is stopping
  68271. * @returns true if the system is currently stopping
  68272. */
  68273. isStopping(): boolean;
  68274. /**
  68275. * Gets the number of particles active at the same time.
  68276. * @returns The number of active particles.
  68277. */
  68278. getActiveCount(): number;
  68279. /**
  68280. * Starts the particle system and begins to emit
  68281. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68282. */
  68283. start(delay?: number): void;
  68284. /**
  68285. * Stops the particle system.
  68286. */
  68287. stop(): void;
  68288. /**
  68289. * Remove all active particles
  68290. */
  68291. reset(): void;
  68292. /**
  68293. * Returns the string "GPUParticleSystem"
  68294. * @returns a string containing the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the custom effect used to render the particles
  68299. * @param blendMode Blend mode for which the effect should be retrieved
  68300. * @returns The effect
  68301. */
  68302. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68303. /**
  68304. * Sets the custom effect used to render the particles
  68305. * @param effect The effect to set
  68306. * @param blendMode Blend mode for which the effect should be set
  68307. */
  68308. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68309. /** @hidden */
  68310. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68311. /**
  68312. * Observable that will be called just before the particles are drawn
  68313. */
  68314. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68315. /**
  68316. * Gets the name of the particle vertex shader
  68317. */
  68318. get vertexShaderName(): string;
  68319. private _colorGradientsTexture;
  68320. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68321. /**
  68322. * Adds a new color gradient
  68323. * @param gradient defines the gradient to use (between 0 and 1)
  68324. * @param color1 defines the color to affect to the specified gradient
  68325. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68326. * @returns the current particle system
  68327. */
  68328. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68329. private _refreshColorGradient;
  68330. /** Force the system to rebuild all gradients that need to be resync */
  68331. forceRefreshGradients(): void;
  68332. /**
  68333. * Remove a specific color gradient
  68334. * @param gradient defines the gradient to remove
  68335. * @returns the current particle system
  68336. */
  68337. removeColorGradient(gradient: number): GPUParticleSystem;
  68338. private _angularSpeedGradientsTexture;
  68339. private _sizeGradientsTexture;
  68340. private _velocityGradientsTexture;
  68341. private _limitVelocityGradientsTexture;
  68342. private _dragGradientsTexture;
  68343. private _addFactorGradient;
  68344. /**
  68345. * Adds a new size gradient
  68346. * @param gradient defines the gradient to use (between 0 and 1)
  68347. * @param factor defines the size factor to affect to the specified gradient
  68348. * @returns the current particle system
  68349. */
  68350. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68351. /**
  68352. * Remove a specific size gradient
  68353. * @param gradient defines the gradient to remove
  68354. * @returns the current particle system
  68355. */
  68356. removeSizeGradient(gradient: number): GPUParticleSystem;
  68357. private _refreshFactorGradient;
  68358. /**
  68359. * Adds a new angular speed gradient
  68360. * @param gradient defines the gradient to use (between 0 and 1)
  68361. * @param factor defines the angular speed to affect to the specified gradient
  68362. * @returns the current particle system
  68363. */
  68364. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68365. /**
  68366. * Remove a specific angular speed gradient
  68367. * @param gradient defines the gradient to remove
  68368. * @returns the current particle system
  68369. */
  68370. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68371. /**
  68372. * Adds a new velocity gradient
  68373. * @param gradient defines the gradient to use (between 0 and 1)
  68374. * @param factor defines the velocity to affect to the specified gradient
  68375. * @returns the current particle system
  68376. */
  68377. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68378. /**
  68379. * Remove a specific velocity gradient
  68380. * @param gradient defines the gradient to remove
  68381. * @returns the current particle system
  68382. */
  68383. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68384. /**
  68385. * Adds a new limit velocity gradient
  68386. * @param gradient defines the gradient to use (between 0 and 1)
  68387. * @param factor defines the limit velocity value to affect to the specified gradient
  68388. * @returns the current particle system
  68389. */
  68390. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68391. /**
  68392. * Remove a specific limit velocity gradient
  68393. * @param gradient defines the gradient to remove
  68394. * @returns the current particle system
  68395. */
  68396. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68397. /**
  68398. * Adds a new drag gradient
  68399. * @param gradient defines the gradient to use (between 0 and 1)
  68400. * @param factor defines the drag value to affect to the specified gradient
  68401. * @returns the current particle system
  68402. */
  68403. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68404. /**
  68405. * Remove a specific drag gradient
  68406. * @param gradient defines the gradient to remove
  68407. * @returns the current particle system
  68408. */
  68409. removeDragGradient(gradient: number): GPUParticleSystem;
  68410. /**
  68411. * Not supported by GPUParticleSystem
  68412. * @param gradient defines the gradient to use (between 0 and 1)
  68413. * @param factor defines the emit rate value to affect to the specified gradient
  68414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68415. * @returns the current particle system
  68416. */
  68417. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68418. /**
  68419. * Not supported by GPUParticleSystem
  68420. * @param gradient defines the gradient to remove
  68421. * @returns the current particle system
  68422. */
  68423. removeEmitRateGradient(gradient: number): IParticleSystem;
  68424. /**
  68425. * Not supported by GPUParticleSystem
  68426. * @param gradient defines the gradient to use (between 0 and 1)
  68427. * @param factor defines the start size value to affect to the specified gradient
  68428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68429. * @returns the current particle system
  68430. */
  68431. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68432. /**
  68433. * Not supported by GPUParticleSystem
  68434. * @param gradient defines the gradient to remove
  68435. * @returns the current particle system
  68436. */
  68437. removeStartSizeGradient(gradient: number): IParticleSystem;
  68438. /**
  68439. * Not supported by GPUParticleSystem
  68440. * @param gradient defines the gradient to use (between 0 and 1)
  68441. * @param min defines the color remap minimal range
  68442. * @param max defines the color remap maximal range
  68443. * @returns the current particle system
  68444. */
  68445. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68446. /**
  68447. * Not supported by GPUParticleSystem
  68448. * @param gradient defines the gradient to remove
  68449. * @returns the current particle system
  68450. */
  68451. removeColorRemapGradient(): IParticleSystem;
  68452. /**
  68453. * Not supported by GPUParticleSystem
  68454. * @param gradient defines the gradient to use (between 0 and 1)
  68455. * @param min defines the alpha remap minimal range
  68456. * @param max defines the alpha remap maximal range
  68457. * @returns the current particle system
  68458. */
  68459. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68460. /**
  68461. * Not supported by GPUParticleSystem
  68462. * @param gradient defines the gradient to remove
  68463. * @returns the current particle system
  68464. */
  68465. removeAlphaRemapGradient(): IParticleSystem;
  68466. /**
  68467. * Not supported by GPUParticleSystem
  68468. * @param gradient defines the gradient to use (between 0 and 1)
  68469. * @param color defines the color to affect to the specified gradient
  68470. * @returns the current particle system
  68471. */
  68472. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68473. /**
  68474. * Not supported by GPUParticleSystem
  68475. * @param gradient defines the gradient to remove
  68476. * @returns the current particle system
  68477. */
  68478. removeRampGradient(): IParticleSystem;
  68479. /**
  68480. * Not supported by GPUParticleSystem
  68481. * @returns the list of ramp gradients
  68482. */
  68483. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68484. /**
  68485. * Not supported by GPUParticleSystem
  68486. * Gets or sets a boolean indicating that ramp gradients must be used
  68487. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68488. */
  68489. get useRampGradients(): boolean;
  68490. set useRampGradients(value: boolean);
  68491. /**
  68492. * Not supported by GPUParticleSystem
  68493. * @param gradient defines the gradient to use (between 0 and 1)
  68494. * @param factor defines the life time factor to affect to the specified gradient
  68495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68496. * @returns the current particle system
  68497. */
  68498. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68499. /**
  68500. * Not supported by GPUParticleSystem
  68501. * @param gradient defines the gradient to remove
  68502. * @returns the current particle system
  68503. */
  68504. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68505. /**
  68506. * Instantiates a GPU particle system.
  68507. * 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.
  68508. * @param name The name of the particle system
  68509. * @param options The options used to create the system
  68510. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68511. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68512. * @param customEffect a custom effect used to change the way particles are rendered by default
  68513. */
  68514. constructor(name: string, options: Partial<{
  68515. capacity: number;
  68516. randomTextureSize: number;
  68517. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68518. protected _reset(): void;
  68519. private _createUpdateVAO;
  68520. private _createRenderVAO;
  68521. private _initialize;
  68522. /** @hidden */
  68523. _recreateUpdateEffect(): void;
  68524. private _getEffect;
  68525. /**
  68526. * Fill the defines array according to the current settings of the particle system
  68527. * @param defines Array to be updated
  68528. * @param blendMode blend mode to take into account when updating the array
  68529. */
  68530. fillDefines(defines: Array<string>, blendMode?: number): void;
  68531. /**
  68532. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68533. * @param uniforms Uniforms array to fill
  68534. * @param attributes Attributes array to fill
  68535. * @param samplers Samplers array to fill
  68536. */
  68537. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68538. /** @hidden */
  68539. _recreateRenderEffect(): Effect;
  68540. /**
  68541. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68542. * @param preWarm defines if we are in the pre-warmimg phase
  68543. */
  68544. animate(preWarm?: boolean): void;
  68545. private _createFactorGradientTexture;
  68546. private _createSizeGradientTexture;
  68547. private _createAngularSpeedGradientTexture;
  68548. private _createVelocityGradientTexture;
  68549. private _createLimitVelocityGradientTexture;
  68550. private _createDragGradientTexture;
  68551. private _createColorGradientTexture;
  68552. /**
  68553. * Renders the particle system in its current state
  68554. * @param preWarm defines if the system should only update the particles but not render them
  68555. * @returns the current number of particles
  68556. */
  68557. render(preWarm?: boolean): number;
  68558. /**
  68559. * Rebuilds the particle system
  68560. */
  68561. rebuild(): void;
  68562. private _releaseBuffers;
  68563. private _releaseVAOs;
  68564. /**
  68565. * Disposes the particle system and free the associated resources
  68566. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68567. */
  68568. dispose(disposeTexture?: boolean): void;
  68569. /**
  68570. * Clones the particle system.
  68571. * @param name The name of the cloned object
  68572. * @param newEmitter The new emitter to use
  68573. * @returns the cloned particle system
  68574. */
  68575. clone(name: string, newEmitter: any): GPUParticleSystem;
  68576. /**
  68577. * Serializes the particle system to a JSON object
  68578. * @param serializeTexture defines if the texture must be serialized as well
  68579. * @returns the JSON object
  68580. */
  68581. serialize(serializeTexture?: boolean): any;
  68582. /**
  68583. * Parses a JSON object to create a GPU particle system.
  68584. * @param parsedParticleSystem The JSON object to parse
  68585. * @param sceneOrEngine The scene or the engine to create the particle system in
  68586. * @param rootUrl The root url to use to load external dependencies like texture
  68587. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68588. * @returns the parsed GPU particle system
  68589. */
  68590. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * Represents a set of particle systems working together to create a specific effect
  68596. */
  68597. export class ParticleSystemSet implements IDisposable {
  68598. /**
  68599. * Gets or sets base Assets URL
  68600. */
  68601. static BaseAssetsUrl: string;
  68602. private _emitterCreationOptions;
  68603. private _emitterNode;
  68604. /**
  68605. * Gets the particle system list
  68606. */
  68607. systems: IParticleSystem[];
  68608. /**
  68609. * Gets the emitter node used with this set
  68610. */
  68611. get emitterNode(): Nullable<TransformNode>;
  68612. /**
  68613. * Creates a new emitter mesh as a sphere
  68614. * @param options defines the options used to create the sphere
  68615. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68616. * @param scene defines the hosting scene
  68617. */
  68618. setEmitterAsSphere(options: {
  68619. diameter: number;
  68620. segments: number;
  68621. color: Color3;
  68622. }, renderingGroupId: number, scene: Scene): void;
  68623. /**
  68624. * Starts all particle systems of the set
  68625. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68626. */
  68627. start(emitter?: AbstractMesh): void;
  68628. /**
  68629. * Release all associated resources
  68630. */
  68631. dispose(): void;
  68632. /**
  68633. * Serialize the set into a JSON compatible object
  68634. * @param serializeTexture defines if the texture must be serialized as well
  68635. * @returns a JSON compatible representation of the set
  68636. */
  68637. serialize(serializeTexture?: boolean): any;
  68638. /**
  68639. * Parse a new ParticleSystemSet from a serialized source
  68640. * @param data defines a JSON compatible representation of the set
  68641. * @param scene defines the hosting scene
  68642. * @param gpu defines if we want GPU particles or CPU particles
  68643. * @returns a new ParticleSystemSet
  68644. */
  68645. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68646. }
  68647. }
  68648. declare module BABYLON {
  68649. /**
  68650. * This class is made for on one-liner static method to help creating particle system set.
  68651. */
  68652. export class ParticleHelper {
  68653. /**
  68654. * Gets or sets base Assets URL
  68655. */
  68656. static BaseAssetsUrl: string;
  68657. /** Define the Url to load snippets */
  68658. static SnippetUrl: string;
  68659. /**
  68660. * Create a default particle system that you can tweak
  68661. * @param emitter defines the emitter to use
  68662. * @param capacity defines the system capacity (default is 500 particles)
  68663. * @param scene defines the hosting scene
  68664. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68665. * @returns the new Particle system
  68666. */
  68667. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68668. /**
  68669. * This is the main static method (one-liner) of this helper to create different particle systems
  68670. * @param type This string represents the type to the particle system to create
  68671. * @param scene The scene where the particle system should live
  68672. * @param gpu If the system will use gpu
  68673. * @returns the ParticleSystemSet created
  68674. */
  68675. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68676. /**
  68677. * Static function used to export a particle system to a ParticleSystemSet variable.
  68678. * Please note that the emitter shape is not exported
  68679. * @param systems defines the particle systems to export
  68680. * @returns the created particle system set
  68681. */
  68682. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68683. /**
  68684. * Creates a particle system from a snippet saved in a remote file
  68685. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68686. * @param url defines the url to load from
  68687. * @param scene defines the hosting scene
  68688. * @param gpu If the system will use gpu
  68689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68690. * @returns a promise that will resolve to the new particle system
  68691. */
  68692. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68693. /**
  68694. * Creates a particle system from a snippet saved by the particle system editor
  68695. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68696. * @param scene defines the hosting scene
  68697. * @param gpu If the system will use gpu
  68698. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68699. * @returns a promise that will resolve to the new particle system
  68700. */
  68701. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68702. }
  68703. }
  68704. declare module BABYLON {
  68705. interface Engine {
  68706. /**
  68707. * Create an effect to use with particle systems.
  68708. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68709. * the particle system for which you want to create a custom effect in the last parameter
  68710. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68711. * @param uniformsNames defines a list of attribute names
  68712. * @param samplers defines an array of string used to represent textures
  68713. * @param defines defines the string containing the defines to use to compile the shaders
  68714. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68715. * @param onCompiled defines a function to call when the effect creation is successful
  68716. * @param onError defines a function to call when the effect creation has failed
  68717. * @param particleSystem the particle system you want to create the effect for
  68718. * @returns the new Effect
  68719. */
  68720. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68721. }
  68722. interface Mesh {
  68723. /**
  68724. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68725. * @returns an array of IParticleSystem
  68726. */
  68727. getEmittedParticleSystems(): IParticleSystem[];
  68728. /**
  68729. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68730. * @returns an array of IParticleSystem
  68731. */
  68732. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68733. }
  68734. }
  68735. declare module BABYLON {
  68736. /** Defines the 4 color options */
  68737. export enum PointColor {
  68738. /** color value */
  68739. Color = 2,
  68740. /** uv value */
  68741. UV = 1,
  68742. /** random value */
  68743. Random = 0,
  68744. /** stated value */
  68745. Stated = 3
  68746. }
  68747. /**
  68748. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68749. * 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.
  68750. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68751. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68752. *
  68753. * Full documentation here : TO BE ENTERED
  68754. */
  68755. export class PointsCloudSystem implements IDisposable {
  68756. /**
  68757. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68758. * Example : var p = SPS.particles[i];
  68759. */
  68760. particles: CloudPoint[];
  68761. /**
  68762. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68763. */
  68764. nbParticles: number;
  68765. /**
  68766. * This a counter for your own usage. It's not set by any SPS functions.
  68767. */
  68768. counter: number;
  68769. /**
  68770. * The PCS name. This name is also given to the underlying mesh.
  68771. */
  68772. name: string;
  68773. /**
  68774. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68775. */
  68776. mesh: Mesh;
  68777. /**
  68778. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68779. * Please read :
  68780. */
  68781. vars: any;
  68782. /**
  68783. * @hidden
  68784. */
  68785. _size: number;
  68786. private _scene;
  68787. private _promises;
  68788. private _positions;
  68789. private _indices;
  68790. private _normals;
  68791. private _colors;
  68792. private _uvs;
  68793. private _indices32;
  68794. private _positions32;
  68795. private _colors32;
  68796. private _uvs32;
  68797. private _updatable;
  68798. private _isVisibilityBoxLocked;
  68799. private _alwaysVisible;
  68800. private _groups;
  68801. private _groupCounter;
  68802. private _computeParticleColor;
  68803. private _computeParticleTexture;
  68804. private _computeParticleRotation;
  68805. private _computeBoundingBox;
  68806. private _isReady;
  68807. /**
  68808. * Creates a PCS (Points Cloud System) object
  68809. * @param name (String) is the PCS name, this will be the underlying mesh name
  68810. * @param pointSize (number) is the size for each point
  68811. * @param scene (Scene) is the scene in which the PCS is added
  68812. * @param options defines the options of the PCS e.g.
  68813. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68814. */
  68815. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68816. updatable?: boolean;
  68817. });
  68818. /**
  68819. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68820. * If no points were added to the PCS, the returned mesh is just a single point.
  68821. * @returns a promise for the created mesh
  68822. */
  68823. buildMeshAsync(): Promise<Mesh>;
  68824. /**
  68825. * @hidden
  68826. */
  68827. private _buildMesh;
  68828. private _addParticle;
  68829. private _randomUnitVector;
  68830. private _getColorIndicesForCoord;
  68831. private _setPointsColorOrUV;
  68832. private _colorFromTexture;
  68833. private _calculateDensity;
  68834. /**
  68835. * Adds points to the PCS in random positions within a unit sphere
  68836. * @param nb (positive integer) the number of particles to be created from this model
  68837. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68838. * @returns the number of groups in the system
  68839. */
  68840. addPoints(nb: number, pointFunction?: any): number;
  68841. /**
  68842. * Adds points to the PCS from the surface of the model shape
  68843. * @param mesh is any Mesh object that will be used as a surface model for the points
  68844. * @param nb (positive integer) the number of particles to be created from this model
  68845. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68846. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68847. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68848. * @returns the number of groups in the system
  68849. */
  68850. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68851. /**
  68852. * Adds points to the PCS inside the model shape
  68853. * @param mesh is any Mesh object that will be used as a surface model for the points
  68854. * @param nb (positive integer) the number of particles to be created from this model
  68855. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68856. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68857. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68858. * @returns the number of groups in the system
  68859. */
  68860. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68861. /**
  68862. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68863. * This method calls `updateParticle()` for each particle of the SPS.
  68864. * For an animated SPS, it is usually called within the render loop.
  68865. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68866. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68867. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68868. * @returns the PCS.
  68869. */
  68870. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68871. /**
  68872. * Disposes the PCS.
  68873. */
  68874. dispose(): void;
  68875. /**
  68876. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68877. * doc :
  68878. * @returns the PCS.
  68879. */
  68880. refreshVisibleSize(): PointsCloudSystem;
  68881. /**
  68882. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68883. * @param size the size (float) of the visibility box
  68884. * note : this doesn't lock the PCS mesh bounding box.
  68885. * doc :
  68886. */
  68887. setVisibilityBox(size: number): void;
  68888. /**
  68889. * Gets whether the PCS is always visible or not
  68890. * doc :
  68891. */
  68892. get isAlwaysVisible(): boolean;
  68893. /**
  68894. * Sets the PCS as always visible or not
  68895. * doc :
  68896. */
  68897. set isAlwaysVisible(val: boolean);
  68898. /**
  68899. * Tells to `setParticles()` to compute the particle rotations or not
  68900. * Default value : false. The PCS is faster when it's set to false
  68901. * Note : particle rotations are only applied to parent particles
  68902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68903. */
  68904. set computeParticleRotation(val: boolean);
  68905. /**
  68906. * Tells to `setParticles()` to compute the particle colors or not.
  68907. * Default value : true. The PCS is faster when it's set to false.
  68908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68909. */
  68910. set computeParticleColor(val: boolean);
  68911. set computeParticleTexture(val: boolean);
  68912. /**
  68913. * Gets if `setParticles()` computes the particle colors or not.
  68914. * Default value : false. The PCS is faster when it's set to false.
  68915. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68916. */
  68917. get computeParticleColor(): boolean;
  68918. /**
  68919. * Gets if `setParticles()` computes the particle textures or not.
  68920. * Default value : false. The PCS is faster when it's set to false.
  68921. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68922. */
  68923. get computeParticleTexture(): boolean;
  68924. /**
  68925. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68926. */
  68927. set computeBoundingBox(val: boolean);
  68928. /**
  68929. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68930. */
  68931. get computeBoundingBox(): boolean;
  68932. /**
  68933. * This function does nothing. It may be overwritten to set all the particle first values.
  68934. * The PCS doesn't call this function, you may have to call it by your own.
  68935. * doc :
  68936. */
  68937. initParticles(): void;
  68938. /**
  68939. * This function does nothing. It may be overwritten to recycle a particle
  68940. * The PCS doesn't call this function, you can to call it
  68941. * doc :
  68942. * @param particle The particle to recycle
  68943. * @returns the recycled particle
  68944. */
  68945. recycleParticle(particle: CloudPoint): CloudPoint;
  68946. /**
  68947. * Updates a particle : this function should be overwritten by the user.
  68948. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68949. * doc :
  68950. * @example : just set a particle position or velocity and recycle conditions
  68951. * @param particle The particle to update
  68952. * @returns the updated particle
  68953. */
  68954. updateParticle(particle: CloudPoint): CloudPoint;
  68955. /**
  68956. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68957. * This does nothing and may be overwritten by the user.
  68958. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68959. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68960. * @param update the boolean update value actually passed to setParticles()
  68961. */
  68962. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68963. /**
  68964. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68965. * This will be passed three parameters.
  68966. * This does nothing and may be overwritten by the user.
  68967. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68968. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68969. * @param update the boolean update value actually passed to setParticles()
  68970. */
  68971. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68972. }
  68973. }
  68974. declare module BABYLON {
  68975. /**
  68976. * Represents one particle of a points cloud system.
  68977. */
  68978. export class CloudPoint {
  68979. /**
  68980. * particle global index
  68981. */
  68982. idx: number;
  68983. /**
  68984. * The color of the particle
  68985. */
  68986. color: Nullable<Color4>;
  68987. /**
  68988. * The world space position of the particle.
  68989. */
  68990. position: Vector3;
  68991. /**
  68992. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68993. */
  68994. rotation: Vector3;
  68995. /**
  68996. * The world space rotation quaternion of the particle.
  68997. */
  68998. rotationQuaternion: Nullable<Quaternion>;
  68999. /**
  69000. * The uv of the particle.
  69001. */
  69002. uv: Nullable<Vector2>;
  69003. /**
  69004. * The current speed of the particle.
  69005. */
  69006. velocity: Vector3;
  69007. /**
  69008. * The pivot point in the particle local space.
  69009. */
  69010. pivot: Vector3;
  69011. /**
  69012. * Must the particle be translated from its pivot point in its local space ?
  69013. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69014. * Default : false
  69015. */
  69016. translateFromPivot: boolean;
  69017. /**
  69018. * Index of this particle in the global "positions" array (Internal use)
  69019. * @hidden
  69020. */
  69021. _pos: number;
  69022. /**
  69023. * @hidden Index of this particle in the global "indices" array (Internal use)
  69024. */
  69025. _ind: number;
  69026. /**
  69027. * Group this particle belongs to
  69028. */
  69029. _group: PointsGroup;
  69030. /**
  69031. * Group id of this particle
  69032. */
  69033. groupId: number;
  69034. /**
  69035. * Index of the particle in its group id (Internal use)
  69036. */
  69037. idxInGroup: number;
  69038. /**
  69039. * @hidden Particle BoundingInfo object (Internal use)
  69040. */
  69041. _boundingInfo: BoundingInfo;
  69042. /**
  69043. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69044. */
  69045. _pcs: PointsCloudSystem;
  69046. /**
  69047. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69048. */
  69049. _stillInvisible: boolean;
  69050. /**
  69051. * @hidden Last computed particle rotation matrix
  69052. */
  69053. _rotationMatrix: number[];
  69054. /**
  69055. * Parent particle Id, if any.
  69056. * Default null.
  69057. */
  69058. parentId: Nullable<number>;
  69059. /**
  69060. * @hidden Internal global position in the PCS.
  69061. */
  69062. _globalPosition: Vector3;
  69063. /**
  69064. * Creates a Point Cloud object.
  69065. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69066. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69067. * @param group (PointsGroup) is the group the particle belongs to
  69068. * @param groupId (integer) is the group identifier in the PCS.
  69069. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69070. * @param pcs defines the PCS it is associated to
  69071. */
  69072. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69073. /**
  69074. * get point size
  69075. */
  69076. get size(): Vector3;
  69077. /**
  69078. * Set point size
  69079. */
  69080. set size(scale: Vector3);
  69081. /**
  69082. * Legacy support, changed quaternion to rotationQuaternion
  69083. */
  69084. get quaternion(): Nullable<Quaternion>;
  69085. /**
  69086. * Legacy support, changed quaternion to rotationQuaternion
  69087. */
  69088. set quaternion(q: Nullable<Quaternion>);
  69089. /**
  69090. * Returns a boolean. True if the particle intersects a mesh, else false
  69091. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69092. * @param target is the object (point or mesh) what the intersection is computed against
  69093. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69094. * @returns true if it intersects
  69095. */
  69096. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69097. /**
  69098. * get the rotation matrix of the particle
  69099. * @hidden
  69100. */
  69101. getRotationMatrix(m: Matrix): void;
  69102. }
  69103. /**
  69104. * Represents a group of points in a points cloud system
  69105. * * PCS internal tool, don't use it manually.
  69106. */
  69107. export class PointsGroup {
  69108. /**
  69109. * The group id
  69110. * @hidden
  69111. */
  69112. groupID: number;
  69113. /**
  69114. * image data for group (internal use)
  69115. * @hidden
  69116. */
  69117. _groupImageData: Nullable<ArrayBufferView>;
  69118. /**
  69119. * Image Width (internal use)
  69120. * @hidden
  69121. */
  69122. _groupImgWidth: number;
  69123. /**
  69124. * Image Height (internal use)
  69125. * @hidden
  69126. */
  69127. _groupImgHeight: number;
  69128. /**
  69129. * Custom position function (internal use)
  69130. * @hidden
  69131. */
  69132. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69133. /**
  69134. * density per facet for surface points
  69135. * @hidden
  69136. */
  69137. _groupDensity: number[];
  69138. /**
  69139. * Only when points are colored by texture carries pointer to texture list array
  69140. * @hidden
  69141. */
  69142. _textureNb: number;
  69143. /**
  69144. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69145. * PCS internal tool, don't use it manually.
  69146. * @hidden
  69147. */
  69148. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69149. }
  69150. }
  69151. declare module BABYLON {
  69152. interface Scene {
  69153. /** @hidden (Backing field) */
  69154. _physicsEngine: Nullable<IPhysicsEngine>;
  69155. /** @hidden */
  69156. _physicsTimeAccumulator: number;
  69157. /**
  69158. * Gets the current physics engine
  69159. * @returns a IPhysicsEngine or null if none attached
  69160. */
  69161. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69162. /**
  69163. * Enables physics to the current scene
  69164. * @param gravity defines the scene's gravity for the physics engine
  69165. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69166. * @return a boolean indicating if the physics engine was initialized
  69167. */
  69168. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69169. /**
  69170. * Disables and disposes the physics engine associated with the scene
  69171. */
  69172. disablePhysicsEngine(): void;
  69173. /**
  69174. * Gets a boolean indicating if there is an active physics engine
  69175. * @returns a boolean indicating if there is an active physics engine
  69176. */
  69177. isPhysicsEnabled(): boolean;
  69178. /**
  69179. * Deletes a physics compound impostor
  69180. * @param compound defines the compound to delete
  69181. */
  69182. deleteCompoundImpostor(compound: any): void;
  69183. /**
  69184. * An event triggered when physic simulation is about to be run
  69185. */
  69186. onBeforePhysicsObservable: Observable<Scene>;
  69187. /**
  69188. * An event triggered when physic simulation has been done
  69189. */
  69190. onAfterPhysicsObservable: Observable<Scene>;
  69191. }
  69192. interface AbstractMesh {
  69193. /** @hidden */
  69194. _physicsImpostor: Nullable<PhysicsImpostor>;
  69195. /**
  69196. * Gets or sets impostor used for physic simulation
  69197. * @see https://doc.babylonjs.com/features/physics_engine
  69198. */
  69199. physicsImpostor: Nullable<PhysicsImpostor>;
  69200. /**
  69201. * Gets the current physics impostor
  69202. * @see https://doc.babylonjs.com/features/physics_engine
  69203. * @returns a physics impostor or null
  69204. */
  69205. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69206. /** Apply a physic impulse to the mesh
  69207. * @param force defines the force to apply
  69208. * @param contactPoint defines where to apply the force
  69209. * @returns the current mesh
  69210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69211. */
  69212. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69213. /**
  69214. * Creates a physic joint between two meshes
  69215. * @param otherMesh defines the other mesh to use
  69216. * @param pivot1 defines the pivot to use on this mesh
  69217. * @param pivot2 defines the pivot to use on the other mesh
  69218. * @param options defines additional options (can be plugin dependent)
  69219. * @returns the current mesh
  69220. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69221. */
  69222. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69223. /** @hidden */
  69224. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69225. }
  69226. /**
  69227. * Defines the physics engine scene component responsible to manage a physics engine
  69228. */
  69229. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69230. /**
  69231. * The component name helpful to identify the component in the list of scene components.
  69232. */
  69233. readonly name: string;
  69234. /**
  69235. * The scene the component belongs to.
  69236. */
  69237. scene: Scene;
  69238. /**
  69239. * Creates a new instance of the component for the given scene
  69240. * @param scene Defines the scene to register the component in
  69241. */
  69242. constructor(scene: Scene);
  69243. /**
  69244. * Registers the component in a given scene
  69245. */
  69246. register(): void;
  69247. /**
  69248. * Rebuilds the elements related to this component in case of
  69249. * context lost for instance.
  69250. */
  69251. rebuild(): void;
  69252. /**
  69253. * Disposes the component and the associated ressources
  69254. */
  69255. dispose(): void;
  69256. }
  69257. }
  69258. declare module BABYLON {
  69259. /**
  69260. * A helper for physics simulations
  69261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69262. */
  69263. export class PhysicsHelper {
  69264. private _scene;
  69265. private _physicsEngine;
  69266. /**
  69267. * Initializes the Physics helper
  69268. * @param scene Babylon.js scene
  69269. */
  69270. constructor(scene: Scene);
  69271. /**
  69272. * Applies a radial explosion impulse
  69273. * @param origin the origin of the explosion
  69274. * @param radiusOrEventOptions the radius or the options of radial explosion
  69275. * @param strength the explosion strength
  69276. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69277. * @returns A physics radial explosion event, or null
  69278. */
  69279. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69280. /**
  69281. * Applies a radial explosion force
  69282. * @param origin the origin of the explosion
  69283. * @param radiusOrEventOptions the radius or the options of radial explosion
  69284. * @param strength the explosion strength
  69285. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69286. * @returns A physics radial explosion event, or null
  69287. */
  69288. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69289. /**
  69290. * Creates a gravitational field
  69291. * @param origin the origin of the explosion
  69292. * @param radiusOrEventOptions the radius or the options of radial explosion
  69293. * @param strength the explosion strength
  69294. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69295. * @returns A physics gravitational field event, or null
  69296. */
  69297. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69298. /**
  69299. * Creates a physics updraft event
  69300. * @param origin the origin of the updraft
  69301. * @param radiusOrEventOptions the radius or the options of the updraft
  69302. * @param strength the strength of the updraft
  69303. * @param height the height of the updraft
  69304. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69305. * @returns A physics updraft event, or null
  69306. */
  69307. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69308. /**
  69309. * Creates a physics vortex event
  69310. * @param origin the of the vortex
  69311. * @param radiusOrEventOptions the radius or the options of the vortex
  69312. * @param strength the strength of the vortex
  69313. * @param height the height of the vortex
  69314. * @returns a Physics vortex event, or null
  69315. * A physics vortex event or null
  69316. */
  69317. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69318. }
  69319. /**
  69320. * Represents a physics radial explosion event
  69321. */
  69322. class PhysicsRadialExplosionEvent {
  69323. private _scene;
  69324. private _options;
  69325. private _sphere;
  69326. private _dataFetched;
  69327. /**
  69328. * Initializes a radial explosioin event
  69329. * @param _scene BabylonJS scene
  69330. * @param _options The options for the vortex event
  69331. */
  69332. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69333. /**
  69334. * Returns the data related to the radial explosion event (sphere).
  69335. * @returns The radial explosion event data
  69336. */
  69337. getData(): PhysicsRadialExplosionEventData;
  69338. /**
  69339. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69340. * @param impostor A physics imposter
  69341. * @param origin the origin of the explosion
  69342. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69343. */
  69344. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69345. /**
  69346. * Triggers affecterd impostors callbacks
  69347. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69348. */
  69349. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69350. /**
  69351. * Disposes the sphere.
  69352. * @param force Specifies if the sphere should be disposed by force
  69353. */
  69354. dispose(force?: boolean): void;
  69355. /*** Helpers ***/
  69356. private _prepareSphere;
  69357. private _intersectsWithSphere;
  69358. }
  69359. /**
  69360. * Represents a gravitational field event
  69361. */
  69362. class PhysicsGravitationalFieldEvent {
  69363. private _physicsHelper;
  69364. private _scene;
  69365. private _origin;
  69366. private _options;
  69367. private _tickCallback;
  69368. private _sphere;
  69369. private _dataFetched;
  69370. /**
  69371. * Initializes the physics gravitational field event
  69372. * @param _physicsHelper A physics helper
  69373. * @param _scene BabylonJS scene
  69374. * @param _origin The origin position of the gravitational field event
  69375. * @param _options The options for the vortex event
  69376. */
  69377. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69378. /**
  69379. * Returns the data related to the gravitational field event (sphere).
  69380. * @returns A gravitational field event
  69381. */
  69382. getData(): PhysicsGravitationalFieldEventData;
  69383. /**
  69384. * Enables the gravitational field.
  69385. */
  69386. enable(): void;
  69387. /**
  69388. * Disables the gravitational field.
  69389. */
  69390. disable(): void;
  69391. /**
  69392. * Disposes the sphere.
  69393. * @param force The force to dispose from the gravitational field event
  69394. */
  69395. dispose(force?: boolean): void;
  69396. private _tick;
  69397. }
  69398. /**
  69399. * Represents a physics updraft event
  69400. */
  69401. class PhysicsUpdraftEvent {
  69402. private _scene;
  69403. private _origin;
  69404. private _options;
  69405. private _physicsEngine;
  69406. private _originTop;
  69407. private _originDirection;
  69408. private _tickCallback;
  69409. private _cylinder;
  69410. private _cylinderPosition;
  69411. private _dataFetched;
  69412. /**
  69413. * Initializes the physics updraft event
  69414. * @param _scene BabylonJS scene
  69415. * @param _origin The origin position of the updraft
  69416. * @param _options The options for the updraft event
  69417. */
  69418. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69419. /**
  69420. * Returns the data related to the updraft event (cylinder).
  69421. * @returns A physics updraft event
  69422. */
  69423. getData(): PhysicsUpdraftEventData;
  69424. /**
  69425. * Enables the updraft.
  69426. */
  69427. enable(): void;
  69428. /**
  69429. * Disables the updraft.
  69430. */
  69431. disable(): void;
  69432. /**
  69433. * Disposes the cylinder.
  69434. * @param force Specifies if the updraft should be disposed by force
  69435. */
  69436. dispose(force?: boolean): void;
  69437. private getImpostorHitData;
  69438. private _tick;
  69439. /*** Helpers ***/
  69440. private _prepareCylinder;
  69441. private _intersectsWithCylinder;
  69442. }
  69443. /**
  69444. * Represents a physics vortex event
  69445. */
  69446. class PhysicsVortexEvent {
  69447. private _scene;
  69448. private _origin;
  69449. private _options;
  69450. private _physicsEngine;
  69451. private _originTop;
  69452. private _tickCallback;
  69453. private _cylinder;
  69454. private _cylinderPosition;
  69455. private _dataFetched;
  69456. /**
  69457. * Initializes the physics vortex event
  69458. * @param _scene The BabylonJS scene
  69459. * @param _origin The origin position of the vortex
  69460. * @param _options The options for the vortex event
  69461. */
  69462. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69463. /**
  69464. * Returns the data related to the vortex event (cylinder).
  69465. * @returns The physics vortex event data
  69466. */
  69467. getData(): PhysicsVortexEventData;
  69468. /**
  69469. * Enables the vortex.
  69470. */
  69471. enable(): void;
  69472. /**
  69473. * Disables the cortex.
  69474. */
  69475. disable(): void;
  69476. /**
  69477. * Disposes the sphere.
  69478. * @param force
  69479. */
  69480. dispose(force?: boolean): void;
  69481. private getImpostorHitData;
  69482. private _tick;
  69483. /*** Helpers ***/
  69484. private _prepareCylinder;
  69485. private _intersectsWithCylinder;
  69486. }
  69487. /**
  69488. * Options fot the radial explosion event
  69489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69490. */
  69491. export class PhysicsRadialExplosionEventOptions {
  69492. /**
  69493. * The radius of the sphere for the radial explosion.
  69494. */
  69495. radius: number;
  69496. /**
  69497. * The strenth of the explosion.
  69498. */
  69499. strength: number;
  69500. /**
  69501. * The strenght of the force in correspondence to the distance of the affected object
  69502. */
  69503. falloff: PhysicsRadialImpulseFalloff;
  69504. /**
  69505. * Sphere options for the radial explosion.
  69506. */
  69507. sphere: {
  69508. segments: number;
  69509. diameter: number;
  69510. };
  69511. /**
  69512. * Sphere options for the radial explosion.
  69513. */
  69514. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69515. }
  69516. /**
  69517. * Options fot the updraft event
  69518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69519. */
  69520. export class PhysicsUpdraftEventOptions {
  69521. /**
  69522. * The radius of the cylinder for the vortex
  69523. */
  69524. radius: number;
  69525. /**
  69526. * The strenth of the updraft.
  69527. */
  69528. strength: number;
  69529. /**
  69530. * The height of the cylinder for the updraft.
  69531. */
  69532. height: number;
  69533. /**
  69534. * The mode for the the updraft.
  69535. */
  69536. updraftMode: PhysicsUpdraftMode;
  69537. }
  69538. /**
  69539. * Options fot the vortex event
  69540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69541. */
  69542. export class PhysicsVortexEventOptions {
  69543. /**
  69544. * The radius of the cylinder for the vortex
  69545. */
  69546. radius: number;
  69547. /**
  69548. * The strenth of the vortex.
  69549. */
  69550. strength: number;
  69551. /**
  69552. * The height of the cylinder for the vortex.
  69553. */
  69554. height: number;
  69555. /**
  69556. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69557. */
  69558. centripetalForceThreshold: number;
  69559. /**
  69560. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69561. */
  69562. centripetalForceMultiplier: number;
  69563. /**
  69564. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69565. */
  69566. centrifugalForceMultiplier: number;
  69567. /**
  69568. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69569. */
  69570. updraftForceMultiplier: number;
  69571. }
  69572. /**
  69573. * The strenght of the force in correspondence to the distance of the affected object
  69574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69575. */
  69576. export enum PhysicsRadialImpulseFalloff {
  69577. /** Defines that impulse is constant in strength across it's whole radius */
  69578. Constant = 0,
  69579. /** Defines that impulse gets weaker if it's further from the origin */
  69580. Linear = 1
  69581. }
  69582. /**
  69583. * The strength of the force in correspondence to the distance of the affected object
  69584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69585. */
  69586. export enum PhysicsUpdraftMode {
  69587. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69588. Center = 0,
  69589. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69590. Perpendicular = 1
  69591. }
  69592. /**
  69593. * Interface for a physics hit data
  69594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69595. */
  69596. export interface PhysicsHitData {
  69597. /**
  69598. * The force applied at the contact point
  69599. */
  69600. force: Vector3;
  69601. /**
  69602. * The contact point
  69603. */
  69604. contactPoint: Vector3;
  69605. /**
  69606. * The distance from the origin to the contact point
  69607. */
  69608. distanceFromOrigin: number;
  69609. }
  69610. /**
  69611. * Interface for radial explosion event data
  69612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69613. */
  69614. export interface PhysicsRadialExplosionEventData {
  69615. /**
  69616. * A sphere used for the radial explosion event
  69617. */
  69618. sphere: Mesh;
  69619. }
  69620. /**
  69621. * Interface for gravitational field event data
  69622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69623. */
  69624. export interface PhysicsGravitationalFieldEventData {
  69625. /**
  69626. * A sphere mesh used for the gravitational field event
  69627. */
  69628. sphere: Mesh;
  69629. }
  69630. /**
  69631. * Interface for updraft event data
  69632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69633. */
  69634. export interface PhysicsUpdraftEventData {
  69635. /**
  69636. * A cylinder used for the updraft event
  69637. */
  69638. cylinder: Mesh;
  69639. }
  69640. /**
  69641. * Interface for vortex event data
  69642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69643. */
  69644. export interface PhysicsVortexEventData {
  69645. /**
  69646. * A cylinder used for the vortex event
  69647. */
  69648. cylinder: Mesh;
  69649. }
  69650. /**
  69651. * Interface for an affected physics impostor
  69652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69653. */
  69654. export interface PhysicsAffectedImpostorWithData {
  69655. /**
  69656. * The impostor affected by the effect
  69657. */
  69658. impostor: PhysicsImpostor;
  69659. /**
  69660. * The data about the hit/horce from the explosion
  69661. */
  69662. hitData: PhysicsHitData;
  69663. }
  69664. }
  69665. declare module BABYLON {
  69666. /** @hidden */
  69667. export var blackAndWhitePixelShader: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module BABYLON {
  69673. /**
  69674. * Post process used to render in black and white
  69675. */
  69676. export class BlackAndWhitePostProcess extends PostProcess {
  69677. /**
  69678. * Linear about to convert he result to black and white (default: 1)
  69679. */
  69680. degree: number;
  69681. /**
  69682. * Gets a string identifying the name of the class
  69683. * @returns "BlackAndWhitePostProcess" string
  69684. */
  69685. getClassName(): string;
  69686. /**
  69687. * Creates a black and white post process
  69688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69689. * @param name The name of the effect.
  69690. * @param options The required width/height ratio to downsize to before computing the render pass.
  69691. * @param camera The camera to apply the render pass to.
  69692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69693. * @param engine The engine which the post process will be applied. (default: current engine)
  69694. * @param reusable If the post process can be reused on the same frame. (default: false)
  69695. */
  69696. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69697. /** @hidden */
  69698. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69699. }
  69700. }
  69701. declare module BABYLON {
  69702. /**
  69703. * This represents a set of one or more post processes in Babylon.
  69704. * A post process can be used to apply a shader to a texture after it is rendered.
  69705. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69706. */
  69707. export class PostProcessRenderEffect {
  69708. private _postProcesses;
  69709. private _getPostProcesses;
  69710. private _singleInstance;
  69711. private _cameras;
  69712. private _indicesForCamera;
  69713. /**
  69714. * Name of the effect
  69715. * @hidden
  69716. */
  69717. _name: string;
  69718. /**
  69719. * Instantiates a post process render effect.
  69720. * A post process can be used to apply a shader to a texture after it is rendered.
  69721. * @param engine The engine the effect is tied to
  69722. * @param name The name of the effect
  69723. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69724. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69725. */
  69726. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69727. /**
  69728. * Checks if all the post processes in the effect are supported.
  69729. */
  69730. get isSupported(): boolean;
  69731. /**
  69732. * Updates the current state of the effect
  69733. * @hidden
  69734. */
  69735. _update(): void;
  69736. /**
  69737. * Attaches the effect on cameras
  69738. * @param cameras The camera to attach to.
  69739. * @hidden
  69740. */
  69741. _attachCameras(cameras: Camera): void;
  69742. /**
  69743. * Attaches the effect on cameras
  69744. * @param cameras The camera to attach to.
  69745. * @hidden
  69746. */
  69747. _attachCameras(cameras: Camera[]): void;
  69748. /**
  69749. * Detaches the effect on cameras
  69750. * @param cameras The camera to detatch from.
  69751. * @hidden
  69752. */
  69753. _detachCameras(cameras: Camera): void;
  69754. /**
  69755. * Detatches the effect on cameras
  69756. * @param cameras The camera to detatch from.
  69757. * @hidden
  69758. */
  69759. _detachCameras(cameras: Camera[]): void;
  69760. /**
  69761. * Enables the effect on given cameras
  69762. * @param cameras The camera to enable.
  69763. * @hidden
  69764. */
  69765. _enable(cameras: Camera): void;
  69766. /**
  69767. * Enables the effect on given cameras
  69768. * @param cameras The camera to enable.
  69769. * @hidden
  69770. */
  69771. _enable(cameras: Nullable<Camera[]>): void;
  69772. /**
  69773. * Disables the effect on the given cameras
  69774. * @param cameras The camera to disable.
  69775. * @hidden
  69776. */
  69777. _disable(cameras: Camera): void;
  69778. /**
  69779. * Disables the effect on the given cameras
  69780. * @param cameras The camera to disable.
  69781. * @hidden
  69782. */
  69783. _disable(cameras: Nullable<Camera[]>): void;
  69784. /**
  69785. * Gets a list of the post processes contained in the effect.
  69786. * @param camera The camera to get the post processes on.
  69787. * @returns The list of the post processes in the effect.
  69788. */
  69789. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69790. }
  69791. }
  69792. declare module BABYLON {
  69793. /** @hidden */
  69794. export var extractHighlightsPixelShader: {
  69795. name: string;
  69796. shader: string;
  69797. };
  69798. }
  69799. declare module BABYLON {
  69800. /**
  69801. * 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.
  69802. */
  69803. export class ExtractHighlightsPostProcess extends PostProcess {
  69804. /**
  69805. * The luminance threshold, pixels below this value will be set to black.
  69806. */
  69807. threshold: number;
  69808. /** @hidden */
  69809. _exposure: number;
  69810. /**
  69811. * Post process which has the input texture to be used when performing highlight extraction
  69812. * @hidden
  69813. */
  69814. _inputPostProcess: Nullable<PostProcess>;
  69815. /**
  69816. * Gets a string identifying the name of the class
  69817. * @returns "ExtractHighlightsPostProcess" string
  69818. */
  69819. getClassName(): string;
  69820. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69821. }
  69822. }
  69823. declare module BABYLON {
  69824. /** @hidden */
  69825. export var bloomMergePixelShader: {
  69826. name: string;
  69827. shader: string;
  69828. };
  69829. }
  69830. declare module BABYLON {
  69831. /**
  69832. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69833. */
  69834. export class BloomMergePostProcess extends PostProcess {
  69835. /** Weight of the bloom to be added to the original input. */
  69836. weight: number;
  69837. /**
  69838. * Gets a string identifying the name of the class
  69839. * @returns "BloomMergePostProcess" string
  69840. */
  69841. getClassName(): string;
  69842. /**
  69843. * Creates a new instance of @see BloomMergePostProcess
  69844. * @param name The name of the effect.
  69845. * @param originalFromInput Post process which's input will be used for the merge.
  69846. * @param blurred Blurred highlights post process which's output will be used.
  69847. * @param weight Weight of the bloom to be added to the original input.
  69848. * @param options The required width/height ratio to downsize to before computing the render pass.
  69849. * @param camera The camera to apply the render pass to.
  69850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69851. * @param engine The engine which the post process will be applied. (default: current engine)
  69852. * @param reusable If the post process can be reused on the same frame. (default: false)
  69853. * @param textureType Type of textures used when performing the post process. (default: 0)
  69854. * @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)
  69855. */
  69856. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69857. /** Weight of the bloom to be added to the original input. */
  69858. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69859. }
  69860. }
  69861. declare module BABYLON {
  69862. /**
  69863. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69864. */
  69865. export class BloomEffect extends PostProcessRenderEffect {
  69866. private bloomScale;
  69867. /**
  69868. * @hidden Internal
  69869. */
  69870. _effects: Array<PostProcess>;
  69871. /**
  69872. * @hidden Internal
  69873. */
  69874. _downscale: ExtractHighlightsPostProcess;
  69875. private _blurX;
  69876. private _blurY;
  69877. private _merge;
  69878. /**
  69879. * The luminance threshold to find bright areas of the image to bloom.
  69880. */
  69881. get threshold(): number;
  69882. set threshold(value: number);
  69883. /**
  69884. * The strength of the bloom.
  69885. */
  69886. get weight(): number;
  69887. set weight(value: number);
  69888. /**
  69889. * Specifies the size of the bloom blur kernel, relative to the final output size
  69890. */
  69891. get kernel(): number;
  69892. set kernel(value: number);
  69893. /**
  69894. * Creates a new instance of @see BloomEffect
  69895. * @param scene The scene the effect belongs to.
  69896. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69897. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69898. * @param bloomWeight The the strength of bloom.
  69899. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69900. * @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)
  69901. */
  69902. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69903. /**
  69904. * Disposes each of the internal effects for a given camera.
  69905. * @param camera The camera to dispose the effect on.
  69906. */
  69907. disposeEffects(camera: Camera): void;
  69908. /**
  69909. * @hidden Internal
  69910. */
  69911. _updateEffects(): void;
  69912. /**
  69913. * Internal
  69914. * @returns if all the contained post processes are ready.
  69915. * @hidden
  69916. */
  69917. _isReady(): boolean;
  69918. }
  69919. }
  69920. declare module BABYLON {
  69921. /** @hidden */
  69922. export var chromaticAberrationPixelShader: {
  69923. name: string;
  69924. shader: string;
  69925. };
  69926. }
  69927. declare module BABYLON {
  69928. /**
  69929. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69930. */
  69931. export class ChromaticAberrationPostProcess extends PostProcess {
  69932. /**
  69933. * The amount of seperation of rgb channels (default: 30)
  69934. */
  69935. aberrationAmount: number;
  69936. /**
  69937. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69938. */
  69939. radialIntensity: number;
  69940. /**
  69941. * 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))
  69942. */
  69943. direction: Vector2;
  69944. /**
  69945. * 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))
  69946. */
  69947. centerPosition: Vector2;
  69948. /** The width of the screen to apply the effect on */
  69949. screenWidth: number;
  69950. /** The height of the screen to apply the effect on */
  69951. screenHeight: number;
  69952. /**
  69953. * Gets a string identifying the name of the class
  69954. * @returns "ChromaticAberrationPostProcess" string
  69955. */
  69956. getClassName(): string;
  69957. /**
  69958. * Creates a new instance ChromaticAberrationPostProcess
  69959. * @param name The name of the effect.
  69960. * @param screenWidth The width of the screen to apply the effect on.
  69961. * @param screenHeight The height of the screen to apply the effect on.
  69962. * @param options The required width/height ratio to downsize to before computing the render pass.
  69963. * @param camera The camera to apply the render pass to.
  69964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69965. * @param engine The engine which the post process will be applied. (default: current engine)
  69966. * @param reusable If the post process can be reused on the same frame. (default: false)
  69967. * @param textureType Type of textures used when performing the post process. (default: 0)
  69968. * @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)
  69969. */
  69970. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69971. /** @hidden */
  69972. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69973. }
  69974. }
  69975. declare module BABYLON {
  69976. /** @hidden */
  69977. export var circleOfConfusionPixelShader: {
  69978. name: string;
  69979. shader: string;
  69980. };
  69981. }
  69982. declare module BABYLON {
  69983. /**
  69984. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69985. */
  69986. export class CircleOfConfusionPostProcess extends PostProcess {
  69987. /**
  69988. * 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.
  69989. */
  69990. lensSize: number;
  69991. /**
  69992. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69993. */
  69994. fStop: number;
  69995. /**
  69996. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69997. */
  69998. focusDistance: number;
  69999. /**
  70000. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70001. */
  70002. focalLength: number;
  70003. /**
  70004. * Gets a string identifying the name of the class
  70005. * @returns "CircleOfConfusionPostProcess" string
  70006. */
  70007. getClassName(): string;
  70008. private _depthTexture;
  70009. /**
  70010. * Creates a new instance CircleOfConfusionPostProcess
  70011. * @param name The name of the effect.
  70012. * @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.
  70013. * @param options The required width/height ratio to downsize to before computing the render pass.
  70014. * @param camera The camera to apply the render pass to.
  70015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70016. * @param engine The engine which the post process will be applied. (default: current engine)
  70017. * @param reusable If the post process can be reused on the same frame. (default: false)
  70018. * @param textureType Type of textures used when performing the post process. (default: 0)
  70019. * @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)
  70020. */
  70021. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70022. /**
  70023. * 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.
  70024. */
  70025. set depthTexture(value: RenderTargetTexture);
  70026. }
  70027. }
  70028. declare module BABYLON {
  70029. /** @hidden */
  70030. export var colorCorrectionPixelShader: {
  70031. name: string;
  70032. shader: string;
  70033. };
  70034. }
  70035. declare module BABYLON {
  70036. /**
  70037. *
  70038. * This post-process allows the modification of rendered colors by using
  70039. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70040. *
  70041. * The object needs to be provided an url to a texture containing the color
  70042. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70043. * Use an image editing software to tweak the LUT to match your needs.
  70044. *
  70045. * For an example of a color LUT, see here:
  70046. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70047. * For explanations on color grading, see here:
  70048. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70049. *
  70050. */
  70051. export class ColorCorrectionPostProcess extends PostProcess {
  70052. private _colorTableTexture;
  70053. /**
  70054. * Gets the color table url used to create the LUT texture
  70055. */
  70056. colorTableUrl: string;
  70057. /**
  70058. * Gets a string identifying the name of the class
  70059. * @returns "ColorCorrectionPostProcess" string
  70060. */
  70061. getClassName(): string;
  70062. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70063. /** @hidden */
  70064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. /** @hidden */
  70069. export var convolutionPixelShader: {
  70070. name: string;
  70071. shader: string;
  70072. };
  70073. }
  70074. declare module BABYLON {
  70075. /**
  70076. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70077. * input texture to perform effects such as edge detection or sharpening
  70078. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70079. */
  70080. export class ConvolutionPostProcess extends PostProcess {
  70081. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70082. kernel: number[];
  70083. /**
  70084. * Gets a string identifying the name of the class
  70085. * @returns "ConvolutionPostProcess" string
  70086. */
  70087. getClassName(): string;
  70088. /**
  70089. * Creates a new instance ConvolutionPostProcess
  70090. * @param name The name of the effect.
  70091. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70092. * @param options The required width/height ratio to downsize to before computing the render pass.
  70093. * @param camera The camera to apply the render pass to.
  70094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70095. * @param engine The engine which the post process will be applied. (default: current engine)
  70096. * @param reusable If the post process can be reused on the same frame. (default: false)
  70097. * @param textureType Type of textures used when performing the post process. (default: 0)
  70098. */
  70099. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70100. /** @hidden */
  70101. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70102. /**
  70103. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70104. */
  70105. static EdgeDetect0Kernel: number[];
  70106. /**
  70107. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70108. */
  70109. static EdgeDetect1Kernel: number[];
  70110. /**
  70111. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70112. */
  70113. static EdgeDetect2Kernel: number[];
  70114. /**
  70115. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70116. */
  70117. static SharpenKernel: number[];
  70118. /**
  70119. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70120. */
  70121. static EmbossKernel: number[];
  70122. /**
  70123. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70124. */
  70125. static GaussianKernel: number[];
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /**
  70130. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70131. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70132. * based on samples that have a large difference in distance than the center pixel.
  70133. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70134. */
  70135. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70136. /**
  70137. * The direction the blur should be applied
  70138. */
  70139. direction: Vector2;
  70140. /**
  70141. * Gets a string identifying the name of the class
  70142. * @returns "DepthOfFieldBlurPostProcess" string
  70143. */
  70144. getClassName(): string;
  70145. /**
  70146. * Creates a new instance CircleOfConfusionPostProcess
  70147. * @param name The name of the effect.
  70148. * @param scene The scene the effect belongs to.
  70149. * @param direction The direction the blur should be applied.
  70150. * @param kernel The size of the kernel used to blur.
  70151. * @param options The required width/height ratio to downsize to before computing the render pass.
  70152. * @param camera The camera to apply the render pass to.
  70153. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70154. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70156. * @param engine The engine which the post process will be applied. (default: current engine)
  70157. * @param reusable If the post process can be reused on the same frame. (default: false)
  70158. * @param textureType Type of textures used when performing the post process. (default: 0)
  70159. * @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)
  70160. */
  70161. 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);
  70162. }
  70163. }
  70164. declare module BABYLON {
  70165. /** @hidden */
  70166. export var depthOfFieldMergePixelShader: {
  70167. name: string;
  70168. shader: string;
  70169. };
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * Options to be set when merging outputs from the default pipeline.
  70174. */
  70175. export class DepthOfFieldMergePostProcessOptions {
  70176. /**
  70177. * The original image to merge on top of
  70178. */
  70179. originalFromInput: PostProcess;
  70180. /**
  70181. * Parameters to perform the merge of the depth of field effect
  70182. */
  70183. depthOfField?: {
  70184. circleOfConfusion: PostProcess;
  70185. blurSteps: Array<PostProcess>;
  70186. };
  70187. /**
  70188. * Parameters to perform the merge of bloom effect
  70189. */
  70190. bloom?: {
  70191. blurred: PostProcess;
  70192. weight: number;
  70193. };
  70194. }
  70195. /**
  70196. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70197. */
  70198. export class DepthOfFieldMergePostProcess extends PostProcess {
  70199. private blurSteps;
  70200. /**
  70201. * Gets a string identifying the name of the class
  70202. * @returns "DepthOfFieldMergePostProcess" string
  70203. */
  70204. getClassName(): string;
  70205. /**
  70206. * Creates a new instance of DepthOfFieldMergePostProcess
  70207. * @param name The name of the effect.
  70208. * @param originalFromInput Post process which's input will be used for the merge.
  70209. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70210. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70211. * @param options The required width/height ratio to downsize to before computing the render pass.
  70212. * @param camera The camera to apply the render pass to.
  70213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70214. * @param engine The engine which the post process will be applied. (default: current engine)
  70215. * @param reusable If the post process can be reused on the same frame. (default: false)
  70216. * @param textureType Type of textures used when performing the post process. (default: 0)
  70217. * @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)
  70218. */
  70219. 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);
  70220. /**
  70221. * Updates the effect with the current post process compile time values and recompiles the shader.
  70222. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70223. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70224. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70225. * @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
  70226. * @param onCompiled Called when the shader has been compiled.
  70227. * @param onError Called if there is an error when compiling a shader.
  70228. */
  70229. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70230. }
  70231. }
  70232. declare module BABYLON {
  70233. /**
  70234. * Specifies the level of max blur that should be applied when using the depth of field effect
  70235. */
  70236. export enum DepthOfFieldEffectBlurLevel {
  70237. /**
  70238. * Subtle blur
  70239. */
  70240. Low = 0,
  70241. /**
  70242. * Medium blur
  70243. */
  70244. Medium = 1,
  70245. /**
  70246. * Large blur
  70247. */
  70248. High = 2
  70249. }
  70250. /**
  70251. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70252. */
  70253. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70254. private _circleOfConfusion;
  70255. /**
  70256. * @hidden Internal, blurs from high to low
  70257. */
  70258. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70259. private _depthOfFieldBlurY;
  70260. private _dofMerge;
  70261. /**
  70262. * @hidden Internal post processes in depth of field effect
  70263. */
  70264. _effects: Array<PostProcess>;
  70265. /**
  70266. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70267. */
  70268. set focalLength(value: number);
  70269. get focalLength(): number;
  70270. /**
  70271. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70272. */
  70273. set fStop(value: number);
  70274. get fStop(): number;
  70275. /**
  70276. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70277. */
  70278. set focusDistance(value: number);
  70279. get focusDistance(): number;
  70280. /**
  70281. * 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.
  70282. */
  70283. set lensSize(value: number);
  70284. get lensSize(): number;
  70285. /**
  70286. * Creates a new instance DepthOfFieldEffect
  70287. * @param scene The scene the effect belongs to.
  70288. * @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.
  70289. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70290. * @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)
  70291. */
  70292. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70293. /**
  70294. * Get the current class name of the current effet
  70295. * @returns "DepthOfFieldEffect"
  70296. */
  70297. getClassName(): string;
  70298. /**
  70299. * 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.
  70300. */
  70301. set depthTexture(value: RenderTargetTexture);
  70302. /**
  70303. * Disposes each of the internal effects for a given camera.
  70304. * @param camera The camera to dispose the effect on.
  70305. */
  70306. disposeEffects(camera: Camera): void;
  70307. /**
  70308. * @hidden Internal
  70309. */
  70310. _updateEffects(): void;
  70311. /**
  70312. * Internal
  70313. * @returns if all the contained post processes are ready.
  70314. * @hidden
  70315. */
  70316. _isReady(): boolean;
  70317. }
  70318. }
  70319. declare module BABYLON {
  70320. /** @hidden */
  70321. export var displayPassPixelShader: {
  70322. name: string;
  70323. shader: string;
  70324. };
  70325. }
  70326. declare module BABYLON {
  70327. /**
  70328. * DisplayPassPostProcess which produces an output the same as it's input
  70329. */
  70330. export class DisplayPassPostProcess extends PostProcess {
  70331. /**
  70332. * Gets a string identifying the name of the class
  70333. * @returns "DisplayPassPostProcess" string
  70334. */
  70335. getClassName(): string;
  70336. /**
  70337. * Creates the DisplayPassPostProcess
  70338. * @param name The name of the effect.
  70339. * @param options The required width/height ratio to downsize to before computing the render pass.
  70340. * @param camera The camera to apply the render pass to.
  70341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70342. * @param engine The engine which the post process will be applied. (default: current engine)
  70343. * @param reusable If the post process can be reused on the same frame. (default: false)
  70344. */
  70345. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70346. /** @hidden */
  70347. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. /** @hidden */
  70352. export var filterPixelShader: {
  70353. name: string;
  70354. shader: string;
  70355. };
  70356. }
  70357. declare module BABYLON {
  70358. /**
  70359. * Applies a kernel filter to the image
  70360. */
  70361. export class FilterPostProcess extends PostProcess {
  70362. /** The matrix to be applied to the image */
  70363. kernelMatrix: Matrix;
  70364. /**
  70365. * Gets a string identifying the name of the class
  70366. * @returns "FilterPostProcess" string
  70367. */
  70368. getClassName(): string;
  70369. /**
  70370. *
  70371. * @param name The name of the effect.
  70372. * @param kernelMatrix The matrix to be applied to the image
  70373. * @param options The required width/height ratio to downsize to before computing the render pass.
  70374. * @param camera The camera to apply the render pass to.
  70375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70376. * @param engine The engine which the post process will be applied. (default: current engine)
  70377. * @param reusable If the post process can be reused on the same frame. (default: false)
  70378. */
  70379. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70380. /** @hidden */
  70381. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70382. }
  70383. }
  70384. declare module BABYLON {
  70385. /** @hidden */
  70386. export var fxaaPixelShader: {
  70387. name: string;
  70388. shader: string;
  70389. };
  70390. }
  70391. declare module BABYLON {
  70392. /** @hidden */
  70393. export var fxaaVertexShader: {
  70394. name: string;
  70395. shader: string;
  70396. };
  70397. }
  70398. declare module BABYLON {
  70399. /**
  70400. * Fxaa post process
  70401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70402. */
  70403. export class FxaaPostProcess extends PostProcess {
  70404. /**
  70405. * Gets a string identifying the name of the class
  70406. * @returns "FxaaPostProcess" string
  70407. */
  70408. getClassName(): string;
  70409. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70410. private _getDefines;
  70411. /** @hidden */
  70412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70413. }
  70414. }
  70415. declare module BABYLON {
  70416. /** @hidden */
  70417. export var grainPixelShader: {
  70418. name: string;
  70419. shader: string;
  70420. };
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * The GrainPostProcess adds noise to the image at mid luminance levels
  70425. */
  70426. export class GrainPostProcess extends PostProcess {
  70427. /**
  70428. * The intensity of the grain added (default: 30)
  70429. */
  70430. intensity: number;
  70431. /**
  70432. * If the grain should be randomized on every frame
  70433. */
  70434. animated: boolean;
  70435. /**
  70436. * Gets a string identifying the name of the class
  70437. * @returns "GrainPostProcess" string
  70438. */
  70439. getClassName(): string;
  70440. /**
  70441. * Creates a new instance of @see GrainPostProcess
  70442. * @param name The name of the effect.
  70443. * @param options The required width/height ratio to downsize to before computing the render pass.
  70444. * @param camera The camera to apply the render pass to.
  70445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70446. * @param engine The engine which the post process will be applied. (default: current engine)
  70447. * @param reusable If the post process can be reused on the same frame. (default: false)
  70448. * @param textureType Type of textures used when performing the post process. (default: 0)
  70449. * @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)
  70450. */
  70451. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70452. /** @hidden */
  70453. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70454. }
  70455. }
  70456. declare module BABYLON {
  70457. /** @hidden */
  70458. export var highlightsPixelShader: {
  70459. name: string;
  70460. shader: string;
  70461. };
  70462. }
  70463. declare module BABYLON {
  70464. /**
  70465. * Extracts highlights from the image
  70466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70467. */
  70468. export class HighlightsPostProcess extends PostProcess {
  70469. /**
  70470. * Gets a string identifying the name of the class
  70471. * @returns "HighlightsPostProcess" string
  70472. */
  70473. getClassName(): string;
  70474. /**
  70475. * Extracts highlights from the image
  70476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70477. * @param name The name of the effect.
  70478. * @param options The required width/height ratio to downsize to before computing the render pass.
  70479. * @param camera The camera to apply the render pass to.
  70480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70481. * @param engine The engine which the post process will be applied. (default: current engine)
  70482. * @param reusable If the post process can be reused on the same frame. (default: false)
  70483. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70484. */
  70485. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /**
  70490. * Contains all parameters needed for the prepass to perform
  70491. * motion blur
  70492. */
  70493. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70494. /**
  70495. * Is motion blur enabled
  70496. */
  70497. enabled: boolean;
  70498. /**
  70499. * Name of the configuration
  70500. */
  70501. name: string;
  70502. /**
  70503. * Textures that should be present in the MRT for this effect to work
  70504. */
  70505. readonly texturesRequired: number[];
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. interface Scene {
  70510. /** @hidden (Backing field) */
  70511. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70512. /**
  70513. * Gets or Sets the current geometry buffer associated to the scene.
  70514. */
  70515. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70516. /**
  70517. * Enables a GeometryBufferRender and associates it with the scene
  70518. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70519. * @returns the GeometryBufferRenderer
  70520. */
  70521. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70522. /**
  70523. * Disables the GeometryBufferRender associated with the scene
  70524. */
  70525. disableGeometryBufferRenderer(): void;
  70526. }
  70527. /**
  70528. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70529. * in several rendering techniques.
  70530. */
  70531. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70532. /**
  70533. * The component name helpful to identify the component in the list of scene components.
  70534. */
  70535. readonly name: string;
  70536. /**
  70537. * The scene the component belongs to.
  70538. */
  70539. scene: Scene;
  70540. /**
  70541. * Creates a new instance of the component for the given scene
  70542. * @param scene Defines the scene to register the component in
  70543. */
  70544. constructor(scene: Scene);
  70545. /**
  70546. * Registers the component in a given scene
  70547. */
  70548. register(): void;
  70549. /**
  70550. * Rebuilds the elements related to this component in case of
  70551. * context lost for instance.
  70552. */
  70553. rebuild(): void;
  70554. /**
  70555. * Disposes the component and the associated ressources
  70556. */
  70557. dispose(): void;
  70558. private _gatherRenderTargets;
  70559. }
  70560. }
  70561. declare module BABYLON {
  70562. /** @hidden */
  70563. export var motionBlurPixelShader: {
  70564. name: string;
  70565. shader: string;
  70566. };
  70567. }
  70568. declare module BABYLON {
  70569. /**
  70570. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70571. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70572. * As an example, all you have to do is to create the post-process:
  70573. * var mb = new BABYLON.MotionBlurPostProcess(
  70574. * 'mb', // The name of the effect.
  70575. * scene, // The scene containing the objects to blur according to their velocity.
  70576. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70577. * camera // The camera to apply the render pass to.
  70578. * );
  70579. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70580. */
  70581. export class MotionBlurPostProcess extends PostProcess {
  70582. /**
  70583. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70584. */
  70585. motionStrength: number;
  70586. /**
  70587. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70588. */
  70589. get motionBlurSamples(): number;
  70590. /**
  70591. * Sets the number of iterations to be used for motion blur quality
  70592. */
  70593. set motionBlurSamples(samples: number);
  70594. private _motionBlurSamples;
  70595. private _forceGeometryBuffer;
  70596. private _geometryBufferRenderer;
  70597. private _prePassRenderer;
  70598. /**
  70599. * Gets a string identifying the name of the class
  70600. * @returns "MotionBlurPostProcess" string
  70601. */
  70602. getClassName(): string;
  70603. /**
  70604. * Creates a new instance MotionBlurPostProcess
  70605. * @param name The name of the effect.
  70606. * @param scene The scene containing the objects to blur according to their velocity.
  70607. * @param options The required width/height ratio to downsize to before computing the render pass.
  70608. * @param camera The camera to apply the render pass to.
  70609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70610. * @param engine The engine which the post process will be applied. (default: current engine)
  70611. * @param reusable If the post process can be reused on the same frame. (default: false)
  70612. * @param textureType Type of textures used when performing the post process. (default: 0)
  70613. * @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)
  70614. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70615. */
  70616. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70617. /**
  70618. * Excludes the given skinned mesh from computing bones velocities.
  70619. * 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.
  70620. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70621. */
  70622. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70623. /**
  70624. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70625. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70626. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70627. */
  70628. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70629. /**
  70630. * Disposes the post process.
  70631. * @param camera The camera to dispose the post process on.
  70632. */
  70633. dispose(camera?: Camera): void;
  70634. /** @hidden */
  70635. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70636. }
  70637. }
  70638. declare module BABYLON {
  70639. /** @hidden */
  70640. export var refractionPixelShader: {
  70641. name: string;
  70642. shader: string;
  70643. };
  70644. }
  70645. declare module BABYLON {
  70646. /**
  70647. * Post process which applies a refractin texture
  70648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70649. */
  70650. export class RefractionPostProcess extends PostProcess {
  70651. private _refTexture;
  70652. private _ownRefractionTexture;
  70653. /** the base color of the refraction (used to taint the rendering) */
  70654. color: Color3;
  70655. /** simulated refraction depth */
  70656. depth: number;
  70657. /** the coefficient of the base color (0 to remove base color tainting) */
  70658. colorLevel: number;
  70659. /** Gets the url used to load the refraction texture */
  70660. refractionTextureUrl: string;
  70661. /**
  70662. * Gets or sets the refraction texture
  70663. * Please note that you are responsible for disposing the texture if you set it manually
  70664. */
  70665. get refractionTexture(): Texture;
  70666. set refractionTexture(value: Texture);
  70667. /**
  70668. * Gets a string identifying the name of the class
  70669. * @returns "RefractionPostProcess" string
  70670. */
  70671. getClassName(): string;
  70672. /**
  70673. * Initializes the RefractionPostProcess
  70674. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70675. * @param name The name of the effect.
  70676. * @param refractionTextureUrl Url of the refraction texture to use
  70677. * @param color the base color of the refraction (used to taint the rendering)
  70678. * @param depth simulated refraction depth
  70679. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70680. * @param camera The camera to apply the render pass to.
  70681. * @param options The required width/height ratio to downsize to before computing the render pass.
  70682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70683. * @param engine The engine which the post process will be applied. (default: current engine)
  70684. * @param reusable If the post process can be reused on the same frame. (default: false)
  70685. */
  70686. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70687. /**
  70688. * Disposes of the post process
  70689. * @param camera Camera to dispose post process on
  70690. */
  70691. dispose(camera: Camera): void;
  70692. /** @hidden */
  70693. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70694. }
  70695. }
  70696. declare module BABYLON {
  70697. /** @hidden */
  70698. export var sharpenPixelShader: {
  70699. name: string;
  70700. shader: string;
  70701. };
  70702. }
  70703. declare module BABYLON {
  70704. /**
  70705. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70706. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70707. */
  70708. export class SharpenPostProcess extends PostProcess {
  70709. /**
  70710. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70711. */
  70712. colorAmount: number;
  70713. /**
  70714. * How much sharpness should be applied (default: 0.3)
  70715. */
  70716. edgeAmount: number;
  70717. /**
  70718. * Gets a string identifying the name of the class
  70719. * @returns "SharpenPostProcess" string
  70720. */
  70721. getClassName(): string;
  70722. /**
  70723. * Creates a new instance ConvolutionPostProcess
  70724. * @param name The name of the effect.
  70725. * @param options The required width/height ratio to downsize to before computing the render pass.
  70726. * @param camera The camera to apply the render pass to.
  70727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70728. * @param engine The engine which the post process will be applied. (default: current engine)
  70729. * @param reusable If the post process can be reused on the same frame. (default: false)
  70730. * @param textureType Type of textures used when performing the post process. (default: 0)
  70731. * @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)
  70732. */
  70733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70734. /** @hidden */
  70735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70736. }
  70737. }
  70738. declare module BABYLON {
  70739. /**
  70740. * PostProcessRenderPipeline
  70741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70742. */
  70743. export class PostProcessRenderPipeline {
  70744. private engine;
  70745. private _renderEffects;
  70746. private _renderEffectsForIsolatedPass;
  70747. /**
  70748. * List of inspectable custom properties (used by the Inspector)
  70749. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70750. */
  70751. inspectableCustomProperties: IInspectable[];
  70752. /**
  70753. * @hidden
  70754. */
  70755. protected _cameras: Camera[];
  70756. /** @hidden */
  70757. _name: string;
  70758. /**
  70759. * Gets pipeline name
  70760. */
  70761. get name(): string;
  70762. /** Gets the list of attached cameras */
  70763. get cameras(): Camera[];
  70764. /**
  70765. * Initializes a PostProcessRenderPipeline
  70766. * @param engine engine to add the pipeline to
  70767. * @param name name of the pipeline
  70768. */
  70769. constructor(engine: Engine, name: string);
  70770. /**
  70771. * Gets the class name
  70772. * @returns "PostProcessRenderPipeline"
  70773. */
  70774. getClassName(): string;
  70775. /**
  70776. * If all the render effects in the pipeline are supported
  70777. */
  70778. get isSupported(): boolean;
  70779. /**
  70780. * Adds an effect to the pipeline
  70781. * @param renderEffect the effect to add
  70782. */
  70783. addEffect(renderEffect: PostProcessRenderEffect): void;
  70784. /** @hidden */
  70785. _rebuild(): void;
  70786. /** @hidden */
  70787. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70788. /** @hidden */
  70789. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70790. /** @hidden */
  70791. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70792. /** @hidden */
  70793. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70794. /** @hidden */
  70795. _attachCameras(cameras: Camera, unique: boolean): void;
  70796. /** @hidden */
  70797. _attachCameras(cameras: Camera[], unique: boolean): void;
  70798. /** @hidden */
  70799. _detachCameras(cameras: Camera): void;
  70800. /** @hidden */
  70801. _detachCameras(cameras: Nullable<Camera[]>): void;
  70802. /** @hidden */
  70803. _update(): void;
  70804. /** @hidden */
  70805. _reset(): void;
  70806. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70807. /**
  70808. * Sets the required values to the prepass renderer.
  70809. * @param prePassRenderer defines the prepass renderer to setup.
  70810. * @returns true if the pre pass is needed.
  70811. */
  70812. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70813. /**
  70814. * Disposes of the pipeline
  70815. */
  70816. dispose(): void;
  70817. }
  70818. }
  70819. declare module BABYLON {
  70820. /**
  70821. * PostProcessRenderPipelineManager class
  70822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70823. */
  70824. export class PostProcessRenderPipelineManager {
  70825. private _renderPipelines;
  70826. /**
  70827. * Initializes a PostProcessRenderPipelineManager
  70828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70829. */
  70830. constructor();
  70831. /**
  70832. * Gets the list of supported render pipelines
  70833. */
  70834. get supportedPipelines(): PostProcessRenderPipeline[];
  70835. /**
  70836. * Adds a pipeline to the manager
  70837. * @param renderPipeline The pipeline to add
  70838. */
  70839. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70840. /**
  70841. * Attaches a camera to the pipeline
  70842. * @param renderPipelineName The name of the pipeline to attach to
  70843. * @param cameras the camera to attach
  70844. * @param unique if the camera can be attached multiple times to the pipeline
  70845. */
  70846. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70847. /**
  70848. * Detaches a camera from the pipeline
  70849. * @param renderPipelineName The name of the pipeline to detach from
  70850. * @param cameras the camera to detach
  70851. */
  70852. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70853. /**
  70854. * Enables an effect by name on a pipeline
  70855. * @param renderPipelineName the name of the pipeline to enable the effect in
  70856. * @param renderEffectName the name of the effect to enable
  70857. * @param cameras the cameras that the effect should be enabled on
  70858. */
  70859. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70860. /**
  70861. * Disables an effect by name on a pipeline
  70862. * @param renderPipelineName the name of the pipeline to disable the effect in
  70863. * @param renderEffectName the name of the effect to disable
  70864. * @param cameras the cameras that the effect should be disabled on
  70865. */
  70866. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70867. /**
  70868. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70869. */
  70870. update(): void;
  70871. /** @hidden */
  70872. _rebuild(): void;
  70873. /**
  70874. * Disposes of the manager and pipelines
  70875. */
  70876. dispose(): void;
  70877. }
  70878. }
  70879. declare module BABYLON {
  70880. interface Scene {
  70881. /** @hidden (Backing field) */
  70882. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70883. /**
  70884. * Gets the postprocess render pipeline manager
  70885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70886. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70887. */
  70888. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70889. }
  70890. /**
  70891. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70892. */
  70893. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70894. /**
  70895. * The component name helpfull to identify the component in the list of scene components.
  70896. */
  70897. readonly name: string;
  70898. /**
  70899. * The scene the component belongs to.
  70900. */
  70901. scene: Scene;
  70902. /**
  70903. * Creates a new instance of the component for the given scene
  70904. * @param scene Defines the scene to register the component in
  70905. */
  70906. constructor(scene: Scene);
  70907. /**
  70908. * Registers the component in a given scene
  70909. */
  70910. register(): void;
  70911. /**
  70912. * Rebuilds the elements related to this component in case of
  70913. * context lost for instance.
  70914. */
  70915. rebuild(): void;
  70916. /**
  70917. * Disposes the component and the associated ressources
  70918. */
  70919. dispose(): void;
  70920. private _gatherRenderTargets;
  70921. }
  70922. }
  70923. declare module BABYLON {
  70924. /**
  70925. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70926. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70927. */
  70928. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70929. private _scene;
  70930. private _camerasToBeAttached;
  70931. /**
  70932. * ID of the sharpen post process,
  70933. */
  70934. private readonly SharpenPostProcessId;
  70935. /**
  70936. * @ignore
  70937. * ID of the image processing post process;
  70938. */
  70939. readonly ImageProcessingPostProcessId: string;
  70940. /**
  70941. * @ignore
  70942. * ID of the Fast Approximate Anti-Aliasing post process;
  70943. */
  70944. readonly FxaaPostProcessId: string;
  70945. /**
  70946. * ID of the chromatic aberration post process,
  70947. */
  70948. private readonly ChromaticAberrationPostProcessId;
  70949. /**
  70950. * ID of the grain post process
  70951. */
  70952. private readonly GrainPostProcessId;
  70953. /**
  70954. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70955. */
  70956. sharpen: SharpenPostProcess;
  70957. private _sharpenEffect;
  70958. private bloom;
  70959. /**
  70960. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70961. */
  70962. depthOfField: DepthOfFieldEffect;
  70963. /**
  70964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70965. */
  70966. fxaa: FxaaPostProcess;
  70967. /**
  70968. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70969. */
  70970. imageProcessing: ImageProcessingPostProcess;
  70971. /**
  70972. * Chromatic aberration post process which will shift rgb colors in the image
  70973. */
  70974. chromaticAberration: ChromaticAberrationPostProcess;
  70975. private _chromaticAberrationEffect;
  70976. /**
  70977. * Grain post process which add noise to the image
  70978. */
  70979. grain: GrainPostProcess;
  70980. private _grainEffect;
  70981. /**
  70982. * Glow post process which adds a glow to emissive areas of the image
  70983. */
  70984. private _glowLayer;
  70985. /**
  70986. * Animations which can be used to tweak settings over a period of time
  70987. */
  70988. animations: Animation[];
  70989. private _imageProcessingConfigurationObserver;
  70990. private _sharpenEnabled;
  70991. private _bloomEnabled;
  70992. private _depthOfFieldEnabled;
  70993. private _depthOfFieldBlurLevel;
  70994. private _fxaaEnabled;
  70995. private _imageProcessingEnabled;
  70996. private _defaultPipelineTextureType;
  70997. private _bloomScale;
  70998. private _chromaticAberrationEnabled;
  70999. private _grainEnabled;
  71000. private _buildAllowed;
  71001. /**
  71002. * Gets active scene
  71003. */
  71004. get scene(): Scene;
  71005. /**
  71006. * Enable or disable the sharpen process from the pipeline
  71007. */
  71008. set sharpenEnabled(enabled: boolean);
  71009. get sharpenEnabled(): boolean;
  71010. private _resizeObserver;
  71011. private _hardwareScaleLevel;
  71012. private _bloomKernel;
  71013. /**
  71014. * Specifies the size of the bloom blur kernel, relative to the final output size
  71015. */
  71016. get bloomKernel(): number;
  71017. set bloomKernel(value: number);
  71018. /**
  71019. * Specifies the weight of the bloom in the final rendering
  71020. */
  71021. private _bloomWeight;
  71022. /**
  71023. * Specifies the luma threshold for the area that will be blurred by the bloom
  71024. */
  71025. private _bloomThreshold;
  71026. private _hdr;
  71027. /**
  71028. * The strength of the bloom.
  71029. */
  71030. set bloomWeight(value: number);
  71031. get bloomWeight(): number;
  71032. /**
  71033. * The strength of the bloom.
  71034. */
  71035. set bloomThreshold(value: number);
  71036. get bloomThreshold(): number;
  71037. /**
  71038. * The scale of the bloom, lower value will provide better performance.
  71039. */
  71040. set bloomScale(value: number);
  71041. get bloomScale(): number;
  71042. /**
  71043. * Enable or disable the bloom from the pipeline
  71044. */
  71045. set bloomEnabled(enabled: boolean);
  71046. get bloomEnabled(): boolean;
  71047. private _rebuildBloom;
  71048. /**
  71049. * If the depth of field is enabled.
  71050. */
  71051. get depthOfFieldEnabled(): boolean;
  71052. set depthOfFieldEnabled(enabled: boolean);
  71053. /**
  71054. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71055. */
  71056. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71057. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71058. /**
  71059. * If the anti aliasing is enabled.
  71060. */
  71061. set fxaaEnabled(enabled: boolean);
  71062. get fxaaEnabled(): boolean;
  71063. private _samples;
  71064. /**
  71065. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71066. */
  71067. set samples(sampleCount: number);
  71068. get samples(): number;
  71069. /**
  71070. * If image processing is enabled.
  71071. */
  71072. set imageProcessingEnabled(enabled: boolean);
  71073. get imageProcessingEnabled(): boolean;
  71074. /**
  71075. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71076. */
  71077. set glowLayerEnabled(enabled: boolean);
  71078. get glowLayerEnabled(): boolean;
  71079. /**
  71080. * Gets the glow layer (or null if not defined)
  71081. */
  71082. get glowLayer(): Nullable<GlowLayer>;
  71083. /**
  71084. * Enable or disable the chromaticAberration process from the pipeline
  71085. */
  71086. set chromaticAberrationEnabled(enabled: boolean);
  71087. get chromaticAberrationEnabled(): boolean;
  71088. /**
  71089. * Enable or disable the grain process from the pipeline
  71090. */
  71091. set grainEnabled(enabled: boolean);
  71092. get grainEnabled(): boolean;
  71093. /**
  71094. * @constructor
  71095. * @param name - The rendering pipeline name (default: "")
  71096. * @param hdr - If high dynamic range textures should be used (default: true)
  71097. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71098. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71099. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71100. */
  71101. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71102. /**
  71103. * Get the class name
  71104. * @returns "DefaultRenderingPipeline"
  71105. */
  71106. getClassName(): string;
  71107. /**
  71108. * Force the compilation of the entire pipeline.
  71109. */
  71110. prepare(): void;
  71111. private _hasCleared;
  71112. private _prevPostProcess;
  71113. private _prevPrevPostProcess;
  71114. private _setAutoClearAndTextureSharing;
  71115. private _depthOfFieldSceneObserver;
  71116. private _buildPipeline;
  71117. private _disposePostProcesses;
  71118. /**
  71119. * Adds a camera to the pipeline
  71120. * @param camera the camera to be added
  71121. */
  71122. addCamera(camera: Camera): void;
  71123. /**
  71124. * Removes a camera from the pipeline
  71125. * @param camera the camera to remove
  71126. */
  71127. removeCamera(camera: Camera): void;
  71128. /**
  71129. * Dispose of the pipeline and stop all post processes
  71130. */
  71131. dispose(): void;
  71132. /**
  71133. * Serialize the rendering pipeline (Used when exporting)
  71134. * @returns the serialized object
  71135. */
  71136. serialize(): any;
  71137. /**
  71138. * Parse the serialized pipeline
  71139. * @param source Source pipeline.
  71140. * @param scene The scene to load the pipeline to.
  71141. * @param rootUrl The URL of the serialized pipeline.
  71142. * @returns An instantiated pipeline from the serialized object.
  71143. */
  71144. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71145. }
  71146. }
  71147. declare module BABYLON {
  71148. /** @hidden */
  71149. export var lensHighlightsPixelShader: {
  71150. name: string;
  71151. shader: string;
  71152. };
  71153. }
  71154. declare module BABYLON {
  71155. /** @hidden */
  71156. export var depthOfFieldPixelShader: {
  71157. name: string;
  71158. shader: string;
  71159. };
  71160. }
  71161. declare module BABYLON {
  71162. /**
  71163. * BABYLON.JS Chromatic Aberration GLSL Shader
  71164. * Author: Olivier Guyot
  71165. * Separates very slightly R, G and B colors on the edges of the screen
  71166. * Inspired by Francois Tarlier & Martins Upitis
  71167. */
  71168. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71169. /**
  71170. * @ignore
  71171. * The chromatic aberration PostProcess id in the pipeline
  71172. */
  71173. LensChromaticAberrationEffect: string;
  71174. /**
  71175. * @ignore
  71176. * The highlights enhancing PostProcess id in the pipeline
  71177. */
  71178. HighlightsEnhancingEffect: string;
  71179. /**
  71180. * @ignore
  71181. * The depth-of-field PostProcess id in the pipeline
  71182. */
  71183. LensDepthOfFieldEffect: string;
  71184. private _scene;
  71185. private _depthTexture;
  71186. private _grainTexture;
  71187. private _chromaticAberrationPostProcess;
  71188. private _highlightsPostProcess;
  71189. private _depthOfFieldPostProcess;
  71190. private _edgeBlur;
  71191. private _grainAmount;
  71192. private _chromaticAberration;
  71193. private _distortion;
  71194. private _highlightsGain;
  71195. private _highlightsThreshold;
  71196. private _dofDistance;
  71197. private _dofAperture;
  71198. private _dofDarken;
  71199. private _dofPentagon;
  71200. private _blurNoise;
  71201. /**
  71202. * @constructor
  71203. *
  71204. * Effect parameters are as follow:
  71205. * {
  71206. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71207. * edge_blur: number; // from 0 to x (1 for realism)
  71208. * distortion: number; // from 0 to x (1 for realism)
  71209. * grain_amount: number; // from 0 to 1
  71210. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71211. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71212. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71213. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71214. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71215. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71216. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71217. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71218. * }
  71219. * Note: if an effect parameter is unset, effect is disabled
  71220. *
  71221. * @param name The rendering pipeline name
  71222. * @param parameters - An object containing all parameters (see above)
  71223. * @param scene The scene linked to this pipeline
  71224. * @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)
  71225. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71226. */
  71227. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71228. /**
  71229. * Get the class name
  71230. * @returns "LensRenderingPipeline"
  71231. */
  71232. getClassName(): string;
  71233. /**
  71234. * Gets associated scene
  71235. */
  71236. get scene(): Scene;
  71237. /**
  71238. * Gets or sets the edge blur
  71239. */
  71240. get edgeBlur(): number;
  71241. set edgeBlur(value: number);
  71242. /**
  71243. * Gets or sets the grain amount
  71244. */
  71245. get grainAmount(): number;
  71246. set grainAmount(value: number);
  71247. /**
  71248. * Gets or sets the chromatic aberration amount
  71249. */
  71250. get chromaticAberration(): number;
  71251. set chromaticAberration(value: number);
  71252. /**
  71253. * Gets or sets the depth of field aperture
  71254. */
  71255. get dofAperture(): number;
  71256. set dofAperture(value: number);
  71257. /**
  71258. * Gets or sets the edge distortion
  71259. */
  71260. get edgeDistortion(): number;
  71261. set edgeDistortion(value: number);
  71262. /**
  71263. * Gets or sets the depth of field distortion
  71264. */
  71265. get dofDistortion(): number;
  71266. set dofDistortion(value: number);
  71267. /**
  71268. * Gets or sets the darken out of focus amount
  71269. */
  71270. get darkenOutOfFocus(): number;
  71271. set darkenOutOfFocus(value: number);
  71272. /**
  71273. * Gets or sets a boolean indicating if blur noise is enabled
  71274. */
  71275. get blurNoise(): boolean;
  71276. set blurNoise(value: boolean);
  71277. /**
  71278. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71279. */
  71280. get pentagonBokeh(): boolean;
  71281. set pentagonBokeh(value: boolean);
  71282. /**
  71283. * Gets or sets the highlight grain amount
  71284. */
  71285. get highlightsGain(): number;
  71286. set highlightsGain(value: number);
  71287. /**
  71288. * Gets or sets the highlight threshold
  71289. */
  71290. get highlightsThreshold(): number;
  71291. set highlightsThreshold(value: number);
  71292. /**
  71293. * Sets the amount of blur at the edges
  71294. * @param amount blur amount
  71295. */
  71296. setEdgeBlur(amount: number): void;
  71297. /**
  71298. * Sets edge blur to 0
  71299. */
  71300. disableEdgeBlur(): void;
  71301. /**
  71302. * Sets the amout of grain
  71303. * @param amount Amount of grain
  71304. */
  71305. setGrainAmount(amount: number): void;
  71306. /**
  71307. * Set grain amount to 0
  71308. */
  71309. disableGrain(): void;
  71310. /**
  71311. * Sets the chromatic aberration amount
  71312. * @param amount amount of chromatic aberration
  71313. */
  71314. setChromaticAberration(amount: number): void;
  71315. /**
  71316. * Sets chromatic aberration amount to 0
  71317. */
  71318. disableChromaticAberration(): void;
  71319. /**
  71320. * Sets the EdgeDistortion amount
  71321. * @param amount amount of EdgeDistortion
  71322. */
  71323. setEdgeDistortion(amount: number): void;
  71324. /**
  71325. * Sets edge distortion to 0
  71326. */
  71327. disableEdgeDistortion(): void;
  71328. /**
  71329. * Sets the FocusDistance amount
  71330. * @param amount amount of FocusDistance
  71331. */
  71332. setFocusDistance(amount: number): void;
  71333. /**
  71334. * Disables depth of field
  71335. */
  71336. disableDepthOfField(): void;
  71337. /**
  71338. * Sets the Aperture amount
  71339. * @param amount amount of Aperture
  71340. */
  71341. setAperture(amount: number): void;
  71342. /**
  71343. * Sets the DarkenOutOfFocus amount
  71344. * @param amount amount of DarkenOutOfFocus
  71345. */
  71346. setDarkenOutOfFocus(amount: number): void;
  71347. private _pentagonBokehIsEnabled;
  71348. /**
  71349. * Creates a pentagon bokeh effect
  71350. */
  71351. enablePentagonBokeh(): void;
  71352. /**
  71353. * Disables the pentagon bokeh effect
  71354. */
  71355. disablePentagonBokeh(): void;
  71356. /**
  71357. * Enables noise blur
  71358. */
  71359. enableNoiseBlur(): void;
  71360. /**
  71361. * Disables noise blur
  71362. */
  71363. disableNoiseBlur(): void;
  71364. /**
  71365. * Sets the HighlightsGain amount
  71366. * @param amount amount of HighlightsGain
  71367. */
  71368. setHighlightsGain(amount: number): void;
  71369. /**
  71370. * Sets the HighlightsThreshold amount
  71371. * @param amount amount of HighlightsThreshold
  71372. */
  71373. setHighlightsThreshold(amount: number): void;
  71374. /**
  71375. * Disables highlights
  71376. */
  71377. disableHighlights(): void;
  71378. /**
  71379. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71380. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71381. */
  71382. dispose(disableDepthRender?: boolean): void;
  71383. private _createChromaticAberrationPostProcess;
  71384. private _createHighlightsPostProcess;
  71385. private _createDepthOfFieldPostProcess;
  71386. private _createGrainTexture;
  71387. }
  71388. }
  71389. declare module BABYLON {
  71390. /**
  71391. * Contains all parameters needed for the prepass to perform
  71392. * screen space subsurface scattering
  71393. */
  71394. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71395. /**
  71396. * Is subsurface enabled
  71397. */
  71398. enabled: boolean;
  71399. /**
  71400. * Name of the configuration
  71401. */
  71402. name: string;
  71403. /**
  71404. * Textures that should be present in the MRT for this effect to work
  71405. */
  71406. readonly texturesRequired: number[];
  71407. }
  71408. }
  71409. declare module BABYLON {
  71410. /** @hidden */
  71411. export var ssao2PixelShader: {
  71412. name: string;
  71413. shader: string;
  71414. };
  71415. }
  71416. declare module BABYLON {
  71417. /** @hidden */
  71418. export var ssaoCombinePixelShader: {
  71419. name: string;
  71420. shader: string;
  71421. };
  71422. }
  71423. declare module BABYLON {
  71424. /**
  71425. * Render pipeline to produce ssao effect
  71426. */
  71427. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71428. /**
  71429. * @ignore
  71430. * The PassPostProcess id in the pipeline that contains the original scene color
  71431. */
  71432. SSAOOriginalSceneColorEffect: string;
  71433. /**
  71434. * @ignore
  71435. * The SSAO PostProcess id in the pipeline
  71436. */
  71437. SSAORenderEffect: string;
  71438. /**
  71439. * @ignore
  71440. * The horizontal blur PostProcess id in the pipeline
  71441. */
  71442. SSAOBlurHRenderEffect: string;
  71443. /**
  71444. * @ignore
  71445. * The vertical blur PostProcess id in the pipeline
  71446. */
  71447. SSAOBlurVRenderEffect: string;
  71448. /**
  71449. * @ignore
  71450. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71451. */
  71452. SSAOCombineRenderEffect: string;
  71453. /**
  71454. * The output strength of the SSAO post-process. Default value is 1.0.
  71455. */
  71456. totalStrength: number;
  71457. /**
  71458. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71459. */
  71460. maxZ: number;
  71461. /**
  71462. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71463. */
  71464. minZAspect: number;
  71465. private _samples;
  71466. /**
  71467. * Number of samples used for the SSAO calculations. Default value is 8
  71468. */
  71469. set samples(n: number);
  71470. get samples(): number;
  71471. private _textureSamples;
  71472. /**
  71473. * Number of samples to use for antialiasing
  71474. */
  71475. set textureSamples(n: number);
  71476. get textureSamples(): number;
  71477. /**
  71478. * Force rendering the geometry through geometry buffer
  71479. */
  71480. private _forceGeometryBuffer;
  71481. /**
  71482. * Ratio object used for SSAO ratio and blur ratio
  71483. */
  71484. private _ratio;
  71485. /**
  71486. * Dynamically generated sphere sampler.
  71487. */
  71488. private _sampleSphere;
  71489. /**
  71490. * Blur filter offsets
  71491. */
  71492. private _samplerOffsets;
  71493. private _expensiveBlur;
  71494. /**
  71495. * If bilateral blur should be used
  71496. */
  71497. set expensiveBlur(b: boolean);
  71498. get expensiveBlur(): boolean;
  71499. /**
  71500. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71501. */
  71502. radius: number;
  71503. /**
  71504. * The base color of the SSAO post-process
  71505. * The final result is "base + ssao" between [0, 1]
  71506. */
  71507. base: number;
  71508. /**
  71509. * Support test.
  71510. */
  71511. static get IsSupported(): boolean;
  71512. private _scene;
  71513. private _randomTexture;
  71514. private _originalColorPostProcess;
  71515. private _ssaoPostProcess;
  71516. private _blurHPostProcess;
  71517. private _blurVPostProcess;
  71518. private _ssaoCombinePostProcess;
  71519. private _prePassRenderer;
  71520. /**
  71521. * Gets active scene
  71522. */
  71523. get scene(): Scene;
  71524. /**
  71525. * @constructor
  71526. * @param name The rendering pipeline name
  71527. * @param scene The scene linked to this pipeline
  71528. * @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 }
  71529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71530. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71531. */
  71532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71533. /**
  71534. * Get the class name
  71535. * @returns "SSAO2RenderingPipeline"
  71536. */
  71537. getClassName(): string;
  71538. /**
  71539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71540. */
  71541. dispose(disableGeometryBufferRenderer?: boolean): void;
  71542. private _createBlurPostProcess;
  71543. /** @hidden */
  71544. _rebuild(): void;
  71545. private _bits;
  71546. private _radicalInverse_VdC;
  71547. private _hammersley;
  71548. private _hemisphereSample_uniform;
  71549. private _generateHemisphere;
  71550. private _getDefinesForSSAO;
  71551. private _createSSAOPostProcess;
  71552. private _createSSAOCombinePostProcess;
  71553. private _createRandomTexture;
  71554. /**
  71555. * Serialize the rendering pipeline (Used when exporting)
  71556. * @returns the serialized object
  71557. */
  71558. serialize(): any;
  71559. /**
  71560. * Parse the serialized pipeline
  71561. * @param source Source pipeline.
  71562. * @param scene The scene to load the pipeline to.
  71563. * @param rootUrl The URL of the serialized pipeline.
  71564. * @returns An instantiated pipeline from the serialized object.
  71565. */
  71566. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71567. }
  71568. }
  71569. declare module BABYLON {
  71570. /** @hidden */
  71571. export var ssaoPixelShader: {
  71572. name: string;
  71573. shader: string;
  71574. };
  71575. }
  71576. declare module BABYLON {
  71577. /**
  71578. * Render pipeline to produce ssao effect
  71579. */
  71580. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71581. /**
  71582. * @ignore
  71583. * The PassPostProcess id in the pipeline that contains the original scene color
  71584. */
  71585. SSAOOriginalSceneColorEffect: string;
  71586. /**
  71587. * @ignore
  71588. * The SSAO PostProcess id in the pipeline
  71589. */
  71590. SSAORenderEffect: string;
  71591. /**
  71592. * @ignore
  71593. * The horizontal blur PostProcess id in the pipeline
  71594. */
  71595. SSAOBlurHRenderEffect: string;
  71596. /**
  71597. * @ignore
  71598. * The vertical blur PostProcess id in the pipeline
  71599. */
  71600. SSAOBlurVRenderEffect: string;
  71601. /**
  71602. * @ignore
  71603. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71604. */
  71605. SSAOCombineRenderEffect: string;
  71606. /**
  71607. * The output strength of the SSAO post-process. Default value is 1.0.
  71608. */
  71609. totalStrength: number;
  71610. /**
  71611. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71612. */
  71613. radius: number;
  71614. /**
  71615. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71616. * Must not be equal to fallOff and superior to fallOff.
  71617. * Default value is 0.0075
  71618. */
  71619. area: number;
  71620. /**
  71621. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71622. * Must not be equal to area and inferior to area.
  71623. * Default value is 0.000001
  71624. */
  71625. fallOff: number;
  71626. /**
  71627. * The base color of the SSAO post-process
  71628. * The final result is "base + ssao" between [0, 1]
  71629. */
  71630. base: number;
  71631. private _scene;
  71632. private _depthTexture;
  71633. private _randomTexture;
  71634. private _originalColorPostProcess;
  71635. private _ssaoPostProcess;
  71636. private _blurHPostProcess;
  71637. private _blurVPostProcess;
  71638. private _ssaoCombinePostProcess;
  71639. private _firstUpdate;
  71640. /**
  71641. * Gets active scene
  71642. */
  71643. get scene(): Scene;
  71644. /**
  71645. * @constructor
  71646. * @param name - The rendering pipeline name
  71647. * @param scene - The scene linked to this pipeline
  71648. * @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 }
  71649. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71650. */
  71651. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71652. /**
  71653. * Get the class name
  71654. * @returns "SSAORenderingPipeline"
  71655. */
  71656. getClassName(): string;
  71657. /**
  71658. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71659. */
  71660. dispose(disableDepthRender?: boolean): void;
  71661. private _createBlurPostProcess;
  71662. /** @hidden */
  71663. _rebuild(): void;
  71664. private _createSSAOPostProcess;
  71665. private _createSSAOCombinePostProcess;
  71666. private _createRandomTexture;
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. /**
  71671. * Contains all parameters needed for the prepass to perform
  71672. * screen space reflections
  71673. */
  71674. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71675. /**
  71676. * Is ssr enabled
  71677. */
  71678. enabled: boolean;
  71679. /**
  71680. * Name of the configuration
  71681. */
  71682. name: string;
  71683. /**
  71684. * Textures that should be present in the MRT for this effect to work
  71685. */
  71686. readonly texturesRequired: number[];
  71687. }
  71688. }
  71689. declare module BABYLON {
  71690. /** @hidden */
  71691. export var screenSpaceReflectionPixelShader: {
  71692. name: string;
  71693. shader: string;
  71694. };
  71695. }
  71696. declare module BABYLON {
  71697. /**
  71698. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71699. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71700. */
  71701. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71702. /**
  71703. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71704. */
  71705. threshold: number;
  71706. /**
  71707. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71708. */
  71709. strength: number;
  71710. /**
  71711. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71712. */
  71713. reflectionSpecularFalloffExponent: number;
  71714. /**
  71715. * 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]
  71716. */
  71717. step: number;
  71718. /**
  71719. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71720. */
  71721. roughnessFactor: number;
  71722. private _forceGeometryBuffer;
  71723. private _geometryBufferRenderer;
  71724. private _prePassRenderer;
  71725. private _enableSmoothReflections;
  71726. private _reflectionSamples;
  71727. private _smoothSteps;
  71728. /**
  71729. * Gets a string identifying the name of the class
  71730. * @returns "ScreenSpaceReflectionPostProcess" string
  71731. */
  71732. getClassName(): string;
  71733. /**
  71734. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71735. * @param name The name of the effect.
  71736. * @param scene The scene containing the objects to calculate reflections.
  71737. * @param options The required width/height ratio to downsize to before computing the render pass.
  71738. * @param camera The camera to apply the render pass to.
  71739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71740. * @param engine The engine which the post process will be applied. (default: current engine)
  71741. * @param reusable If the post process can be reused on the same frame. (default: false)
  71742. * @param textureType Type of textures used when performing the post process. (default: 0)
  71743. * @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)
  71744. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71745. */
  71746. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71747. /**
  71748. * Gets wether or not smoothing reflections is enabled.
  71749. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71750. */
  71751. get enableSmoothReflections(): boolean;
  71752. /**
  71753. * Sets wether or not smoothing reflections is enabled.
  71754. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71755. */
  71756. set enableSmoothReflections(enabled: boolean);
  71757. /**
  71758. * Gets the number of samples taken while computing reflections. More samples count is high,
  71759. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71760. */
  71761. get reflectionSamples(): number;
  71762. /**
  71763. * Sets the number of samples taken while computing reflections. More samples count is high,
  71764. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71765. */
  71766. set reflectionSamples(samples: number);
  71767. /**
  71768. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71769. * more the post-process will require GPU power and can generate a drop in FPS.
  71770. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71771. */
  71772. get smoothSteps(): number;
  71773. set smoothSteps(steps: number);
  71774. private _updateEffectDefines;
  71775. /** @hidden */
  71776. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71777. }
  71778. }
  71779. declare module BABYLON {
  71780. /** @hidden */
  71781. export var standardPixelShader: {
  71782. name: string;
  71783. shader: string;
  71784. };
  71785. }
  71786. declare module BABYLON {
  71787. /**
  71788. * Standard rendering pipeline
  71789. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71790. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71791. */
  71792. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71793. /**
  71794. * Public members
  71795. */
  71796. /**
  71797. * Post-process which contains the original scene color before the pipeline applies all the effects
  71798. */
  71799. originalPostProcess: Nullable<PostProcess>;
  71800. /**
  71801. * Post-process used to down scale an image x4
  71802. */
  71803. downSampleX4PostProcess: Nullable<PostProcess>;
  71804. /**
  71805. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71806. */
  71807. brightPassPostProcess: Nullable<PostProcess>;
  71808. /**
  71809. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71810. */
  71811. blurHPostProcesses: PostProcess[];
  71812. /**
  71813. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71814. */
  71815. blurVPostProcesses: PostProcess[];
  71816. /**
  71817. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71818. */
  71819. textureAdderPostProcess: Nullable<PostProcess>;
  71820. /**
  71821. * Post-process used to create volumetric lighting effect
  71822. */
  71823. volumetricLightPostProcess: Nullable<PostProcess>;
  71824. /**
  71825. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71826. */
  71827. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71828. /**
  71829. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71830. */
  71831. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71832. /**
  71833. * Post-process used to merge the volumetric light effect and the real scene color
  71834. */
  71835. volumetricLightMergePostProces: Nullable<PostProcess>;
  71836. /**
  71837. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71838. */
  71839. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71840. /**
  71841. * Base post-process used to calculate the average luminance of the final image for HDR
  71842. */
  71843. luminancePostProcess: Nullable<PostProcess>;
  71844. /**
  71845. * Post-processes used to create down sample post-processes in order to get
  71846. * the average luminance of the final image for HDR
  71847. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71848. */
  71849. luminanceDownSamplePostProcesses: PostProcess[];
  71850. /**
  71851. * Post-process used to create a HDR effect (light adaptation)
  71852. */
  71853. hdrPostProcess: Nullable<PostProcess>;
  71854. /**
  71855. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71856. */
  71857. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71858. /**
  71859. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71860. */
  71861. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71862. /**
  71863. * Post-process used to merge the final HDR post-process and the real scene color
  71864. */
  71865. hdrFinalPostProcess: Nullable<PostProcess>;
  71866. /**
  71867. * Post-process used to create a lens flare effect
  71868. */
  71869. lensFlarePostProcess: Nullable<PostProcess>;
  71870. /**
  71871. * Post-process that merges the result of the lens flare post-process and the real scene color
  71872. */
  71873. lensFlareComposePostProcess: Nullable<PostProcess>;
  71874. /**
  71875. * Post-process used to create a motion blur effect
  71876. */
  71877. motionBlurPostProcess: Nullable<PostProcess>;
  71878. /**
  71879. * Post-process used to create a depth of field effect
  71880. */
  71881. depthOfFieldPostProcess: Nullable<PostProcess>;
  71882. /**
  71883. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71884. */
  71885. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71886. /**
  71887. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71888. */
  71889. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71890. /**
  71891. * Represents the brightness threshold in order to configure the illuminated surfaces
  71892. */
  71893. brightThreshold: number;
  71894. /**
  71895. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71896. */
  71897. blurWidth: number;
  71898. /**
  71899. * Sets if the blur for highlighted surfaces must be only horizontal
  71900. */
  71901. horizontalBlur: boolean;
  71902. /**
  71903. * Gets the overall exposure used by the pipeline
  71904. */
  71905. get exposure(): number;
  71906. /**
  71907. * Sets the overall exposure used by the pipeline
  71908. */
  71909. set exposure(value: number);
  71910. /**
  71911. * Texture used typically to simulate "dirty" on camera lens
  71912. */
  71913. lensTexture: Nullable<Texture>;
  71914. /**
  71915. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71916. */
  71917. volumetricLightCoefficient: number;
  71918. /**
  71919. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71920. */
  71921. volumetricLightPower: number;
  71922. /**
  71923. * Used the set the blur intensity to smooth the volumetric lights
  71924. */
  71925. volumetricLightBlurScale: number;
  71926. /**
  71927. * Light (spot or directional) used to generate the volumetric lights rays
  71928. * The source light must have a shadow generate so the pipeline can get its
  71929. * depth map
  71930. */
  71931. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71932. /**
  71933. * For eye adaptation, represents the minimum luminance the eye can see
  71934. */
  71935. hdrMinimumLuminance: number;
  71936. /**
  71937. * For eye adaptation, represents the decrease luminance speed
  71938. */
  71939. hdrDecreaseRate: number;
  71940. /**
  71941. * For eye adaptation, represents the increase luminance speed
  71942. */
  71943. hdrIncreaseRate: number;
  71944. /**
  71945. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71946. */
  71947. get hdrAutoExposure(): boolean;
  71948. /**
  71949. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71950. */
  71951. set hdrAutoExposure(value: boolean);
  71952. /**
  71953. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71954. */
  71955. lensColorTexture: Nullable<Texture>;
  71956. /**
  71957. * The overall strengh for the lens flare effect
  71958. */
  71959. lensFlareStrength: number;
  71960. /**
  71961. * Dispersion coefficient for lens flare ghosts
  71962. */
  71963. lensFlareGhostDispersal: number;
  71964. /**
  71965. * Main lens flare halo width
  71966. */
  71967. lensFlareHaloWidth: number;
  71968. /**
  71969. * Based on the lens distortion effect, defines how much the lens flare result
  71970. * is distorted
  71971. */
  71972. lensFlareDistortionStrength: number;
  71973. /**
  71974. * Configures the blur intensity used for for lens flare (halo)
  71975. */
  71976. lensFlareBlurWidth: number;
  71977. /**
  71978. * Lens star texture must be used to simulate rays on the flares and is available
  71979. * in the documentation
  71980. */
  71981. lensStarTexture: Nullable<Texture>;
  71982. /**
  71983. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71984. * flare effect by taking account of the dirt texture
  71985. */
  71986. lensFlareDirtTexture: Nullable<Texture>;
  71987. /**
  71988. * Represents the focal length for the depth of field effect
  71989. */
  71990. depthOfFieldDistance: number;
  71991. /**
  71992. * Represents the blur intensity for the blurred part of the depth of field effect
  71993. */
  71994. depthOfFieldBlurWidth: number;
  71995. /**
  71996. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71997. */
  71998. get motionStrength(): number;
  71999. /**
  72000. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72001. */
  72002. set motionStrength(strength: number);
  72003. /**
  72004. * Gets wether or not the motion blur post-process is object based or screen based.
  72005. */
  72006. get objectBasedMotionBlur(): boolean;
  72007. /**
  72008. * Sets wether or not the motion blur post-process should be object based or screen based
  72009. */
  72010. set objectBasedMotionBlur(value: boolean);
  72011. /**
  72012. * List of animations for the pipeline (IAnimatable implementation)
  72013. */
  72014. animations: Animation[];
  72015. /**
  72016. * Private members
  72017. */
  72018. private _scene;
  72019. private _currentDepthOfFieldSource;
  72020. private _basePostProcess;
  72021. private _fixedExposure;
  72022. private _currentExposure;
  72023. private _hdrAutoExposure;
  72024. private _hdrCurrentLuminance;
  72025. private _motionStrength;
  72026. private _isObjectBasedMotionBlur;
  72027. private _floatTextureType;
  72028. private _camerasToBeAttached;
  72029. private _ratio;
  72030. private _bloomEnabled;
  72031. private _depthOfFieldEnabled;
  72032. private _vlsEnabled;
  72033. private _lensFlareEnabled;
  72034. private _hdrEnabled;
  72035. private _motionBlurEnabled;
  72036. private _fxaaEnabled;
  72037. private _screenSpaceReflectionsEnabled;
  72038. private _motionBlurSamples;
  72039. private _volumetricLightStepsCount;
  72040. private _samples;
  72041. /**
  72042. * @ignore
  72043. * Specifies if the bloom pipeline is enabled
  72044. */
  72045. get BloomEnabled(): boolean;
  72046. set BloomEnabled(enabled: boolean);
  72047. /**
  72048. * @ignore
  72049. * Specifies if the depth of field pipeline is enabed
  72050. */
  72051. get DepthOfFieldEnabled(): boolean;
  72052. set DepthOfFieldEnabled(enabled: boolean);
  72053. /**
  72054. * @ignore
  72055. * Specifies if the lens flare pipeline is enabed
  72056. */
  72057. get LensFlareEnabled(): boolean;
  72058. set LensFlareEnabled(enabled: boolean);
  72059. /**
  72060. * @ignore
  72061. * Specifies if the HDR pipeline is enabled
  72062. */
  72063. get HDREnabled(): boolean;
  72064. set HDREnabled(enabled: boolean);
  72065. /**
  72066. * @ignore
  72067. * Specifies if the volumetric lights scattering effect is enabled
  72068. */
  72069. get VLSEnabled(): boolean;
  72070. set VLSEnabled(enabled: boolean);
  72071. /**
  72072. * @ignore
  72073. * Specifies if the motion blur effect is enabled
  72074. */
  72075. get MotionBlurEnabled(): boolean;
  72076. set MotionBlurEnabled(enabled: boolean);
  72077. /**
  72078. * Specifies if anti-aliasing is enabled
  72079. */
  72080. get fxaaEnabled(): boolean;
  72081. set fxaaEnabled(enabled: boolean);
  72082. /**
  72083. * Specifies if screen space reflections are enabled.
  72084. */
  72085. get screenSpaceReflectionsEnabled(): boolean;
  72086. set screenSpaceReflectionsEnabled(enabled: boolean);
  72087. /**
  72088. * Specifies the number of steps used to calculate the volumetric lights
  72089. * Typically in interval [50, 200]
  72090. */
  72091. get volumetricLightStepsCount(): number;
  72092. set volumetricLightStepsCount(count: number);
  72093. /**
  72094. * Specifies the number of samples used for the motion blur effect
  72095. * Typically in interval [16, 64]
  72096. */
  72097. get motionBlurSamples(): number;
  72098. set motionBlurSamples(samples: number);
  72099. /**
  72100. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72101. */
  72102. get samples(): number;
  72103. set samples(sampleCount: number);
  72104. /**
  72105. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72106. * @constructor
  72107. * @param name The rendering pipeline name
  72108. * @param scene The scene linked to this pipeline
  72109. * @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)
  72110. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72111. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72112. */
  72113. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72114. private _buildPipeline;
  72115. private _createDownSampleX4PostProcess;
  72116. private _createBrightPassPostProcess;
  72117. private _createBlurPostProcesses;
  72118. private _createTextureAdderPostProcess;
  72119. private _createVolumetricLightPostProcess;
  72120. private _createLuminancePostProcesses;
  72121. private _createHdrPostProcess;
  72122. private _createLensFlarePostProcess;
  72123. private _createDepthOfFieldPostProcess;
  72124. private _createMotionBlurPostProcess;
  72125. private _getDepthTexture;
  72126. private _disposePostProcesses;
  72127. /**
  72128. * Dispose of the pipeline and stop all post processes
  72129. */
  72130. dispose(): void;
  72131. /**
  72132. * Serialize the rendering pipeline (Used when exporting)
  72133. * @returns the serialized object
  72134. */
  72135. serialize(): any;
  72136. /**
  72137. * Parse the serialized pipeline
  72138. * @param source Source pipeline.
  72139. * @param scene The scene to load the pipeline to.
  72140. * @param rootUrl The URL of the serialized pipeline.
  72141. * @returns An instantiated pipeline from the serialized object.
  72142. */
  72143. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72144. /**
  72145. * Luminance steps
  72146. */
  72147. static LuminanceSteps: number;
  72148. }
  72149. }
  72150. declare module BABYLON {
  72151. /** @hidden */
  72152. export var stereoscopicInterlacePixelShader: {
  72153. name: string;
  72154. shader: string;
  72155. };
  72156. }
  72157. declare module BABYLON {
  72158. /**
  72159. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72160. */
  72161. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72162. private _stepSize;
  72163. private _passedProcess;
  72164. /**
  72165. * Gets a string identifying the name of the class
  72166. * @returns "StereoscopicInterlacePostProcessI" string
  72167. */
  72168. getClassName(): string;
  72169. /**
  72170. * Initializes a StereoscopicInterlacePostProcessI
  72171. * @param name The name of the effect.
  72172. * @param rigCameras The rig cameras to be appled to the post process
  72173. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72174. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72176. * @param engine The engine which the post process will be applied. (default: current engine)
  72177. * @param reusable If the post process can be reused on the same frame. (default: false)
  72178. */
  72179. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72180. }
  72181. /**
  72182. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72183. */
  72184. export class StereoscopicInterlacePostProcess extends PostProcess {
  72185. private _stepSize;
  72186. private _passedProcess;
  72187. /**
  72188. * Gets a string identifying the name of the class
  72189. * @returns "StereoscopicInterlacePostProcess" string
  72190. */
  72191. getClassName(): string;
  72192. /**
  72193. * Initializes a StereoscopicInterlacePostProcess
  72194. * @param name The name of the effect.
  72195. * @param rigCameras The rig cameras to be appled to the post process
  72196. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72198. * @param engine The engine which the post process will be applied. (default: current engine)
  72199. * @param reusable If the post process can be reused on the same frame. (default: false)
  72200. */
  72201. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72202. }
  72203. }
  72204. declare module BABYLON {
  72205. /** @hidden */
  72206. export var tonemapPixelShader: {
  72207. name: string;
  72208. shader: string;
  72209. };
  72210. }
  72211. declare module BABYLON {
  72212. /** Defines operator used for tonemapping */
  72213. export enum TonemappingOperator {
  72214. /** Hable */
  72215. Hable = 0,
  72216. /** Reinhard */
  72217. Reinhard = 1,
  72218. /** HejiDawson */
  72219. HejiDawson = 2,
  72220. /** Photographic */
  72221. Photographic = 3
  72222. }
  72223. /**
  72224. * Defines a post process to apply tone mapping
  72225. */
  72226. export class TonemapPostProcess extends PostProcess {
  72227. private _operator;
  72228. /** Defines the required exposure adjustement */
  72229. exposureAdjustment: number;
  72230. /**
  72231. * Gets a string identifying the name of the class
  72232. * @returns "TonemapPostProcess" string
  72233. */
  72234. getClassName(): string;
  72235. /**
  72236. * Creates a new TonemapPostProcess
  72237. * @param name defines the name of the postprocess
  72238. * @param _operator defines the operator to use
  72239. * @param exposureAdjustment defines the required exposure adjustement
  72240. * @param camera defines the camera to use (can be null)
  72241. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72242. * @param engine defines the hosting engine (can be ignore if camera is set)
  72243. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72244. */
  72245. constructor(name: string, _operator: TonemappingOperator,
  72246. /** Defines the required exposure adjustement */
  72247. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72248. }
  72249. }
  72250. declare module BABYLON {
  72251. /** @hidden */
  72252. export var volumetricLightScatteringPixelShader: {
  72253. name: string;
  72254. shader: string;
  72255. };
  72256. }
  72257. declare module BABYLON {
  72258. /** @hidden */
  72259. export var volumetricLightScatteringPassVertexShader: {
  72260. name: string;
  72261. shader: string;
  72262. };
  72263. }
  72264. declare module BABYLON {
  72265. /** @hidden */
  72266. export var volumetricLightScatteringPassPixelShader: {
  72267. name: string;
  72268. shader: string;
  72269. };
  72270. }
  72271. declare module BABYLON {
  72272. /**
  72273. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72274. */
  72275. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72276. private _volumetricLightScatteringPass;
  72277. private _volumetricLightScatteringRTT;
  72278. private _viewPort;
  72279. private _screenCoordinates;
  72280. private _cachedDefines;
  72281. /**
  72282. * If not undefined, the mesh position is computed from the attached node position
  72283. */
  72284. attachedNode: {
  72285. position: Vector3;
  72286. };
  72287. /**
  72288. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72289. */
  72290. customMeshPosition: Vector3;
  72291. /**
  72292. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72293. */
  72294. useCustomMeshPosition: boolean;
  72295. /**
  72296. * If the post-process should inverse the light scattering direction
  72297. */
  72298. invert: boolean;
  72299. /**
  72300. * The internal mesh used by the post-process
  72301. */
  72302. mesh: Mesh;
  72303. /**
  72304. * @hidden
  72305. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72306. */
  72307. get useDiffuseColor(): boolean;
  72308. set useDiffuseColor(useDiffuseColor: boolean);
  72309. /**
  72310. * Array containing the excluded meshes not rendered in the internal pass
  72311. */
  72312. excludedMeshes: AbstractMesh[];
  72313. /**
  72314. * Controls the overall intensity of the post-process
  72315. */
  72316. exposure: number;
  72317. /**
  72318. * Dissipates each sample's contribution in range [0, 1]
  72319. */
  72320. decay: number;
  72321. /**
  72322. * Controls the overall intensity of each sample
  72323. */
  72324. weight: number;
  72325. /**
  72326. * Controls the density of each sample
  72327. */
  72328. density: number;
  72329. /**
  72330. * @constructor
  72331. * @param name The post-process name
  72332. * @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)
  72333. * @param camera The camera that the post-process will be attached to
  72334. * @param mesh The mesh used to create the light scattering
  72335. * @param samples The post-process quality, default 100
  72336. * @param samplingModeThe post-process filtering mode
  72337. * @param engine The babylon engine
  72338. * @param reusable If the post-process is reusable
  72339. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72340. */
  72341. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72342. /**
  72343. * Returns the string "VolumetricLightScatteringPostProcess"
  72344. * @returns "VolumetricLightScatteringPostProcess"
  72345. */
  72346. getClassName(): string;
  72347. private _isReady;
  72348. /**
  72349. * Sets the new light position for light scattering effect
  72350. * @param position The new custom light position
  72351. */
  72352. setCustomMeshPosition(position: Vector3): void;
  72353. /**
  72354. * Returns the light position for light scattering effect
  72355. * @return Vector3 The custom light position
  72356. */
  72357. getCustomMeshPosition(): Vector3;
  72358. /**
  72359. * Disposes the internal assets and detaches the post-process from the camera
  72360. */
  72361. dispose(camera: Camera): void;
  72362. /**
  72363. * Returns the render target texture used by the post-process
  72364. * @return the render target texture used by the post-process
  72365. */
  72366. getPass(): RenderTargetTexture;
  72367. private _meshExcluded;
  72368. private _createPass;
  72369. private _updateMeshScreenCoordinates;
  72370. /**
  72371. * Creates a default mesh for the Volumeric Light Scattering post-process
  72372. * @param name The mesh name
  72373. * @param scene The scene where to create the mesh
  72374. * @return the default mesh
  72375. */
  72376. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72377. }
  72378. }
  72379. declare module BABYLON {
  72380. /** @hidden */
  72381. export var screenSpaceCurvaturePixelShader: {
  72382. name: string;
  72383. shader: string;
  72384. };
  72385. }
  72386. declare module BABYLON {
  72387. /**
  72388. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72389. */
  72390. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72391. /**
  72392. * Defines how much ridge the curvature effect displays.
  72393. */
  72394. ridge: number;
  72395. /**
  72396. * Defines how much valley the curvature effect displays.
  72397. */
  72398. valley: number;
  72399. private _geometryBufferRenderer;
  72400. /**
  72401. * Gets a string identifying the name of the class
  72402. * @returns "ScreenSpaceCurvaturePostProcess" string
  72403. */
  72404. getClassName(): string;
  72405. /**
  72406. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72407. * @param name The name of the effect.
  72408. * @param scene The scene containing the objects to blur according to their velocity.
  72409. * @param options The required width/height ratio to downsize to before computing the render pass.
  72410. * @param camera The camera to apply the render pass to.
  72411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72412. * @param engine The engine which the post process will be applied. (default: current engine)
  72413. * @param reusable If the post process can be reused on the same frame. (default: false)
  72414. * @param textureType Type of textures used when performing the post process. (default: 0)
  72415. * @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)
  72416. */
  72417. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72418. /**
  72419. * Support test.
  72420. */
  72421. static get IsSupported(): boolean;
  72422. /** @hidden */
  72423. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72424. }
  72425. }
  72426. declare module BABYLON {
  72427. interface Scene {
  72428. /** @hidden (Backing field) */
  72429. _boundingBoxRenderer: BoundingBoxRenderer;
  72430. /** @hidden (Backing field) */
  72431. _forceShowBoundingBoxes: boolean;
  72432. /**
  72433. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72434. */
  72435. forceShowBoundingBoxes: boolean;
  72436. /**
  72437. * Gets the bounding box renderer associated with the scene
  72438. * @returns a BoundingBoxRenderer
  72439. */
  72440. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72441. }
  72442. interface AbstractMesh {
  72443. /** @hidden (Backing field) */
  72444. _showBoundingBox: boolean;
  72445. /**
  72446. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72447. */
  72448. showBoundingBox: boolean;
  72449. }
  72450. /**
  72451. * Component responsible of rendering the bounding box of the meshes in a scene.
  72452. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72453. */
  72454. export class BoundingBoxRenderer implements ISceneComponent {
  72455. /**
  72456. * The component name helpfull to identify the component in the list of scene components.
  72457. */
  72458. readonly name: string;
  72459. /**
  72460. * The scene the component belongs to.
  72461. */
  72462. scene: Scene;
  72463. /**
  72464. * Color of the bounding box lines placed in front of an object
  72465. */
  72466. frontColor: Color3;
  72467. /**
  72468. * Color of the bounding box lines placed behind an object
  72469. */
  72470. backColor: Color3;
  72471. /**
  72472. * Defines if the renderer should show the back lines or not
  72473. */
  72474. showBackLines: boolean;
  72475. /**
  72476. * Observable raised before rendering a bounding box
  72477. */
  72478. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72479. /**
  72480. * Observable raised after rendering a bounding box
  72481. */
  72482. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72483. /**
  72484. * @hidden
  72485. */
  72486. renderList: SmartArray<BoundingBox>;
  72487. private _colorShader;
  72488. private _vertexBuffers;
  72489. private _indexBuffer;
  72490. private _fillIndexBuffer;
  72491. private _fillIndexData;
  72492. /**
  72493. * Instantiates a new bounding box renderer in a scene.
  72494. * @param scene the scene the renderer renders in
  72495. */
  72496. constructor(scene: Scene);
  72497. /**
  72498. * Registers the component in a given scene
  72499. */
  72500. register(): void;
  72501. private _evaluateSubMesh;
  72502. private _activeMesh;
  72503. private _prepareRessources;
  72504. private _createIndexBuffer;
  72505. /**
  72506. * Rebuilds the elements related to this component in case of
  72507. * context lost for instance.
  72508. */
  72509. rebuild(): void;
  72510. /**
  72511. * @hidden
  72512. */
  72513. reset(): void;
  72514. /**
  72515. * Render the bounding boxes of a specific rendering group
  72516. * @param renderingGroupId defines the rendering group to render
  72517. */
  72518. render(renderingGroupId: number): void;
  72519. /**
  72520. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72521. * @param mesh Define the mesh to render the occlusion bounding box for
  72522. */
  72523. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72524. /**
  72525. * Dispose and release the resources attached to this renderer.
  72526. */
  72527. dispose(): void;
  72528. }
  72529. }
  72530. declare module BABYLON {
  72531. interface Scene {
  72532. /** @hidden (Backing field) */
  72533. _depthRenderer: {
  72534. [id: string]: DepthRenderer;
  72535. };
  72536. /**
  72537. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72538. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72539. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72540. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72541. * @returns the created depth renderer
  72542. */
  72543. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72544. /**
  72545. * Disables a depth renderer for a given camera
  72546. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72547. */
  72548. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72549. }
  72550. /**
  72551. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72552. * in several rendering techniques.
  72553. */
  72554. export class DepthRendererSceneComponent implements ISceneComponent {
  72555. /**
  72556. * The component name helpfull to identify the component in the list of scene components.
  72557. */
  72558. readonly name: string;
  72559. /**
  72560. * The scene the component belongs to.
  72561. */
  72562. scene: Scene;
  72563. /**
  72564. * Creates a new instance of the component for the given scene
  72565. * @param scene Defines the scene to register the component in
  72566. */
  72567. constructor(scene: Scene);
  72568. /**
  72569. * Registers the component in a given scene
  72570. */
  72571. register(): void;
  72572. /**
  72573. * Rebuilds the elements related to this component in case of
  72574. * context lost for instance.
  72575. */
  72576. rebuild(): void;
  72577. /**
  72578. * Disposes the component and the associated ressources
  72579. */
  72580. dispose(): void;
  72581. private _gatherRenderTargets;
  72582. private _gatherActiveCameraRenderTargets;
  72583. }
  72584. }
  72585. declare module BABYLON {
  72586. interface AbstractScene {
  72587. /** @hidden (Backing field) */
  72588. _prePassRenderer: Nullable<PrePassRenderer>;
  72589. /**
  72590. * Gets or Sets the current prepass renderer associated to the scene.
  72591. */
  72592. prePassRenderer: Nullable<PrePassRenderer>;
  72593. /**
  72594. * Enables the prepass and associates it with the scene
  72595. * @returns the PrePassRenderer
  72596. */
  72597. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72598. /**
  72599. * Disables the prepass associated with the scene
  72600. */
  72601. disablePrePassRenderer(): void;
  72602. }
  72603. /**
  72604. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72605. * in several rendering techniques.
  72606. */
  72607. export class PrePassRendererSceneComponent implements ISceneComponent {
  72608. /**
  72609. * The component name helpful to identify the component in the list of scene components.
  72610. */
  72611. readonly name: string;
  72612. /**
  72613. * The scene the component belongs to.
  72614. */
  72615. scene: Scene;
  72616. /**
  72617. * Creates a new instance of the component for the given scene
  72618. * @param scene Defines the scene to register the component in
  72619. */
  72620. constructor(scene: Scene);
  72621. /**
  72622. * Registers the component in a given scene
  72623. */
  72624. register(): void;
  72625. private _beforeCameraDraw;
  72626. private _afterCameraDraw;
  72627. private _beforeClearStage;
  72628. /**
  72629. * Rebuilds the elements related to this component in case of
  72630. * context lost for instance.
  72631. */
  72632. rebuild(): void;
  72633. /**
  72634. * Disposes the component and the associated ressources
  72635. */
  72636. dispose(): void;
  72637. }
  72638. }
  72639. declare module BABYLON {
  72640. /** @hidden */
  72641. export var fibonacci: {
  72642. name: string;
  72643. shader: string;
  72644. };
  72645. }
  72646. declare module BABYLON {
  72647. /** @hidden */
  72648. export var diffusionProfile: {
  72649. name: string;
  72650. shader: string;
  72651. };
  72652. }
  72653. declare module BABYLON {
  72654. /** @hidden */
  72655. export var subSurfaceScatteringPixelShader: {
  72656. name: string;
  72657. shader: string;
  72658. };
  72659. }
  72660. declare module BABYLON {
  72661. /**
  72662. * Sub surface scattering post process
  72663. */
  72664. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72665. /**
  72666. * Gets a string identifying the name of the class
  72667. * @returns "SubSurfaceScatteringPostProcess" string
  72668. */
  72669. getClassName(): string;
  72670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72671. }
  72672. }
  72673. declare module BABYLON {
  72674. /**
  72675. * Contains all parameters needed for the prepass to perform
  72676. * screen space subsurface scattering
  72677. */
  72678. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72679. /** @hidden */
  72680. static _SceneComponentInitialization: (scene: Scene) => void;
  72681. private _ssDiffusionS;
  72682. private _ssFilterRadii;
  72683. private _ssDiffusionD;
  72684. /**
  72685. * Post process to attach for screen space subsurface scattering
  72686. */
  72687. postProcess: SubSurfaceScatteringPostProcess;
  72688. /**
  72689. * Diffusion profile color for subsurface scattering
  72690. */
  72691. get ssDiffusionS(): number[];
  72692. /**
  72693. * Diffusion profile max color channel value for subsurface scattering
  72694. */
  72695. get ssDiffusionD(): number[];
  72696. /**
  72697. * Diffusion profile filter radius for subsurface scattering
  72698. */
  72699. get ssFilterRadii(): number[];
  72700. /**
  72701. * Is subsurface enabled
  72702. */
  72703. enabled: boolean;
  72704. /**
  72705. * Name of the configuration
  72706. */
  72707. name: string;
  72708. /**
  72709. * Diffusion profile colors for subsurface scattering
  72710. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72711. * See ...
  72712. * Note that you can only store up to 5 of them
  72713. */
  72714. ssDiffusionProfileColors: Color3[];
  72715. /**
  72716. * Defines the ratio real world => scene units.
  72717. * Used for subsurface scattering
  72718. */
  72719. metersPerUnit: number;
  72720. /**
  72721. * Textures that should be present in the MRT for this effect to work
  72722. */
  72723. readonly texturesRequired: number[];
  72724. private _scene;
  72725. /**
  72726. * Builds a subsurface configuration object
  72727. * @param scene The scene
  72728. */
  72729. constructor(scene: Scene);
  72730. /**
  72731. * Adds a new diffusion profile.
  72732. * Useful for more realistic subsurface scattering on diverse materials.
  72733. * @param color The color of the diffusion profile. Should be the average color of the material.
  72734. * @return The index of the diffusion profile for the material subsurface configuration
  72735. */
  72736. addDiffusionProfile(color: Color3): number;
  72737. /**
  72738. * Creates the sss post process
  72739. * @return The created post process
  72740. */
  72741. createPostProcess(): SubSurfaceScatteringPostProcess;
  72742. /**
  72743. * Deletes all diffusion profiles.
  72744. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72745. */
  72746. clearAllDiffusionProfiles(): void;
  72747. /**
  72748. * Disposes this object
  72749. */
  72750. dispose(): void;
  72751. /**
  72752. * @hidden
  72753. * https://zero-radiance.github.io/post/sampling-diffusion/
  72754. *
  72755. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72756. * ------------------------------------------------------------------------------------
  72757. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72758. * PDF[r, phi, s] = r * R[r, phi, s]
  72759. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72760. * ------------------------------------------------------------------------------------
  72761. * We importance sample the color channel with the widest scattering distance.
  72762. */
  72763. getDiffusionProfileParameters(color: Color3): number;
  72764. /**
  72765. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72766. * 'u' is the random number (the value of the CDF): [0, 1).
  72767. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72768. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72769. */
  72770. private _sampleBurleyDiffusionProfile;
  72771. }
  72772. }
  72773. declare module BABYLON {
  72774. interface AbstractScene {
  72775. /** @hidden (Backing field) */
  72776. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72777. /**
  72778. * Gets or Sets the current prepass renderer associated to the scene.
  72779. */
  72780. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72781. /**
  72782. * Enables the subsurface effect for prepass
  72783. * @returns the SubSurfaceConfiguration
  72784. */
  72785. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72786. /**
  72787. * Disables the subsurface effect for prepass
  72788. */
  72789. disableSubSurfaceForPrePass(): void;
  72790. }
  72791. /**
  72792. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72793. * in several rendering techniques.
  72794. */
  72795. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72796. /**
  72797. * The component name helpful to identify the component in the list of scene components.
  72798. */
  72799. readonly name: string;
  72800. /**
  72801. * The scene the component belongs to.
  72802. */
  72803. scene: Scene;
  72804. /**
  72805. * Creates a new instance of the component for the given scene
  72806. * @param scene Defines the scene to register the component in
  72807. */
  72808. constructor(scene: Scene);
  72809. /**
  72810. * Registers the component in a given scene
  72811. */
  72812. register(): void;
  72813. /**
  72814. * Serializes the component data to the specified json object
  72815. * @param serializationObject The object to serialize to
  72816. */
  72817. serialize(serializationObject: any): void;
  72818. /**
  72819. * Adds all the elements from the container to the scene
  72820. * @param container the container holding the elements
  72821. */
  72822. addFromContainer(container: AbstractScene): void;
  72823. /**
  72824. * Removes all the elements in the container from the scene
  72825. * @param container contains the elements to remove
  72826. * @param dispose if the removed element should be disposed (default: false)
  72827. */
  72828. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72829. /**
  72830. * Rebuilds the elements related to this component in case of
  72831. * context lost for instance.
  72832. */
  72833. rebuild(): void;
  72834. /**
  72835. * Disposes the component and the associated ressources
  72836. */
  72837. dispose(): void;
  72838. }
  72839. }
  72840. declare module BABYLON {
  72841. /** @hidden */
  72842. export var outlinePixelShader: {
  72843. name: string;
  72844. shader: string;
  72845. };
  72846. }
  72847. declare module BABYLON {
  72848. /** @hidden */
  72849. export var outlineVertexShader: {
  72850. name: string;
  72851. shader: string;
  72852. };
  72853. }
  72854. declare module BABYLON {
  72855. interface Scene {
  72856. /** @hidden */
  72857. _outlineRenderer: OutlineRenderer;
  72858. /**
  72859. * Gets the outline renderer associated with the scene
  72860. * @returns a OutlineRenderer
  72861. */
  72862. getOutlineRenderer(): OutlineRenderer;
  72863. }
  72864. interface AbstractMesh {
  72865. /** @hidden (Backing field) */
  72866. _renderOutline: boolean;
  72867. /**
  72868. * Gets or sets a boolean indicating if the outline must be rendered as well
  72869. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72870. */
  72871. renderOutline: boolean;
  72872. /** @hidden (Backing field) */
  72873. _renderOverlay: boolean;
  72874. /**
  72875. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72876. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72877. */
  72878. renderOverlay: boolean;
  72879. }
  72880. /**
  72881. * This class is responsible to draw bothe outline/overlay of meshes.
  72882. * It should not be used directly but through the available method on mesh.
  72883. */
  72884. export class OutlineRenderer implements ISceneComponent {
  72885. /**
  72886. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72887. */
  72888. private static _StencilReference;
  72889. /**
  72890. * The name of the component. Each component must have a unique name.
  72891. */
  72892. name: string;
  72893. /**
  72894. * The scene the component belongs to.
  72895. */
  72896. scene: Scene;
  72897. /**
  72898. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72899. */
  72900. zOffset: number;
  72901. private _engine;
  72902. private _effect;
  72903. private _cachedDefines;
  72904. private _savedDepthWrite;
  72905. /**
  72906. * Instantiates a new outline renderer. (There could be only one per scene).
  72907. * @param scene Defines the scene it belongs to
  72908. */
  72909. constructor(scene: Scene);
  72910. /**
  72911. * Register the component to one instance of a scene.
  72912. */
  72913. register(): void;
  72914. /**
  72915. * Rebuilds the elements related to this component in case of
  72916. * context lost for instance.
  72917. */
  72918. rebuild(): void;
  72919. /**
  72920. * Disposes the component and the associated ressources.
  72921. */
  72922. dispose(): void;
  72923. /**
  72924. * Renders the outline in the canvas.
  72925. * @param subMesh Defines the sumesh to render
  72926. * @param batch Defines the batch of meshes in case of instances
  72927. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72928. */
  72929. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72930. /**
  72931. * Returns whether or not the outline renderer is ready for a given submesh.
  72932. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72933. * @param subMesh Defines the submesh to check readyness for
  72934. * @param useInstances Defines wheter wee are trying to render instances or not
  72935. * @returns true if ready otherwise false
  72936. */
  72937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72938. private _beforeRenderingMesh;
  72939. private _afterRenderingMesh;
  72940. }
  72941. }
  72942. declare module BABYLON {
  72943. /**
  72944. * Defines the basic options interface of a Sprite Frame Source Size.
  72945. */
  72946. export interface ISpriteJSONSpriteSourceSize {
  72947. /**
  72948. * number of the original width of the Frame
  72949. */
  72950. w: number;
  72951. /**
  72952. * number of the original height of the Frame
  72953. */
  72954. h: number;
  72955. }
  72956. /**
  72957. * Defines the basic options interface of a Sprite Frame Data.
  72958. */
  72959. export interface ISpriteJSONSpriteFrameData {
  72960. /**
  72961. * number of the x offset of the Frame
  72962. */
  72963. x: number;
  72964. /**
  72965. * number of the y offset of the Frame
  72966. */
  72967. y: number;
  72968. /**
  72969. * number of the width of the Frame
  72970. */
  72971. w: number;
  72972. /**
  72973. * number of the height of the Frame
  72974. */
  72975. h: number;
  72976. }
  72977. /**
  72978. * Defines the basic options interface of a JSON Sprite.
  72979. */
  72980. export interface ISpriteJSONSprite {
  72981. /**
  72982. * string name of the Frame
  72983. */
  72984. filename: string;
  72985. /**
  72986. * ISpriteJSONSpriteFrame basic object of the frame data
  72987. */
  72988. frame: ISpriteJSONSpriteFrameData;
  72989. /**
  72990. * boolean to flag is the frame was rotated.
  72991. */
  72992. rotated: boolean;
  72993. /**
  72994. * boolean to flag is the frame was trimmed.
  72995. */
  72996. trimmed: boolean;
  72997. /**
  72998. * ISpriteJSONSpriteFrame basic object of the source data
  72999. */
  73000. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73001. /**
  73002. * ISpriteJSONSpriteFrame basic object of the source data
  73003. */
  73004. sourceSize: ISpriteJSONSpriteSourceSize;
  73005. }
  73006. /**
  73007. * Defines the basic options interface of a JSON atlas.
  73008. */
  73009. export interface ISpriteJSONAtlas {
  73010. /**
  73011. * Array of objects that contain the frame data.
  73012. */
  73013. frames: Array<ISpriteJSONSprite>;
  73014. /**
  73015. * object basic object containing the sprite meta data.
  73016. */
  73017. meta?: object;
  73018. }
  73019. }
  73020. declare module BABYLON {
  73021. /** @hidden */
  73022. export var spriteMapPixelShader: {
  73023. name: string;
  73024. shader: string;
  73025. };
  73026. }
  73027. declare module BABYLON {
  73028. /** @hidden */
  73029. export var spriteMapVertexShader: {
  73030. name: string;
  73031. shader: string;
  73032. };
  73033. }
  73034. declare module BABYLON {
  73035. /**
  73036. * Defines the basic options interface of a SpriteMap
  73037. */
  73038. export interface ISpriteMapOptions {
  73039. /**
  73040. * Vector2 of the number of cells in the grid.
  73041. */
  73042. stageSize?: Vector2;
  73043. /**
  73044. * Vector2 of the size of the output plane in World Units.
  73045. */
  73046. outputSize?: Vector2;
  73047. /**
  73048. * Vector3 of the position of the output plane in World Units.
  73049. */
  73050. outputPosition?: Vector3;
  73051. /**
  73052. * Vector3 of the rotation of the output plane.
  73053. */
  73054. outputRotation?: Vector3;
  73055. /**
  73056. * number of layers that the system will reserve in resources.
  73057. */
  73058. layerCount?: number;
  73059. /**
  73060. * number of max animation frames a single cell will reserve in resources.
  73061. */
  73062. maxAnimationFrames?: number;
  73063. /**
  73064. * number cell index of the base tile when the system compiles.
  73065. */
  73066. baseTile?: number;
  73067. /**
  73068. * boolean flip the sprite after its been repositioned by the framing data.
  73069. */
  73070. flipU?: boolean;
  73071. /**
  73072. * Vector3 scalar of the global RGB values of the SpriteMap.
  73073. */
  73074. colorMultiply?: Vector3;
  73075. }
  73076. /**
  73077. * Defines the IDisposable interface in order to be cleanable from resources.
  73078. */
  73079. export interface ISpriteMap extends IDisposable {
  73080. /**
  73081. * String name of the SpriteMap.
  73082. */
  73083. name: string;
  73084. /**
  73085. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73086. */
  73087. atlasJSON: ISpriteJSONAtlas;
  73088. /**
  73089. * Texture of the SpriteMap.
  73090. */
  73091. spriteSheet: Texture;
  73092. /**
  73093. * The parameters to initialize the SpriteMap with.
  73094. */
  73095. options: ISpriteMapOptions;
  73096. }
  73097. /**
  73098. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73099. */
  73100. export class SpriteMap implements ISpriteMap {
  73101. /** The Name of the spriteMap */
  73102. name: string;
  73103. /** The JSON file with the frame and meta data */
  73104. atlasJSON: ISpriteJSONAtlas;
  73105. /** The systems Sprite Sheet Texture */
  73106. spriteSheet: Texture;
  73107. /** Arguments passed with the Constructor */
  73108. options: ISpriteMapOptions;
  73109. /** Public Sprite Storage array, parsed from atlasJSON */
  73110. sprites: Array<ISpriteJSONSprite>;
  73111. /** Returns the Number of Sprites in the System */
  73112. get spriteCount(): number;
  73113. /** Returns the Position of Output Plane*/
  73114. get position(): Vector3;
  73115. /** Returns the Position of Output Plane*/
  73116. set position(v: Vector3);
  73117. /** Returns the Rotation of Output Plane*/
  73118. get rotation(): Vector3;
  73119. /** Returns the Rotation of Output Plane*/
  73120. set rotation(v: Vector3);
  73121. /** Sets the AnimationMap*/
  73122. get animationMap(): RawTexture;
  73123. /** Sets the AnimationMap*/
  73124. set animationMap(v: RawTexture);
  73125. /** Scene that the SpriteMap was created in */
  73126. private _scene;
  73127. /** Texture Buffer of Float32 that holds tile frame data*/
  73128. private _frameMap;
  73129. /** Texture Buffers of Float32 that holds tileMap data*/
  73130. private _tileMaps;
  73131. /** Texture Buffer of Float32 that holds Animation Data*/
  73132. private _animationMap;
  73133. /** Custom ShaderMaterial Central to the System*/
  73134. private _material;
  73135. /** Custom ShaderMaterial Central to the System*/
  73136. private _output;
  73137. /** Systems Time Ticker*/
  73138. private _time;
  73139. /**
  73140. * Creates a new SpriteMap
  73141. * @param name defines the SpriteMaps Name
  73142. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73143. * @param spriteSheet is the Texture that the Sprites are on.
  73144. * @param options a basic deployment configuration
  73145. * @param scene The Scene that the map is deployed on
  73146. */
  73147. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73148. /**
  73149. * Returns tileID location
  73150. * @returns Vector2 the cell position ID
  73151. */
  73152. getTileID(): Vector2;
  73153. /**
  73154. * Gets the UV location of the mouse over the SpriteMap.
  73155. * @returns Vector2 the UV position of the mouse interaction
  73156. */
  73157. getMousePosition(): Vector2;
  73158. /**
  73159. * Creates the "frame" texture Buffer
  73160. * -------------------------------------
  73161. * Structure of frames
  73162. * "filename": "Falling-Water-2.png",
  73163. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73164. * "rotated": true,
  73165. * "trimmed": true,
  73166. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73167. * "sourceSize": {"w":32,"h":32}
  73168. * @returns RawTexture of the frameMap
  73169. */
  73170. private _createFrameBuffer;
  73171. /**
  73172. * Creates the tileMap texture Buffer
  73173. * @param buffer normally and array of numbers, or a false to generate from scratch
  73174. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73175. * @returns RawTexture of the tileMap
  73176. */
  73177. private _createTileBuffer;
  73178. /**
  73179. * Modifies the data of the tileMaps
  73180. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73181. * @param pos is the iVector2 Coordinates of the Tile
  73182. * @param tile The SpriteIndex of the new Tile
  73183. */
  73184. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73185. /**
  73186. * Creates the animationMap texture Buffer
  73187. * @param buffer normally and array of numbers, or a false to generate from scratch
  73188. * @returns RawTexture of the animationMap
  73189. */
  73190. private _createTileAnimationBuffer;
  73191. /**
  73192. * Modifies the data of the animationMap
  73193. * @param cellID is the Index of the Sprite
  73194. * @param _frame is the target Animation frame
  73195. * @param toCell is the Target Index of the next frame of the animation
  73196. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73197. * @param speed is a global scalar of the time variable on the map.
  73198. */
  73199. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73200. /**
  73201. * Exports the .tilemaps file
  73202. */
  73203. saveTileMaps(): void;
  73204. /**
  73205. * Imports the .tilemaps file
  73206. * @param url of the .tilemaps file
  73207. */
  73208. loadTileMaps(url: string): void;
  73209. /**
  73210. * Release associated resources
  73211. */
  73212. dispose(): void;
  73213. }
  73214. }
  73215. declare module BABYLON {
  73216. /**
  73217. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73218. * @see https://doc.babylonjs.com/babylon101/sprites
  73219. */
  73220. export class SpritePackedManager extends SpriteManager {
  73221. /** defines the packed manager's name */
  73222. name: string;
  73223. /**
  73224. * Creates a new sprite manager from a packed sprite sheet
  73225. * @param name defines the manager's name
  73226. * @param imgUrl defines the sprite sheet url
  73227. * @param capacity defines the maximum allowed number of sprites
  73228. * @param scene defines the hosting scene
  73229. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73230. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73231. * @param samplingMode defines the smapling mode to use with spritesheet
  73232. * @param fromPacked set to true; do not alter
  73233. */
  73234. constructor(
  73235. /** defines the packed manager's name */
  73236. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73237. }
  73238. }
  73239. declare module BABYLON {
  73240. /**
  73241. * Defines the list of states available for a task inside a AssetsManager
  73242. */
  73243. export enum AssetTaskState {
  73244. /**
  73245. * Initialization
  73246. */
  73247. INIT = 0,
  73248. /**
  73249. * Running
  73250. */
  73251. RUNNING = 1,
  73252. /**
  73253. * Done
  73254. */
  73255. DONE = 2,
  73256. /**
  73257. * Error
  73258. */
  73259. ERROR = 3
  73260. }
  73261. /**
  73262. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73263. */
  73264. export abstract class AbstractAssetTask {
  73265. /**
  73266. * Task name
  73267. */ name: string;
  73268. /**
  73269. * Callback called when the task is successful
  73270. */
  73271. onSuccess: (task: any) => void;
  73272. /**
  73273. * Callback called when the task is not successful
  73274. */
  73275. onError: (task: any, message?: string, exception?: any) => void;
  73276. /**
  73277. * Creates a new AssetsManager
  73278. * @param name defines the name of the task
  73279. */
  73280. constructor(
  73281. /**
  73282. * Task name
  73283. */ name: string);
  73284. private _isCompleted;
  73285. private _taskState;
  73286. private _errorObject;
  73287. /**
  73288. * Get if the task is completed
  73289. */
  73290. get isCompleted(): boolean;
  73291. /**
  73292. * Gets the current state of the task
  73293. */
  73294. get taskState(): AssetTaskState;
  73295. /**
  73296. * Gets the current error object (if task is in error)
  73297. */
  73298. get errorObject(): {
  73299. message?: string;
  73300. exception?: any;
  73301. };
  73302. /**
  73303. * Internal only
  73304. * @hidden
  73305. */
  73306. _setErrorObject(message?: string, exception?: any): void;
  73307. /**
  73308. * Execute the current task
  73309. * @param scene defines the scene where you want your assets to be loaded
  73310. * @param onSuccess is a callback called when the task is successfully executed
  73311. * @param onError is a callback called if an error occurs
  73312. */
  73313. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73314. /**
  73315. * Execute the current task
  73316. * @param scene defines the scene where you want your assets to be loaded
  73317. * @param onSuccess is a callback called when the task is successfully executed
  73318. * @param onError is a callback called if an error occurs
  73319. */
  73320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73321. /**
  73322. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73323. * This can be used with failed tasks that have the reason for failure fixed.
  73324. */
  73325. reset(): void;
  73326. private onErrorCallback;
  73327. private onDoneCallback;
  73328. }
  73329. /**
  73330. * Define the interface used by progress events raised during assets loading
  73331. */
  73332. export interface IAssetsProgressEvent {
  73333. /**
  73334. * Defines the number of remaining tasks to process
  73335. */
  73336. remainingCount: number;
  73337. /**
  73338. * Defines the total number of tasks
  73339. */
  73340. totalCount: number;
  73341. /**
  73342. * Defines the task that was just processed
  73343. */
  73344. task: AbstractAssetTask;
  73345. }
  73346. /**
  73347. * Class used to share progress information about assets loading
  73348. */
  73349. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73350. /**
  73351. * Defines the number of remaining tasks to process
  73352. */
  73353. remainingCount: number;
  73354. /**
  73355. * Defines the total number of tasks
  73356. */
  73357. totalCount: number;
  73358. /**
  73359. * Defines the task that was just processed
  73360. */
  73361. task: AbstractAssetTask;
  73362. /**
  73363. * Creates a AssetsProgressEvent
  73364. * @param remainingCount defines the number of remaining tasks to process
  73365. * @param totalCount defines the total number of tasks
  73366. * @param task defines the task that was just processed
  73367. */
  73368. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73369. }
  73370. /**
  73371. * Define a task used by AssetsManager to load assets into a container
  73372. */
  73373. export class ContainerAssetTask extends AbstractAssetTask {
  73374. /**
  73375. * Defines the name of the task
  73376. */
  73377. name: string;
  73378. /**
  73379. * Defines the list of mesh's names you want to load
  73380. */
  73381. meshesNames: any;
  73382. /**
  73383. * Defines the root url to use as a base to load your meshes and associated resources
  73384. */
  73385. rootUrl: string;
  73386. /**
  73387. * Defines the filename or File of the scene to load from
  73388. */
  73389. sceneFilename: string | File;
  73390. /**
  73391. * Get the loaded asset container
  73392. */
  73393. loadedContainer: AssetContainer;
  73394. /**
  73395. * Gets the list of loaded meshes
  73396. */
  73397. loadedMeshes: Array<AbstractMesh>;
  73398. /**
  73399. * Gets the list of loaded particle systems
  73400. */
  73401. loadedParticleSystems: Array<IParticleSystem>;
  73402. /**
  73403. * Gets the list of loaded skeletons
  73404. */
  73405. loadedSkeletons: Array<Skeleton>;
  73406. /**
  73407. * Gets the list of loaded animation groups
  73408. */
  73409. loadedAnimationGroups: Array<AnimationGroup>;
  73410. /**
  73411. * Callback called when the task is successful
  73412. */
  73413. onSuccess: (task: ContainerAssetTask) => void;
  73414. /**
  73415. * Callback called when the task is successful
  73416. */
  73417. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73418. /**
  73419. * Creates a new ContainerAssetTask
  73420. * @param name defines the name of the task
  73421. * @param meshesNames defines the list of mesh's names you want to load
  73422. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73423. * @param sceneFilename defines the filename or File of the scene to load from
  73424. */
  73425. constructor(
  73426. /**
  73427. * Defines the name of the task
  73428. */
  73429. name: string,
  73430. /**
  73431. * Defines the list of mesh's names you want to load
  73432. */
  73433. meshesNames: any,
  73434. /**
  73435. * Defines the root url to use as a base to load your meshes and associated resources
  73436. */
  73437. rootUrl: string,
  73438. /**
  73439. * Defines the filename or File of the scene to load from
  73440. */
  73441. sceneFilename: string | File);
  73442. /**
  73443. * Execute the current task
  73444. * @param scene defines the scene where you want your assets to be loaded
  73445. * @param onSuccess is a callback called when the task is successfully executed
  73446. * @param onError is a callback called if an error occurs
  73447. */
  73448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73449. }
  73450. /**
  73451. * Define a task used by AssetsManager to load meshes
  73452. */
  73453. export class MeshAssetTask extends AbstractAssetTask {
  73454. /**
  73455. * Defines the name of the task
  73456. */
  73457. name: string;
  73458. /**
  73459. * Defines the list of mesh's names you want to load
  73460. */
  73461. meshesNames: any;
  73462. /**
  73463. * Defines the root url to use as a base to load your meshes and associated resources
  73464. */
  73465. rootUrl: string;
  73466. /**
  73467. * Defines the filename or File of the scene to load from
  73468. */
  73469. sceneFilename: string | File;
  73470. /**
  73471. * Gets the list of loaded meshes
  73472. */
  73473. loadedMeshes: Array<AbstractMesh>;
  73474. /**
  73475. * Gets the list of loaded particle systems
  73476. */
  73477. loadedParticleSystems: Array<IParticleSystem>;
  73478. /**
  73479. * Gets the list of loaded skeletons
  73480. */
  73481. loadedSkeletons: Array<Skeleton>;
  73482. /**
  73483. * Gets the list of loaded animation groups
  73484. */
  73485. loadedAnimationGroups: Array<AnimationGroup>;
  73486. /**
  73487. * Callback called when the task is successful
  73488. */
  73489. onSuccess: (task: MeshAssetTask) => void;
  73490. /**
  73491. * Callback called when the task is successful
  73492. */
  73493. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73494. /**
  73495. * Creates a new MeshAssetTask
  73496. * @param name defines the name of the task
  73497. * @param meshesNames defines the list of mesh's names you want to load
  73498. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73499. * @param sceneFilename defines the filename or File of the scene to load from
  73500. */
  73501. constructor(
  73502. /**
  73503. * Defines the name of the task
  73504. */
  73505. name: string,
  73506. /**
  73507. * Defines the list of mesh's names you want to load
  73508. */
  73509. meshesNames: any,
  73510. /**
  73511. * Defines the root url to use as a base to load your meshes and associated resources
  73512. */
  73513. rootUrl: string,
  73514. /**
  73515. * Defines the filename or File of the scene to load from
  73516. */
  73517. sceneFilename: string | File);
  73518. /**
  73519. * Execute the current task
  73520. * @param scene defines the scene where you want your assets to be loaded
  73521. * @param onSuccess is a callback called when the task is successfully executed
  73522. * @param onError is a callback called if an error occurs
  73523. */
  73524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73525. }
  73526. /**
  73527. * Define a task used by AssetsManager to load text content
  73528. */
  73529. export class TextFileAssetTask extends AbstractAssetTask {
  73530. /**
  73531. * Defines the name of the task
  73532. */
  73533. name: string;
  73534. /**
  73535. * Defines the location of the file to load
  73536. */
  73537. url: string;
  73538. /**
  73539. * Gets the loaded text string
  73540. */
  73541. text: string;
  73542. /**
  73543. * Callback called when the task is successful
  73544. */
  73545. onSuccess: (task: TextFileAssetTask) => void;
  73546. /**
  73547. * Callback called when the task is successful
  73548. */
  73549. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73550. /**
  73551. * Creates a new TextFileAssetTask object
  73552. * @param name defines the name of the task
  73553. * @param url defines the location of the file to load
  73554. */
  73555. constructor(
  73556. /**
  73557. * Defines the name of the task
  73558. */
  73559. name: string,
  73560. /**
  73561. * Defines the location of the file to load
  73562. */
  73563. url: string);
  73564. /**
  73565. * Execute the current task
  73566. * @param scene defines the scene where you want your assets to be loaded
  73567. * @param onSuccess is a callback called when the task is successfully executed
  73568. * @param onError is a callback called if an error occurs
  73569. */
  73570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73571. }
  73572. /**
  73573. * Define a task used by AssetsManager to load binary data
  73574. */
  73575. export class BinaryFileAssetTask extends AbstractAssetTask {
  73576. /**
  73577. * Defines the name of the task
  73578. */
  73579. name: string;
  73580. /**
  73581. * Defines the location of the file to load
  73582. */
  73583. url: string;
  73584. /**
  73585. * Gets the lodaded data (as an array buffer)
  73586. */
  73587. data: ArrayBuffer;
  73588. /**
  73589. * Callback called when the task is successful
  73590. */
  73591. onSuccess: (task: BinaryFileAssetTask) => void;
  73592. /**
  73593. * Callback called when the task is successful
  73594. */
  73595. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73596. /**
  73597. * Creates a new BinaryFileAssetTask object
  73598. * @param name defines the name of the new task
  73599. * @param url defines the location of the file to load
  73600. */
  73601. constructor(
  73602. /**
  73603. * Defines the name of the task
  73604. */
  73605. name: string,
  73606. /**
  73607. * Defines the location of the file to load
  73608. */
  73609. url: string);
  73610. /**
  73611. * Execute the current task
  73612. * @param scene defines the scene where you want your assets to be loaded
  73613. * @param onSuccess is a callback called when the task is successfully executed
  73614. * @param onError is a callback called if an error occurs
  73615. */
  73616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73617. }
  73618. /**
  73619. * Define a task used by AssetsManager to load images
  73620. */
  73621. export class ImageAssetTask extends AbstractAssetTask {
  73622. /**
  73623. * Defines the name of the task
  73624. */
  73625. name: string;
  73626. /**
  73627. * Defines the location of the image to load
  73628. */
  73629. url: string;
  73630. /**
  73631. * Gets the loaded images
  73632. */
  73633. image: HTMLImageElement;
  73634. /**
  73635. * Callback called when the task is successful
  73636. */
  73637. onSuccess: (task: ImageAssetTask) => void;
  73638. /**
  73639. * Callback called when the task is successful
  73640. */
  73641. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73642. /**
  73643. * Creates a new ImageAssetTask
  73644. * @param name defines the name of the task
  73645. * @param url defines the location of the image to load
  73646. */
  73647. constructor(
  73648. /**
  73649. * Defines the name of the task
  73650. */
  73651. name: string,
  73652. /**
  73653. * Defines the location of the image to load
  73654. */
  73655. url: string);
  73656. /**
  73657. * Execute the current task
  73658. * @param scene defines the scene where you want your assets to be loaded
  73659. * @param onSuccess is a callback called when the task is successfully executed
  73660. * @param onError is a callback called if an error occurs
  73661. */
  73662. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73663. }
  73664. /**
  73665. * Defines the interface used by texture loading tasks
  73666. */
  73667. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73668. /**
  73669. * Gets the loaded texture
  73670. */
  73671. texture: TEX;
  73672. }
  73673. /**
  73674. * Define a task used by AssetsManager to load 2D textures
  73675. */
  73676. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73677. /**
  73678. * Defines the name of the task
  73679. */
  73680. name: string;
  73681. /**
  73682. * Defines the location of the file to load
  73683. */
  73684. url: string;
  73685. /**
  73686. * Defines if mipmap should not be generated (default is false)
  73687. */
  73688. noMipmap?: boolean | undefined;
  73689. /**
  73690. * Defines if texture must be inverted on Y axis (default is true)
  73691. */
  73692. invertY: boolean;
  73693. /**
  73694. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73695. */
  73696. samplingMode: number;
  73697. /**
  73698. * Gets the loaded texture
  73699. */
  73700. texture: Texture;
  73701. /**
  73702. * Callback called when the task is successful
  73703. */
  73704. onSuccess: (task: TextureAssetTask) => void;
  73705. /**
  73706. * Callback called when the task is successful
  73707. */
  73708. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73709. /**
  73710. * Creates a new TextureAssetTask object
  73711. * @param name defines the name of the task
  73712. * @param url defines the location of the file to load
  73713. * @param noMipmap defines if mipmap should not be generated (default is false)
  73714. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73715. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73716. */
  73717. constructor(
  73718. /**
  73719. * Defines the name of the task
  73720. */
  73721. name: string,
  73722. /**
  73723. * Defines the location of the file to load
  73724. */
  73725. url: string,
  73726. /**
  73727. * Defines if mipmap should not be generated (default is false)
  73728. */
  73729. noMipmap?: boolean | undefined,
  73730. /**
  73731. * Defines if texture must be inverted on Y axis (default is true)
  73732. */
  73733. invertY?: boolean,
  73734. /**
  73735. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73736. */
  73737. samplingMode?: number);
  73738. /**
  73739. * Execute the current task
  73740. * @param scene defines the scene where you want your assets to be loaded
  73741. * @param onSuccess is a callback called when the task is successfully executed
  73742. * @param onError is a callback called if an error occurs
  73743. */
  73744. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73745. }
  73746. /**
  73747. * Define a task used by AssetsManager to load cube textures
  73748. */
  73749. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73750. /**
  73751. * Defines the name of the task
  73752. */
  73753. name: string;
  73754. /**
  73755. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73756. */
  73757. url: string;
  73758. /**
  73759. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73760. */
  73761. extensions?: string[] | undefined;
  73762. /**
  73763. * Defines if mipmaps should not be generated (default is false)
  73764. */
  73765. noMipmap?: boolean | undefined;
  73766. /**
  73767. * Defines the explicit list of files (undefined by default)
  73768. */
  73769. files?: string[] | undefined;
  73770. /**
  73771. * Gets the loaded texture
  73772. */
  73773. texture: CubeTexture;
  73774. /**
  73775. * Callback called when the task is successful
  73776. */
  73777. onSuccess: (task: CubeTextureAssetTask) => void;
  73778. /**
  73779. * Callback called when the task is successful
  73780. */
  73781. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73782. /**
  73783. * Creates a new CubeTextureAssetTask
  73784. * @param name defines the name of the task
  73785. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73786. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73787. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73788. * @param files defines the explicit list of files (undefined by default)
  73789. */
  73790. constructor(
  73791. /**
  73792. * Defines the name of the task
  73793. */
  73794. name: string,
  73795. /**
  73796. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73797. */
  73798. url: string,
  73799. /**
  73800. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73801. */
  73802. extensions?: string[] | undefined,
  73803. /**
  73804. * Defines if mipmaps should not be generated (default is false)
  73805. */
  73806. noMipmap?: boolean | undefined,
  73807. /**
  73808. * Defines the explicit list of files (undefined by default)
  73809. */
  73810. files?: string[] | undefined);
  73811. /**
  73812. * Execute the current task
  73813. * @param scene defines the scene where you want your assets to be loaded
  73814. * @param onSuccess is a callback called when the task is successfully executed
  73815. * @param onError is a callback called if an error occurs
  73816. */
  73817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73818. }
  73819. /**
  73820. * Define a task used by AssetsManager to load HDR cube textures
  73821. */
  73822. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73823. /**
  73824. * Defines the name of the task
  73825. */
  73826. name: string;
  73827. /**
  73828. * Defines the location of the file to load
  73829. */
  73830. url: string;
  73831. /**
  73832. * Defines the desired size (the more it increases the longer the generation will be)
  73833. */
  73834. size: number;
  73835. /**
  73836. * Defines if mipmaps should not be generated (default is false)
  73837. */
  73838. noMipmap: boolean;
  73839. /**
  73840. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73841. */
  73842. generateHarmonics: boolean;
  73843. /**
  73844. * 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)
  73845. */
  73846. gammaSpace: boolean;
  73847. /**
  73848. * Internal Use Only
  73849. */
  73850. reserved: boolean;
  73851. /**
  73852. * Gets the loaded texture
  73853. */
  73854. texture: HDRCubeTexture;
  73855. /**
  73856. * Callback called when the task is successful
  73857. */
  73858. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73859. /**
  73860. * Callback called when the task is successful
  73861. */
  73862. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73863. /**
  73864. * Creates a new HDRCubeTextureAssetTask object
  73865. * @param name defines the name of the task
  73866. * @param url defines the location of the file to load
  73867. * @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.
  73868. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73869. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73870. * @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)
  73871. * @param reserved Internal use only
  73872. */
  73873. constructor(
  73874. /**
  73875. * Defines the name of the task
  73876. */
  73877. name: string,
  73878. /**
  73879. * Defines the location of the file to load
  73880. */
  73881. url: string,
  73882. /**
  73883. * Defines the desired size (the more it increases the longer the generation will be)
  73884. */
  73885. size: number,
  73886. /**
  73887. * Defines if mipmaps should not be generated (default is false)
  73888. */
  73889. noMipmap?: boolean,
  73890. /**
  73891. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73892. */
  73893. generateHarmonics?: boolean,
  73894. /**
  73895. * 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)
  73896. */
  73897. gammaSpace?: boolean,
  73898. /**
  73899. * Internal Use Only
  73900. */
  73901. reserved?: boolean);
  73902. /**
  73903. * Execute the current task
  73904. * @param scene defines the scene where you want your assets to be loaded
  73905. * @param onSuccess is a callback called when the task is successfully executed
  73906. * @param onError is a callback called if an error occurs
  73907. */
  73908. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73909. }
  73910. /**
  73911. * Define a task used by AssetsManager to load Equirectangular cube textures
  73912. */
  73913. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73914. /**
  73915. * Defines the name of the task
  73916. */
  73917. name: string;
  73918. /**
  73919. * Defines the location of the file to load
  73920. */
  73921. url: string;
  73922. /**
  73923. * Defines the desired size (the more it increases the longer the generation will be)
  73924. */
  73925. size: number;
  73926. /**
  73927. * Defines if mipmaps should not be generated (default is false)
  73928. */
  73929. noMipmap: boolean;
  73930. /**
  73931. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73932. * but the standard material would require them in Gamma space) (default is true)
  73933. */
  73934. gammaSpace: boolean;
  73935. /**
  73936. * Gets the loaded texture
  73937. */
  73938. texture: EquiRectangularCubeTexture;
  73939. /**
  73940. * Callback called when the task is successful
  73941. */
  73942. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73943. /**
  73944. * Callback called when the task is successful
  73945. */
  73946. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73947. /**
  73948. * Creates a new EquiRectangularCubeTextureAssetTask object
  73949. * @param name defines the name of the task
  73950. * @param url defines the location of the file to load
  73951. * @param size defines the desired size (the more it increases the longer the generation will be)
  73952. * If the size is omitted this implies you are using a preprocessed cubemap.
  73953. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73954. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73955. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73956. * (default is true)
  73957. */
  73958. constructor(
  73959. /**
  73960. * Defines the name of the task
  73961. */
  73962. name: string,
  73963. /**
  73964. * Defines the location of the file to load
  73965. */
  73966. url: string,
  73967. /**
  73968. * Defines the desired size (the more it increases the longer the generation will be)
  73969. */
  73970. size: number,
  73971. /**
  73972. * Defines if mipmaps should not be generated (default is false)
  73973. */
  73974. noMipmap?: boolean,
  73975. /**
  73976. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73977. * but the standard material would require them in Gamma space) (default is true)
  73978. */
  73979. gammaSpace?: boolean);
  73980. /**
  73981. * Execute the current task
  73982. * @param scene defines the scene where you want your assets to be loaded
  73983. * @param onSuccess is a callback called when the task is successfully executed
  73984. * @param onError is a callback called if an error occurs
  73985. */
  73986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73987. }
  73988. /**
  73989. * This class can be used to easily import assets into a scene
  73990. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73991. */
  73992. export class AssetsManager {
  73993. private _scene;
  73994. private _isLoading;
  73995. protected _tasks: AbstractAssetTask[];
  73996. protected _waitingTasksCount: number;
  73997. protected _totalTasksCount: number;
  73998. /**
  73999. * Callback called when all tasks are processed
  74000. */
  74001. onFinish: (tasks: AbstractAssetTask[]) => void;
  74002. /**
  74003. * Callback called when a task is successful
  74004. */
  74005. onTaskSuccess: (task: AbstractAssetTask) => void;
  74006. /**
  74007. * Callback called when a task had an error
  74008. */
  74009. onTaskError: (task: AbstractAssetTask) => void;
  74010. /**
  74011. * Callback called when a task is done (whatever the result is)
  74012. */
  74013. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74014. /**
  74015. * Observable called when all tasks are processed
  74016. */
  74017. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74018. /**
  74019. * Observable called when a task had an error
  74020. */
  74021. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74022. /**
  74023. * Observable called when all tasks were executed
  74024. */
  74025. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74026. /**
  74027. * Observable called when a task is done (whatever the result is)
  74028. */
  74029. onProgressObservable: Observable<IAssetsProgressEvent>;
  74030. /**
  74031. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74032. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74033. */
  74034. useDefaultLoadingScreen: boolean;
  74035. /**
  74036. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74037. * when all assets have been downloaded.
  74038. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74039. */
  74040. autoHideLoadingUI: boolean;
  74041. /**
  74042. * Creates a new AssetsManager
  74043. * @param scene defines the scene to work on
  74044. */
  74045. constructor(scene: Scene);
  74046. /**
  74047. * Add a ContainerAssetTask to the list of active tasks
  74048. * @param taskName defines the name of the new task
  74049. * @param meshesNames defines the name of meshes to load
  74050. * @param rootUrl defines the root url to use to locate files
  74051. * @param sceneFilename defines the filename of the scene file
  74052. * @returns a new ContainerAssetTask object
  74053. */
  74054. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74055. /**
  74056. * Add a MeshAssetTask to the list of active tasks
  74057. * @param taskName defines the name of the new task
  74058. * @param meshesNames defines the name of meshes to load
  74059. * @param rootUrl defines the root url to use to locate files
  74060. * @param sceneFilename defines the filename of the scene file
  74061. * @returns a new MeshAssetTask object
  74062. */
  74063. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74064. /**
  74065. * Add a TextFileAssetTask to the list of active tasks
  74066. * @param taskName defines the name of the new task
  74067. * @param url defines the url of the file to load
  74068. * @returns a new TextFileAssetTask object
  74069. */
  74070. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74071. /**
  74072. * Add a BinaryFileAssetTask to the list of active tasks
  74073. * @param taskName defines the name of the new task
  74074. * @param url defines the url of the file to load
  74075. * @returns a new BinaryFileAssetTask object
  74076. */
  74077. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74078. /**
  74079. * Add a ImageAssetTask to the list of active tasks
  74080. * @param taskName defines the name of the new task
  74081. * @param url defines the url of the file to load
  74082. * @returns a new ImageAssetTask object
  74083. */
  74084. addImageTask(taskName: string, url: string): ImageAssetTask;
  74085. /**
  74086. * Add a TextureAssetTask to the list of active tasks
  74087. * @param taskName defines the name of the new task
  74088. * @param url defines the url of the file to load
  74089. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74090. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74091. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74092. * @returns a new TextureAssetTask object
  74093. */
  74094. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74095. /**
  74096. * Add a CubeTextureAssetTask to the list of active tasks
  74097. * @param taskName defines the name of the new task
  74098. * @param url defines the url of the file to load
  74099. * @param extensions defines the extension to use to load the cube map (can be null)
  74100. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74101. * @param files defines the list of files to load (can be null)
  74102. * @returns a new CubeTextureAssetTask object
  74103. */
  74104. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74105. /**
  74106. *
  74107. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74108. * @param taskName defines the name of the new task
  74109. * @param url defines the url of the file to load
  74110. * @param size defines the size you want for the cubemap (can be null)
  74111. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74112. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74113. * @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)
  74114. * @param reserved Internal use only
  74115. * @returns a new HDRCubeTextureAssetTask object
  74116. */
  74117. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74118. /**
  74119. *
  74120. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74121. * @param taskName defines the name of the new task
  74122. * @param url defines the url of the file to load
  74123. * @param size defines the size you want for the cubemap (can be null)
  74124. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74125. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74126. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74127. * @returns a new EquiRectangularCubeTextureAssetTask object
  74128. */
  74129. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74130. /**
  74131. * Remove a task from the assets manager.
  74132. * @param task the task to remove
  74133. */
  74134. removeTask(task: AbstractAssetTask): void;
  74135. private _decreaseWaitingTasksCount;
  74136. private _runTask;
  74137. /**
  74138. * Reset the AssetsManager and remove all tasks
  74139. * @return the current instance of the AssetsManager
  74140. */
  74141. reset(): AssetsManager;
  74142. /**
  74143. * Start the loading process
  74144. * @return the current instance of the AssetsManager
  74145. */
  74146. load(): AssetsManager;
  74147. /**
  74148. * Start the loading process as an async operation
  74149. * @return a promise returning the list of failed tasks
  74150. */
  74151. loadAsync(): Promise<void>;
  74152. }
  74153. }
  74154. declare module BABYLON {
  74155. /**
  74156. * Wrapper class for promise with external resolve and reject.
  74157. */
  74158. export class Deferred<T> {
  74159. /**
  74160. * The promise associated with this deferred object.
  74161. */
  74162. readonly promise: Promise<T>;
  74163. private _resolve;
  74164. private _reject;
  74165. /**
  74166. * The resolve method of the promise associated with this deferred object.
  74167. */
  74168. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74169. /**
  74170. * The reject method of the promise associated with this deferred object.
  74171. */
  74172. get reject(): (reason?: any) => void;
  74173. /**
  74174. * Constructor for this deferred object.
  74175. */
  74176. constructor();
  74177. }
  74178. }
  74179. declare module BABYLON {
  74180. /**
  74181. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74182. */
  74183. export class MeshExploder {
  74184. private _centerMesh;
  74185. private _meshes;
  74186. private _meshesOrigins;
  74187. private _toCenterVectors;
  74188. private _scaledDirection;
  74189. private _newPosition;
  74190. private _centerPosition;
  74191. /**
  74192. * Explodes meshes from a center mesh.
  74193. * @param meshes The meshes to explode.
  74194. * @param centerMesh The mesh to be center of explosion.
  74195. */
  74196. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74197. private _setCenterMesh;
  74198. /**
  74199. * Get class name
  74200. * @returns "MeshExploder"
  74201. */
  74202. getClassName(): string;
  74203. /**
  74204. * "Exploded meshes"
  74205. * @returns Array of meshes with the centerMesh at index 0.
  74206. */
  74207. getMeshes(): Array<Mesh>;
  74208. /**
  74209. * Explodes meshes giving a specific direction
  74210. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74211. */
  74212. explode(direction?: number): void;
  74213. }
  74214. }
  74215. declare module BABYLON {
  74216. /**
  74217. * Class used to help managing file picking and drag'n'drop
  74218. */
  74219. export class FilesInput {
  74220. /**
  74221. * List of files ready to be loaded
  74222. */
  74223. static get FilesToLoad(): {
  74224. [key: string]: File;
  74225. };
  74226. /**
  74227. * Callback called when a file is processed
  74228. */
  74229. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74230. private _engine;
  74231. private _currentScene;
  74232. private _sceneLoadedCallback;
  74233. private _progressCallback;
  74234. private _additionalRenderLoopLogicCallback;
  74235. private _textureLoadingCallback;
  74236. private _startingProcessingFilesCallback;
  74237. private _onReloadCallback;
  74238. private _errorCallback;
  74239. private _elementToMonitor;
  74240. private _sceneFileToLoad;
  74241. private _filesToLoad;
  74242. /**
  74243. * Creates a new FilesInput
  74244. * @param engine defines the rendering engine
  74245. * @param scene defines the hosting scene
  74246. * @param sceneLoadedCallback callback called when scene is loaded
  74247. * @param progressCallback callback called to track progress
  74248. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74249. * @param textureLoadingCallback callback called when a texture is loading
  74250. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74251. * @param onReloadCallback callback called when a reload is requested
  74252. * @param errorCallback callback call if an error occurs
  74253. */
  74254. 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>);
  74255. private _dragEnterHandler;
  74256. private _dragOverHandler;
  74257. private _dropHandler;
  74258. /**
  74259. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74260. * @param elementToMonitor defines the DOM element to track
  74261. */
  74262. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74263. /** Gets the current list of files to load */
  74264. get filesToLoad(): File[];
  74265. /**
  74266. * Release all associated resources
  74267. */
  74268. dispose(): void;
  74269. private renderFunction;
  74270. private drag;
  74271. private drop;
  74272. private _traverseFolder;
  74273. private _processFiles;
  74274. /**
  74275. * Load files from a drop event
  74276. * @param event defines the drop event to use as source
  74277. */
  74278. loadFiles(event: any): void;
  74279. private _processReload;
  74280. /**
  74281. * Reload the current scene from the loaded files
  74282. */
  74283. reload(): void;
  74284. }
  74285. }
  74286. declare module BABYLON {
  74287. /**
  74288. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74289. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74290. */
  74291. export class SceneOptimization {
  74292. /**
  74293. * Defines the priority of this optimization (0 by default which means first in the list)
  74294. */
  74295. priority: number;
  74296. /**
  74297. * Gets a string describing the action executed by the current optimization
  74298. * @returns description string
  74299. */
  74300. getDescription(): string;
  74301. /**
  74302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74303. * @param scene defines the current scene where to apply this optimization
  74304. * @param optimizer defines the current optimizer
  74305. * @returns true if everything that can be done was applied
  74306. */
  74307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74308. /**
  74309. * Creates the SceneOptimization object
  74310. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74311. * @param desc defines the description associated with the optimization
  74312. */
  74313. constructor(
  74314. /**
  74315. * Defines the priority of this optimization (0 by default which means first in the list)
  74316. */
  74317. priority?: number);
  74318. }
  74319. /**
  74320. * Defines an optimization used to reduce the size of render target textures
  74321. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74322. */
  74323. export class TextureOptimization extends SceneOptimization {
  74324. /**
  74325. * Defines the priority of this optimization (0 by default which means first in the list)
  74326. */
  74327. priority: number;
  74328. /**
  74329. * 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
  74330. */
  74331. maximumSize: number;
  74332. /**
  74333. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74334. */
  74335. step: number;
  74336. /**
  74337. * Gets a string describing the action executed by the current optimization
  74338. * @returns description string
  74339. */
  74340. getDescription(): string;
  74341. /**
  74342. * Creates the TextureOptimization object
  74343. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74344. * @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
  74345. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74346. */
  74347. constructor(
  74348. /**
  74349. * Defines the priority of this optimization (0 by default which means first in the list)
  74350. */
  74351. priority?: number,
  74352. /**
  74353. * 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
  74354. */
  74355. maximumSize?: number,
  74356. /**
  74357. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74358. */
  74359. step?: number);
  74360. /**
  74361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74362. * @param scene defines the current scene where to apply this optimization
  74363. * @param optimizer defines the current optimizer
  74364. * @returns true if everything that can be done was applied
  74365. */
  74366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74367. }
  74368. /**
  74369. * Defines an optimization used to increase or decrease the rendering resolution
  74370. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74371. */
  74372. export class HardwareScalingOptimization extends SceneOptimization {
  74373. /**
  74374. * Defines the priority of this optimization (0 by default which means first in the list)
  74375. */
  74376. priority: number;
  74377. /**
  74378. * Defines the maximum scale to use (2 by default)
  74379. */
  74380. maximumScale: number;
  74381. /**
  74382. * Defines the step to use between two passes (0.5 by default)
  74383. */
  74384. step: number;
  74385. private _currentScale;
  74386. private _directionOffset;
  74387. /**
  74388. * Gets a string describing the action executed by the current optimization
  74389. * @return description string
  74390. */
  74391. getDescription(): string;
  74392. /**
  74393. * Creates the HardwareScalingOptimization object
  74394. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74395. * @param maximumScale defines the maximum scale to use (2 by default)
  74396. * @param step defines the step to use between two passes (0.5 by default)
  74397. */
  74398. constructor(
  74399. /**
  74400. * Defines the priority of this optimization (0 by default which means first in the list)
  74401. */
  74402. priority?: number,
  74403. /**
  74404. * Defines the maximum scale to use (2 by default)
  74405. */
  74406. maximumScale?: number,
  74407. /**
  74408. * Defines the step to use between two passes (0.5 by default)
  74409. */
  74410. step?: number);
  74411. /**
  74412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74413. * @param scene defines the current scene where to apply this optimization
  74414. * @param optimizer defines the current optimizer
  74415. * @returns true if everything that can be done was applied
  74416. */
  74417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74418. }
  74419. /**
  74420. * Defines an optimization used to remove shadows
  74421. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74422. */
  74423. export class ShadowsOptimization extends SceneOptimization {
  74424. /**
  74425. * Gets a string describing the action executed by the current optimization
  74426. * @return description string
  74427. */
  74428. getDescription(): string;
  74429. /**
  74430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74431. * @param scene defines the current scene where to apply this optimization
  74432. * @param optimizer defines the current optimizer
  74433. * @returns true if everything that can be done was applied
  74434. */
  74435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74436. }
  74437. /**
  74438. * Defines an optimization used to turn post-processes off
  74439. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74440. */
  74441. export class PostProcessesOptimization extends SceneOptimization {
  74442. /**
  74443. * Gets a string describing the action executed by the current optimization
  74444. * @return description string
  74445. */
  74446. getDescription(): string;
  74447. /**
  74448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74449. * @param scene defines the current scene where to apply this optimization
  74450. * @param optimizer defines the current optimizer
  74451. * @returns true if everything that can be done was applied
  74452. */
  74453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74454. }
  74455. /**
  74456. * Defines an optimization used to turn lens flares off
  74457. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74458. */
  74459. export class LensFlaresOptimization extends SceneOptimization {
  74460. /**
  74461. * Gets a string describing the action executed by the current optimization
  74462. * @return description string
  74463. */
  74464. getDescription(): string;
  74465. /**
  74466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74467. * @param scene defines the current scene where to apply this optimization
  74468. * @param optimizer defines the current optimizer
  74469. * @returns true if everything that can be done was applied
  74470. */
  74471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74472. }
  74473. /**
  74474. * Defines an optimization based on user defined callback.
  74475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74476. */
  74477. export class CustomOptimization extends SceneOptimization {
  74478. /**
  74479. * Callback called to apply the custom optimization.
  74480. */
  74481. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74482. /**
  74483. * Callback called to get custom description
  74484. */
  74485. onGetDescription: () => string;
  74486. /**
  74487. * Gets a string describing the action executed by the current optimization
  74488. * @returns description string
  74489. */
  74490. getDescription(): string;
  74491. /**
  74492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74493. * @param scene defines the current scene where to apply this optimization
  74494. * @param optimizer defines the current optimizer
  74495. * @returns true if everything that can be done was applied
  74496. */
  74497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74498. }
  74499. /**
  74500. * Defines an optimization used to turn particles off
  74501. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74502. */
  74503. export class ParticlesOptimization extends SceneOptimization {
  74504. /**
  74505. * Gets a string describing the action executed by the current optimization
  74506. * @return description string
  74507. */
  74508. getDescription(): string;
  74509. /**
  74510. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74511. * @param scene defines the current scene where to apply this optimization
  74512. * @param optimizer defines the current optimizer
  74513. * @returns true if everything that can be done was applied
  74514. */
  74515. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74516. }
  74517. /**
  74518. * Defines an optimization used to turn render targets off
  74519. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74520. */
  74521. export class RenderTargetsOptimization extends SceneOptimization {
  74522. /**
  74523. * Gets a string describing the action executed by the current optimization
  74524. * @return description string
  74525. */
  74526. getDescription(): string;
  74527. /**
  74528. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74529. * @param scene defines the current scene where to apply this optimization
  74530. * @param optimizer defines the current optimizer
  74531. * @returns true if everything that can be done was applied
  74532. */
  74533. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74534. }
  74535. /**
  74536. * Defines an optimization used to merge meshes with compatible materials
  74537. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74538. */
  74539. export class MergeMeshesOptimization extends SceneOptimization {
  74540. private static _UpdateSelectionTree;
  74541. /**
  74542. * Gets or sets a boolean which defines if optimization octree has to be updated
  74543. */
  74544. static get UpdateSelectionTree(): boolean;
  74545. /**
  74546. * Gets or sets a boolean which defines if optimization octree has to be updated
  74547. */
  74548. static set UpdateSelectionTree(value: boolean);
  74549. /**
  74550. * Gets a string describing the action executed by the current optimization
  74551. * @return description string
  74552. */
  74553. getDescription(): string;
  74554. private _canBeMerged;
  74555. /**
  74556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74557. * @param scene defines the current scene where to apply this optimization
  74558. * @param optimizer defines the current optimizer
  74559. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74560. * @returns true if everything that can be done was applied
  74561. */
  74562. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74563. }
  74564. /**
  74565. * Defines a list of options used by SceneOptimizer
  74566. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74567. */
  74568. export class SceneOptimizerOptions {
  74569. /**
  74570. * Defines the target frame rate to reach (60 by default)
  74571. */
  74572. targetFrameRate: number;
  74573. /**
  74574. * Defines the interval between two checkes (2000ms by default)
  74575. */
  74576. trackerDuration: number;
  74577. /**
  74578. * Gets the list of optimizations to apply
  74579. */
  74580. optimizations: SceneOptimization[];
  74581. /**
  74582. * Creates a new list of options used by SceneOptimizer
  74583. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74584. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74585. */
  74586. constructor(
  74587. /**
  74588. * Defines the target frame rate to reach (60 by default)
  74589. */
  74590. targetFrameRate?: number,
  74591. /**
  74592. * Defines the interval between two checkes (2000ms by default)
  74593. */
  74594. trackerDuration?: number);
  74595. /**
  74596. * Add a new optimization
  74597. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74598. * @returns the current SceneOptimizerOptions
  74599. */
  74600. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74601. /**
  74602. * Add a new custom optimization
  74603. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74604. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74605. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74606. * @returns the current SceneOptimizerOptions
  74607. */
  74608. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74609. /**
  74610. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74611. * @param targetFrameRate defines the target frame rate (60 by default)
  74612. * @returns a SceneOptimizerOptions object
  74613. */
  74614. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74615. /**
  74616. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74617. * @param targetFrameRate defines the target frame rate (60 by default)
  74618. * @returns a SceneOptimizerOptions object
  74619. */
  74620. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74621. /**
  74622. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74623. * @param targetFrameRate defines the target frame rate (60 by default)
  74624. * @returns a SceneOptimizerOptions object
  74625. */
  74626. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74627. }
  74628. /**
  74629. * Class used to run optimizations in order to reach a target frame rate
  74630. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74631. */
  74632. export class SceneOptimizer implements IDisposable {
  74633. private _isRunning;
  74634. private _options;
  74635. private _scene;
  74636. private _currentPriorityLevel;
  74637. private _targetFrameRate;
  74638. private _trackerDuration;
  74639. private _currentFrameRate;
  74640. private _sceneDisposeObserver;
  74641. private _improvementMode;
  74642. /**
  74643. * Defines an observable called when the optimizer reaches the target frame rate
  74644. */
  74645. onSuccessObservable: Observable<SceneOptimizer>;
  74646. /**
  74647. * Defines an observable called when the optimizer enables an optimization
  74648. */
  74649. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74650. /**
  74651. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74652. */
  74653. onFailureObservable: Observable<SceneOptimizer>;
  74654. /**
  74655. * Gets a boolean indicating if the optimizer is in improvement mode
  74656. */
  74657. get isInImprovementMode(): boolean;
  74658. /**
  74659. * Gets the current priority level (0 at start)
  74660. */
  74661. get currentPriorityLevel(): number;
  74662. /**
  74663. * Gets the current frame rate checked by the SceneOptimizer
  74664. */
  74665. get currentFrameRate(): number;
  74666. /**
  74667. * Gets or sets the current target frame rate (60 by default)
  74668. */
  74669. get targetFrameRate(): number;
  74670. /**
  74671. * Gets or sets the current target frame rate (60 by default)
  74672. */
  74673. set targetFrameRate(value: number);
  74674. /**
  74675. * Gets or sets the current interval between two checks (every 2000ms by default)
  74676. */
  74677. get trackerDuration(): number;
  74678. /**
  74679. * Gets or sets the current interval between two checks (every 2000ms by default)
  74680. */
  74681. set trackerDuration(value: number);
  74682. /**
  74683. * Gets the list of active optimizations
  74684. */
  74685. get optimizations(): SceneOptimization[];
  74686. /**
  74687. * Creates a new SceneOptimizer
  74688. * @param scene defines the scene to work on
  74689. * @param options defines the options to use with the SceneOptimizer
  74690. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74691. * @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)
  74692. */
  74693. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74694. /**
  74695. * Stops the current optimizer
  74696. */
  74697. stop(): void;
  74698. /**
  74699. * Reset the optimizer to initial step (current priority level = 0)
  74700. */
  74701. reset(): void;
  74702. /**
  74703. * Start the optimizer. By default it will try to reach a specific framerate
  74704. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74705. */
  74706. start(): void;
  74707. private _checkCurrentState;
  74708. /**
  74709. * Release all resources
  74710. */
  74711. dispose(): void;
  74712. /**
  74713. * Helper function to create a SceneOptimizer with one single line of code
  74714. * @param scene defines the scene to work on
  74715. * @param options defines the options to use with the SceneOptimizer
  74716. * @param onSuccess defines a callback to call on success
  74717. * @param onFailure defines a callback to call on failure
  74718. * @returns the new SceneOptimizer object
  74719. */
  74720. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74721. }
  74722. }
  74723. declare module BABYLON {
  74724. /**
  74725. * Class used to serialize a scene into a string
  74726. */
  74727. export class SceneSerializer {
  74728. /**
  74729. * Clear cache used by a previous serialization
  74730. */
  74731. static ClearCache(): void;
  74732. /**
  74733. * Serialize a scene into a JSON compatible object
  74734. * @param scene defines the scene to serialize
  74735. * @returns a JSON compatible object
  74736. */
  74737. static Serialize(scene: Scene): any;
  74738. /**
  74739. * Serialize a mesh into a JSON compatible object
  74740. * @param toSerialize defines the mesh to serialize
  74741. * @param withParents defines if parents must be serialized as well
  74742. * @param withChildren defines if children must be serialized as well
  74743. * @returns a JSON compatible object
  74744. */
  74745. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74746. }
  74747. }
  74748. declare module BABYLON {
  74749. /**
  74750. * Class used to host texture specific utilities
  74751. */
  74752. export class TextureTools {
  74753. /**
  74754. * Uses the GPU to create a copy texture rescaled at a given size
  74755. * @param texture Texture to copy from
  74756. * @param width defines the desired width
  74757. * @param height defines the desired height
  74758. * @param useBilinearMode defines if bilinear mode has to be used
  74759. * @return the generated texture
  74760. */
  74761. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /**
  74766. * This represents the different options available for the video capture.
  74767. */
  74768. export interface VideoRecorderOptions {
  74769. /** Defines the mime type of the video. */
  74770. mimeType: string;
  74771. /** Defines the FPS the video should be recorded at. */
  74772. fps: number;
  74773. /** Defines the chunk size for the recording data. */
  74774. recordChunckSize: number;
  74775. /** The audio tracks to attach to the recording. */
  74776. audioTracks?: MediaStreamTrack[];
  74777. }
  74778. /**
  74779. * This can help with recording videos from BabylonJS.
  74780. * This is based on the available WebRTC functionalities of the browser.
  74781. *
  74782. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74783. */
  74784. export class VideoRecorder {
  74785. private static readonly _defaultOptions;
  74786. /**
  74787. * Returns whether or not the VideoRecorder is available in your browser.
  74788. * @param engine Defines the Babylon Engine.
  74789. * @returns true if supported otherwise false.
  74790. */
  74791. static IsSupported(engine: Engine): boolean;
  74792. private readonly _options;
  74793. private _canvas;
  74794. private _mediaRecorder;
  74795. private _recordedChunks;
  74796. private _fileName;
  74797. private _resolve;
  74798. private _reject;
  74799. /**
  74800. * True when a recording is already in progress.
  74801. */
  74802. get isRecording(): boolean;
  74803. /**
  74804. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74805. * @param engine Defines the BabylonJS Engine you wish to record.
  74806. * @param options Defines options that can be used to customize the capture.
  74807. */
  74808. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74809. /**
  74810. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74811. */
  74812. stopRecording(): void;
  74813. /**
  74814. * Starts recording the canvas for a max duration specified in parameters.
  74815. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74816. * If null no automatic download will start and you can rely on the promise to get the data back.
  74817. * @param maxDuration Defines the maximum recording time in seconds.
  74818. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74819. * @return A promise callback at the end of the recording with the video data in Blob.
  74820. */
  74821. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74822. /**
  74823. * Releases internal resources used during the recording.
  74824. */
  74825. dispose(): void;
  74826. private _handleDataAvailable;
  74827. private _handleError;
  74828. private _handleStop;
  74829. }
  74830. }
  74831. declare module BABYLON {
  74832. /**
  74833. * Class containing a set of static utilities functions for screenshots
  74834. */
  74835. export class ScreenshotTools {
  74836. /**
  74837. * Captures a screenshot of the current rendering
  74838. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74839. * @param engine defines the rendering engine
  74840. * @param camera defines the source camera
  74841. * @param size This parameter can be set to a single number or to an object with the
  74842. * following (optional) properties: precision, width, height. If a single number is passed,
  74843. * it will be used for both width and height. If an object is passed, the screenshot size
  74844. * will be derived from the parameters. The precision property is a multiplier allowing
  74845. * rendering at a higher or lower resolution
  74846. * @param successCallback defines the callback receives a single parameter which contains the
  74847. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74848. * src parameter of an <img> to display it
  74849. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74850. * Check your browser for supported MIME types
  74851. */
  74852. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74853. /**
  74854. * Captures a screenshot of the current rendering
  74855. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74856. * @param engine defines the rendering engine
  74857. * @param camera defines the source camera
  74858. * @param size This parameter can be set to a single number or to an object with the
  74859. * following (optional) properties: precision, width, height. If a single number is passed,
  74860. * it will be used for both width and height. If an object is passed, the screenshot size
  74861. * will be derived from the parameters. The precision property is a multiplier allowing
  74862. * rendering at a higher or lower resolution
  74863. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74864. * Check your browser for supported MIME types
  74865. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74866. * to the src parameter of an <img> to display it
  74867. */
  74868. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74869. /**
  74870. * Generates an image screenshot from the specified camera.
  74871. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74872. * @param engine The engine to use for rendering
  74873. * @param camera The camera to use for rendering
  74874. * @param size This parameter can be set to a single number or to an object with the
  74875. * following (optional) properties: precision, width, height. If a single number is passed,
  74876. * it will be used for both width and height. If an object is passed, the screenshot size
  74877. * will be derived from the parameters. The precision property is a multiplier allowing
  74878. * rendering at a higher or lower resolution
  74879. * @param successCallback The callback receives a single parameter which contains the
  74880. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74881. * src parameter of an <img> to display it
  74882. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74883. * Check your browser for supported MIME types
  74884. * @param samples Texture samples (default: 1)
  74885. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74886. * @param fileName A name for for the downloaded file.
  74887. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74888. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74889. */
  74890. 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;
  74891. /**
  74892. * Generates an image screenshot from the specified camera.
  74893. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74894. * @param engine The engine to use for rendering
  74895. * @param camera The camera to use for rendering
  74896. * @param size This parameter can be set to a single number or to an object with the
  74897. * following (optional) properties: precision, width, height. If a single number is passed,
  74898. * it will be used for both width and height. If an object is passed, the screenshot size
  74899. * will be derived from the parameters. The precision property is a multiplier allowing
  74900. * rendering at a higher or lower resolution
  74901. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74902. * Check your browser for supported MIME types
  74903. * @param samples Texture samples (default: 1)
  74904. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74905. * @param fileName A name for for the downloaded file.
  74906. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74907. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74908. * to the src parameter of an <img> to display it
  74909. */
  74910. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74911. /**
  74912. * Gets height and width for screenshot size
  74913. * @private
  74914. */
  74915. private static _getScreenshotSize;
  74916. }
  74917. }
  74918. declare module BABYLON {
  74919. /**
  74920. * Interface for a data buffer
  74921. */
  74922. export interface IDataBuffer {
  74923. /**
  74924. * Reads bytes from the data buffer.
  74925. * @param byteOffset The byte offset to read
  74926. * @param byteLength The byte length to read
  74927. * @returns A promise that resolves when the bytes are read
  74928. */
  74929. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74930. /**
  74931. * The byte length of the buffer.
  74932. */
  74933. readonly byteLength: number;
  74934. }
  74935. /**
  74936. * Utility class for reading from a data buffer
  74937. */
  74938. export class DataReader {
  74939. /**
  74940. * The data buffer associated with this data reader.
  74941. */
  74942. readonly buffer: IDataBuffer;
  74943. /**
  74944. * The current byte offset from the beginning of the data buffer.
  74945. */
  74946. byteOffset: number;
  74947. private _dataView;
  74948. private _dataByteOffset;
  74949. /**
  74950. * Constructor
  74951. * @param buffer The buffer to read
  74952. */
  74953. constructor(buffer: IDataBuffer);
  74954. /**
  74955. * Loads the given byte length.
  74956. * @param byteLength The byte length to load
  74957. * @returns A promise that resolves when the load is complete
  74958. */
  74959. loadAsync(byteLength: number): Promise<void>;
  74960. /**
  74961. * Read a unsigned 32-bit integer from the currently loaded data range.
  74962. * @returns The 32-bit integer read
  74963. */
  74964. readUint32(): number;
  74965. /**
  74966. * Read a byte array from the currently loaded data range.
  74967. * @param byteLength The byte length to read
  74968. * @returns The byte array read
  74969. */
  74970. readUint8Array(byteLength: number): Uint8Array;
  74971. /**
  74972. * Read a string from the currently loaded data range.
  74973. * @param byteLength The byte length to read
  74974. * @returns The string read
  74975. */
  74976. readString(byteLength: number): string;
  74977. /**
  74978. * Skips the given byte length the currently loaded data range.
  74979. * @param byteLength The byte length to skip
  74980. */
  74981. skipBytes(byteLength: number): void;
  74982. }
  74983. }
  74984. declare module BABYLON {
  74985. /**
  74986. * Class for storing data to local storage if available or in-memory storage otherwise
  74987. */
  74988. export class DataStorage {
  74989. private static _Storage;
  74990. private static _GetStorage;
  74991. /**
  74992. * Reads a string from the data storage
  74993. * @param key The key to read
  74994. * @param defaultValue The value if the key doesn't exist
  74995. * @returns The string value
  74996. */
  74997. static ReadString(key: string, defaultValue: string): string;
  74998. /**
  74999. * Writes a string to the data storage
  75000. * @param key The key to write
  75001. * @param value The value to write
  75002. */
  75003. static WriteString(key: string, value: string): void;
  75004. /**
  75005. * Reads a boolean from the data storage
  75006. * @param key The key to read
  75007. * @param defaultValue The value if the key doesn't exist
  75008. * @returns The boolean value
  75009. */
  75010. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75011. /**
  75012. * Writes a boolean to the data storage
  75013. * @param key The key to write
  75014. * @param value The value to write
  75015. */
  75016. static WriteBoolean(key: string, value: boolean): void;
  75017. /**
  75018. * Reads a number from the data storage
  75019. * @param key The key to read
  75020. * @param defaultValue The value if the key doesn't exist
  75021. * @returns The number value
  75022. */
  75023. static ReadNumber(key: string, defaultValue: number): number;
  75024. /**
  75025. * Writes a number to the data storage
  75026. * @param key The key to write
  75027. * @param value The value to write
  75028. */
  75029. static WriteNumber(key: string, value: number): void;
  75030. }
  75031. }
  75032. declare module BABYLON {
  75033. /**
  75034. * Class used to record delta files between 2 scene states
  75035. */
  75036. export class SceneRecorder {
  75037. private _trackedScene;
  75038. private _savedJSON;
  75039. /**
  75040. * Track a given scene. This means the current scene state will be considered the original state
  75041. * @param scene defines the scene to track
  75042. */
  75043. track(scene: Scene): void;
  75044. /**
  75045. * Get the delta between current state and original state
  75046. * @returns a string containing the delta
  75047. */
  75048. getDelta(): any;
  75049. private _compareArray;
  75050. private _compareObjects;
  75051. private _compareCollections;
  75052. private static GetShadowGeneratorById;
  75053. /**
  75054. * Apply a given delta to a given scene
  75055. * @param deltaJSON defines the JSON containing the delta
  75056. * @param scene defines the scene to apply the delta to
  75057. */
  75058. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75059. private static _ApplyPropertiesToEntity;
  75060. private static _ApplyDeltaForEntity;
  75061. }
  75062. }
  75063. declare module BABYLON {
  75064. /**
  75065. * A 3D trajectory consisting of an order list of vectors describing a
  75066. * path of motion through 3D space.
  75067. */
  75068. export class Trajectory {
  75069. private _points;
  75070. private readonly _segmentLength;
  75071. /**
  75072. * Serialize to JSON.
  75073. * @returns serialized JSON string
  75074. */
  75075. serialize(): string;
  75076. /**
  75077. * Deserialize from JSON.
  75078. * @param json serialized JSON string
  75079. * @returns deserialized Trajectory
  75080. */
  75081. static Deserialize(json: string): Trajectory;
  75082. /**
  75083. * Create a new empty Trajectory.
  75084. * @param segmentLength radius of discretization for Trajectory points
  75085. */
  75086. constructor(segmentLength?: number);
  75087. /**
  75088. * Get the length of the Trajectory.
  75089. * @returns length of the Trajectory
  75090. */
  75091. getLength(): number;
  75092. /**
  75093. * Append a new point to the Trajectory.
  75094. * NOTE: This implementation has many allocations.
  75095. * @param point point to append to the Trajectory
  75096. */
  75097. add(point: DeepImmutable<Vector3>): void;
  75098. /**
  75099. * Create a new Trajectory with a segment length chosen to make it
  75100. * probable that the new Trajectory will have a specified number of
  75101. * segments. This operation is imprecise.
  75102. * @param targetResolution number of segments desired
  75103. * @returns new Trajectory with approximately the requested number of segments
  75104. */
  75105. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75106. /**
  75107. * Convert Trajectory segments into tokenized representation. This
  75108. * representation is an array of numbers where each nth number is the
  75109. * index of the token which is most similar to the nth segment of the
  75110. * Trajectory.
  75111. * @param tokens list of vectors which serve as discrete tokens
  75112. * @returns list of indices of most similar token per segment
  75113. */
  75114. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75115. private static _forwardDir;
  75116. private static _inverseFromVec;
  75117. private static _upDir;
  75118. private static _fromToVec;
  75119. private static _lookMatrix;
  75120. /**
  75121. * Transform the rotation (i.e., direction) of a segment to isolate
  75122. * the relative transformation represented by the segment. This operation
  75123. * may or may not succeed due to singularities in the equations that define
  75124. * motion relativity in this context.
  75125. * @param priorVec the origin of the prior segment
  75126. * @param fromVec the origin of the current segment
  75127. * @param toVec the destination of the current segment
  75128. * @param result reference to output variable
  75129. * @returns whether or not transformation was successful
  75130. */
  75131. private static _transformSegmentDirToRef;
  75132. private static _bestMatch;
  75133. private static _score;
  75134. private static _bestScore;
  75135. /**
  75136. * Determine which token vector is most similar to the
  75137. * segment vector.
  75138. * @param segment segment vector
  75139. * @param tokens token vector list
  75140. * @returns index of the most similar token to the segment
  75141. */
  75142. private static _tokenizeSegment;
  75143. }
  75144. /**
  75145. * Class representing a set of known, named trajectories to which Trajectories can be
  75146. * added and using which Trajectories can be recognized.
  75147. */
  75148. export class TrajectoryClassifier {
  75149. private _maximumAllowableMatchCost;
  75150. private _vector3Alphabet;
  75151. private _levenshteinAlphabet;
  75152. private _nameToDescribedTrajectory;
  75153. /**
  75154. * Serialize to JSON.
  75155. * @returns JSON serialization
  75156. */
  75157. serialize(): string;
  75158. /**
  75159. * Deserialize from JSON.
  75160. * @param json JSON serialization
  75161. * @returns deserialized TrajectorySet
  75162. */
  75163. static Deserialize(json: string): TrajectoryClassifier;
  75164. /**
  75165. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75166. * VERY naive, need to be generating these things from known
  75167. * sets. Better version later, probably eliminating this one.
  75168. * @returns auto-generated TrajectorySet
  75169. */
  75170. static Generate(): TrajectoryClassifier;
  75171. private constructor();
  75172. /**
  75173. * Add a new Trajectory to the set with a given name.
  75174. * @param trajectory new Trajectory to be added
  75175. * @param classification name to which to add the Trajectory
  75176. */
  75177. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75178. /**
  75179. * Remove a known named trajectory and all Trajectories associated with it.
  75180. * @param classification name to remove
  75181. * @returns whether anything was removed
  75182. */
  75183. deleteClassification(classification: string): boolean;
  75184. /**
  75185. * Attempt to recognize a Trajectory from among all the classifications
  75186. * already known to the classifier.
  75187. * @param trajectory Trajectory to be recognized
  75188. * @returns classification of Trajectory if recognized, null otherwise
  75189. */
  75190. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75191. }
  75192. }
  75193. declare module BABYLON {
  75194. /**
  75195. * An interface for all Hit test features
  75196. */
  75197. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75198. /**
  75199. * Triggered when new babylon (transformed) hit test results are available
  75200. */
  75201. onHitTestResultObservable: Observable<T[]>;
  75202. }
  75203. /**
  75204. * Options used for hit testing
  75205. */
  75206. export interface IWebXRLegacyHitTestOptions {
  75207. /**
  75208. * Only test when user interacted with the scene. Default - hit test every frame
  75209. */
  75210. testOnPointerDownOnly?: boolean;
  75211. /**
  75212. * The node to use to transform the local results to world coordinates
  75213. */
  75214. worldParentNode?: TransformNode;
  75215. }
  75216. /**
  75217. * Interface defining the babylon result of raycasting/hit-test
  75218. */
  75219. export interface IWebXRLegacyHitResult {
  75220. /**
  75221. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75222. */
  75223. transformationMatrix: Matrix;
  75224. /**
  75225. * The native hit test result
  75226. */
  75227. xrHitResult: XRHitResult | XRHitTestResult;
  75228. }
  75229. /**
  75230. * The currently-working hit-test module.
  75231. * Hit test (or Ray-casting) is used to interact with the real world.
  75232. * For further information read here - https://github.com/immersive-web/hit-test
  75233. */
  75234. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75235. /**
  75236. * options to use when constructing this feature
  75237. */
  75238. readonly options: IWebXRLegacyHitTestOptions;
  75239. private _direction;
  75240. private _mat;
  75241. private _onSelectEnabled;
  75242. private _origin;
  75243. /**
  75244. * The module's name
  75245. */
  75246. static readonly Name: string;
  75247. /**
  75248. * The (Babylon) version of this module.
  75249. * This is an integer representing the implementation version.
  75250. * This number does not correspond to the WebXR specs version
  75251. */
  75252. static readonly Version: number;
  75253. /**
  75254. * Populated with the last native XR Hit Results
  75255. */
  75256. lastNativeXRHitResults: XRHitResult[];
  75257. /**
  75258. * Triggered when new babylon (transformed) hit test results are available
  75259. */
  75260. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75261. /**
  75262. * Creates a new instance of the (legacy version) hit test feature
  75263. * @param _xrSessionManager an instance of WebXRSessionManager
  75264. * @param options options to use when constructing this feature
  75265. */
  75266. constructor(_xrSessionManager: WebXRSessionManager,
  75267. /**
  75268. * options to use when constructing this feature
  75269. */
  75270. options?: IWebXRLegacyHitTestOptions);
  75271. /**
  75272. * execute a hit test with an XR Ray
  75273. *
  75274. * @param xrSession a native xrSession that will execute this hit test
  75275. * @param xrRay the ray (position and direction) to use for ray-casting
  75276. * @param referenceSpace native XR reference space to use for the hit-test
  75277. * @param filter filter function that will filter the results
  75278. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75279. */
  75280. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75281. /**
  75282. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75283. * @param event the (select) event to use to select with
  75284. * @param referenceSpace the reference space to use for this hit test
  75285. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75286. */
  75287. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75288. /**
  75289. * attach this feature
  75290. * Will usually be called by the features manager
  75291. *
  75292. * @returns true if successful.
  75293. */
  75294. attach(): boolean;
  75295. /**
  75296. * detach this feature.
  75297. * Will usually be called by the features manager
  75298. *
  75299. * @returns true if successful.
  75300. */
  75301. detach(): boolean;
  75302. /**
  75303. * Dispose this feature and all of the resources attached
  75304. */
  75305. dispose(): void;
  75306. protected _onXRFrame(frame: XRFrame): void;
  75307. private _onHitTestResults;
  75308. private _onSelect;
  75309. }
  75310. }
  75311. declare module BABYLON {
  75312. /**
  75313. * Options used for hit testing (version 2)
  75314. */
  75315. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75316. /**
  75317. * Do not create a permanent hit test. Will usually be used when only
  75318. * transient inputs are needed.
  75319. */
  75320. disablePermanentHitTest?: boolean;
  75321. /**
  75322. * Enable transient (for example touch-based) hit test inspections
  75323. */
  75324. enableTransientHitTest?: boolean;
  75325. /**
  75326. * Offset ray for the permanent hit test
  75327. */
  75328. offsetRay?: Vector3;
  75329. /**
  75330. * Offset ray for the transient hit test
  75331. */
  75332. transientOffsetRay?: Vector3;
  75333. /**
  75334. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75335. */
  75336. useReferenceSpace?: boolean;
  75337. /**
  75338. * Override the default entity type(s) of the hit-test result
  75339. */
  75340. entityTypes?: XRHitTestTrackableType[];
  75341. }
  75342. /**
  75343. * Interface defining the babylon result of hit-test
  75344. */
  75345. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75346. /**
  75347. * The input source that generated this hit test (if transient)
  75348. */
  75349. inputSource?: XRInputSource;
  75350. /**
  75351. * Is this a transient hit test
  75352. */
  75353. isTransient?: boolean;
  75354. /**
  75355. * Position of the hit test result
  75356. */
  75357. position: Vector3;
  75358. /**
  75359. * Rotation of the hit test result
  75360. */
  75361. rotationQuaternion: Quaternion;
  75362. /**
  75363. * The native hit test result
  75364. */
  75365. xrHitResult: XRHitTestResult;
  75366. }
  75367. /**
  75368. * The currently-working hit-test module.
  75369. * Hit test (or Ray-casting) is used to interact with the real world.
  75370. * For further information read here - https://github.com/immersive-web/hit-test
  75371. *
  75372. * Tested on chrome (mobile) 80.
  75373. */
  75374. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75375. /**
  75376. * options to use when constructing this feature
  75377. */
  75378. readonly options: IWebXRHitTestOptions;
  75379. private _tmpMat;
  75380. private _tmpPos;
  75381. private _tmpQuat;
  75382. private _transientXrHitTestSource;
  75383. private _xrHitTestSource;
  75384. private initHitTestSource;
  75385. /**
  75386. * The module's name
  75387. */
  75388. static readonly Name: string;
  75389. /**
  75390. * The (Babylon) version of this module.
  75391. * This is an integer representing the implementation version.
  75392. * This number does not correspond to the WebXR specs version
  75393. */
  75394. static readonly Version: number;
  75395. /**
  75396. * When set to true, each hit test will have its own position/rotation objects
  75397. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75398. * the developers will clone them or copy them as they see fit.
  75399. */
  75400. autoCloneTransformation: boolean;
  75401. /**
  75402. * Triggered when new babylon (transformed) hit test results are available
  75403. * Note - this will be called when results come back from the device. It can be an empty array!!
  75404. */
  75405. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75406. /**
  75407. * Use this to temporarily pause hit test checks.
  75408. */
  75409. paused: boolean;
  75410. /**
  75411. * Creates a new instance of the hit test feature
  75412. * @param _xrSessionManager an instance of WebXRSessionManager
  75413. * @param options options to use when constructing this feature
  75414. */
  75415. constructor(_xrSessionManager: WebXRSessionManager,
  75416. /**
  75417. * options to use when constructing this feature
  75418. */
  75419. options?: IWebXRHitTestOptions);
  75420. /**
  75421. * attach this feature
  75422. * Will usually be called by the features manager
  75423. *
  75424. * @returns true if successful.
  75425. */
  75426. attach(): boolean;
  75427. /**
  75428. * detach this feature.
  75429. * Will usually be called by the features manager
  75430. *
  75431. * @returns true if successful.
  75432. */
  75433. detach(): boolean;
  75434. /**
  75435. * Dispose this feature and all of the resources attached
  75436. */
  75437. dispose(): void;
  75438. protected _onXRFrame(frame: XRFrame): void;
  75439. private _processWebXRHitTestResult;
  75440. }
  75441. }
  75442. declare module BABYLON {
  75443. /**
  75444. * Configuration options of the anchor system
  75445. */
  75446. export interface IWebXRAnchorSystemOptions {
  75447. /**
  75448. * a node that will be used to convert local to world coordinates
  75449. */
  75450. worldParentNode?: TransformNode;
  75451. /**
  75452. * If set to true a reference of the created anchors will be kept until the next session starts
  75453. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75454. */
  75455. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75456. }
  75457. /**
  75458. * A babylon container for an XR Anchor
  75459. */
  75460. export interface IWebXRAnchor {
  75461. /**
  75462. * A babylon-assigned ID for this anchor
  75463. */
  75464. id: number;
  75465. /**
  75466. * Transformation matrix to apply to an object attached to this anchor
  75467. */
  75468. transformationMatrix: Matrix;
  75469. /**
  75470. * The native anchor object
  75471. */
  75472. xrAnchor: XRAnchor;
  75473. /**
  75474. * if defined, this object will be constantly updated by the anchor's position and rotation
  75475. */
  75476. attachedNode?: TransformNode;
  75477. }
  75478. /**
  75479. * An implementation of the anchor system for WebXR.
  75480. * For further information see https://github.com/immersive-web/anchors/
  75481. */
  75482. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75483. private _options;
  75484. private _lastFrameDetected;
  75485. private _trackedAnchors;
  75486. private _referenceSpaceForFrameAnchors;
  75487. private _futureAnchors;
  75488. /**
  75489. * The module's name
  75490. */
  75491. static readonly Name: string;
  75492. /**
  75493. * The (Babylon) version of this module.
  75494. * This is an integer representing the implementation version.
  75495. * This number does not correspond to the WebXR specs version
  75496. */
  75497. static readonly Version: number;
  75498. /**
  75499. * Observers registered here will be executed when a new anchor was added to the session
  75500. */
  75501. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75502. /**
  75503. * Observers registered here will be executed when an anchor was removed from the session
  75504. */
  75505. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75506. /**
  75507. * Observers registered here will be executed when an existing anchor updates
  75508. * This can execute N times every frame
  75509. */
  75510. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75511. /**
  75512. * Set the reference space to use for anchor creation, when not using a hit test.
  75513. * Will default to the session's reference space if not defined
  75514. */
  75515. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75516. /**
  75517. * constructs a new anchor system
  75518. * @param _xrSessionManager an instance of WebXRSessionManager
  75519. * @param _options configuration object for this feature
  75520. */
  75521. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75522. private _tmpVector;
  75523. private _tmpQuaternion;
  75524. private _populateTmpTransformation;
  75525. /**
  75526. * Create a new anchor point using a hit test result at a specific point in the scene
  75527. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75528. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75529. *
  75530. * @param hitTestResult The hit test result to use for this anchor creation
  75531. * @param position an optional position offset for this anchor
  75532. * @param rotationQuaternion an optional rotation offset for this anchor
  75533. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75534. */
  75535. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75536. /**
  75537. * Add a new anchor at a specific position and rotation
  75538. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75539. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75540. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75541. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75542. *
  75543. * @param position the position in which to add an anchor
  75544. * @param rotationQuaternion an optional rotation for the anchor transformation
  75545. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75546. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75547. */
  75548. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75549. /**
  75550. * detach this feature.
  75551. * Will usually be called by the features manager
  75552. *
  75553. * @returns true if successful.
  75554. */
  75555. detach(): boolean;
  75556. /**
  75557. * Dispose this feature and all of the resources attached
  75558. */
  75559. dispose(): void;
  75560. protected _onXRFrame(frame: XRFrame): void;
  75561. /**
  75562. * avoiding using Array.find for global support.
  75563. * @param xrAnchor the plane to find in the array
  75564. */
  75565. private _findIndexInAnchorArray;
  75566. private _updateAnchorWithXRFrame;
  75567. private _createAnchorAtTransformation;
  75568. }
  75569. }
  75570. declare module BABYLON {
  75571. /**
  75572. * Options used in the plane detector module
  75573. */
  75574. export interface IWebXRPlaneDetectorOptions {
  75575. /**
  75576. * The node to use to transform the local results to world coordinates
  75577. */
  75578. worldParentNode?: TransformNode;
  75579. /**
  75580. * If set to true a reference of the created planes will be kept until the next session starts
  75581. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75582. */
  75583. doNotRemovePlanesOnSessionEnded?: boolean;
  75584. }
  75585. /**
  75586. * A babylon interface for a WebXR plane.
  75587. * A Plane is actually a polygon, built from N points in space
  75588. *
  75589. * Supported in chrome 79, not supported in canary 81 ATM
  75590. */
  75591. export interface IWebXRPlane {
  75592. /**
  75593. * a babylon-assigned ID for this polygon
  75594. */
  75595. id: number;
  75596. /**
  75597. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75598. */
  75599. polygonDefinition: Array<Vector3>;
  75600. /**
  75601. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75602. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75603. */
  75604. transformationMatrix: Matrix;
  75605. /**
  75606. * the native xr-plane object
  75607. */
  75608. xrPlane: XRPlane;
  75609. }
  75610. /**
  75611. * The plane detector is used to detect planes in the real world when in AR
  75612. * For more information see https://github.com/immersive-web/real-world-geometry/
  75613. */
  75614. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75615. private _options;
  75616. private _detectedPlanes;
  75617. private _enabled;
  75618. private _lastFrameDetected;
  75619. /**
  75620. * The module's name
  75621. */
  75622. static readonly Name: string;
  75623. /**
  75624. * The (Babylon) version of this module.
  75625. * This is an integer representing the implementation version.
  75626. * This number does not correspond to the WebXR specs version
  75627. */
  75628. static readonly Version: number;
  75629. /**
  75630. * Observers registered here will be executed when a new plane was added to the session
  75631. */
  75632. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75633. /**
  75634. * Observers registered here will be executed when a plane is no longer detected in the session
  75635. */
  75636. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75637. /**
  75638. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75639. * This can execute N times every frame
  75640. */
  75641. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75642. /**
  75643. * construct a new Plane Detector
  75644. * @param _xrSessionManager an instance of xr Session manager
  75645. * @param _options configuration to use when constructing this feature
  75646. */
  75647. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75648. /**
  75649. * detach this feature.
  75650. * Will usually be called by the features manager
  75651. *
  75652. * @returns true if successful.
  75653. */
  75654. detach(): boolean;
  75655. /**
  75656. * Dispose this feature and all of the resources attached
  75657. */
  75658. dispose(): void;
  75659. protected _onXRFrame(frame: XRFrame): void;
  75660. private _init;
  75661. private _updatePlaneWithXRPlane;
  75662. /**
  75663. * avoiding using Array.find for global support.
  75664. * @param xrPlane the plane to find in the array
  75665. */
  75666. private findIndexInPlaneArray;
  75667. }
  75668. }
  75669. declare module BABYLON {
  75670. /**
  75671. * Options interface for the background remover plugin
  75672. */
  75673. export interface IWebXRBackgroundRemoverOptions {
  75674. /**
  75675. * Further background meshes to disable when entering AR
  75676. */
  75677. backgroundMeshes?: AbstractMesh[];
  75678. /**
  75679. * flags to configure the removal of the environment helper.
  75680. * If not set, the entire background will be removed. If set, flags should be set as well.
  75681. */
  75682. environmentHelperRemovalFlags?: {
  75683. /**
  75684. * Should the skybox be removed (default false)
  75685. */
  75686. skyBox?: boolean;
  75687. /**
  75688. * Should the ground be removed (default false)
  75689. */
  75690. ground?: boolean;
  75691. };
  75692. /**
  75693. * don't disable the environment helper
  75694. */
  75695. ignoreEnvironmentHelper?: boolean;
  75696. }
  75697. /**
  75698. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75699. */
  75700. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75701. /**
  75702. * read-only options to be used in this module
  75703. */
  75704. readonly options: IWebXRBackgroundRemoverOptions;
  75705. /**
  75706. * The module's name
  75707. */
  75708. static readonly Name: string;
  75709. /**
  75710. * The (Babylon) version of this module.
  75711. * This is an integer representing the implementation version.
  75712. * This number does not correspond to the WebXR specs version
  75713. */
  75714. static readonly Version: number;
  75715. /**
  75716. * registered observers will be triggered when the background state changes
  75717. */
  75718. onBackgroundStateChangedObservable: Observable<boolean>;
  75719. /**
  75720. * constructs a new background remover module
  75721. * @param _xrSessionManager the session manager for this module
  75722. * @param options read-only options to be used in this module
  75723. */
  75724. constructor(_xrSessionManager: WebXRSessionManager,
  75725. /**
  75726. * read-only options to be used in this module
  75727. */
  75728. options?: IWebXRBackgroundRemoverOptions);
  75729. /**
  75730. * attach this feature
  75731. * Will usually be called by the features manager
  75732. *
  75733. * @returns true if successful.
  75734. */
  75735. attach(): boolean;
  75736. /**
  75737. * detach this feature.
  75738. * Will usually be called by the features manager
  75739. *
  75740. * @returns true if successful.
  75741. */
  75742. detach(): boolean;
  75743. /**
  75744. * Dispose this feature and all of the resources attached
  75745. */
  75746. dispose(): void;
  75747. protected _onXRFrame(_xrFrame: XRFrame): void;
  75748. private _setBackgroundState;
  75749. }
  75750. }
  75751. declare module BABYLON {
  75752. /**
  75753. * Options for the controller physics feature
  75754. */
  75755. export class IWebXRControllerPhysicsOptions {
  75756. /**
  75757. * Should the headset get its own impostor
  75758. */
  75759. enableHeadsetImpostor?: boolean;
  75760. /**
  75761. * Optional parameters for the headset impostor
  75762. */
  75763. headsetImpostorParams?: {
  75764. /**
  75765. * The type of impostor to create. Default is sphere
  75766. */
  75767. impostorType: number;
  75768. /**
  75769. * the size of the impostor. Defaults to 10cm
  75770. */
  75771. impostorSize?: number | {
  75772. width: number;
  75773. height: number;
  75774. depth: number;
  75775. };
  75776. /**
  75777. * Friction definitions
  75778. */
  75779. friction?: number;
  75780. /**
  75781. * Restitution
  75782. */
  75783. restitution?: number;
  75784. };
  75785. /**
  75786. * The physics properties of the future impostors
  75787. */
  75788. physicsProperties?: {
  75789. /**
  75790. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75791. * Note that this requires a physics engine that supports mesh impostors!
  75792. */
  75793. useControllerMesh?: boolean;
  75794. /**
  75795. * The type of impostor to create. Default is sphere
  75796. */
  75797. impostorType?: number;
  75798. /**
  75799. * the size of the impostor. Defaults to 10cm
  75800. */
  75801. impostorSize?: number | {
  75802. width: number;
  75803. height: number;
  75804. depth: number;
  75805. };
  75806. /**
  75807. * Friction definitions
  75808. */
  75809. friction?: number;
  75810. /**
  75811. * Restitution
  75812. */
  75813. restitution?: number;
  75814. };
  75815. /**
  75816. * the xr input to use with this pointer selection
  75817. */
  75818. xrInput: WebXRInput;
  75819. }
  75820. /**
  75821. * Add physics impostor to your webxr controllers,
  75822. * including naive calculation of their linear and angular velocity
  75823. */
  75824. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75825. private readonly _options;
  75826. private _attachController;
  75827. private _controllers;
  75828. private _debugMode;
  75829. private _delta;
  75830. private _headsetImpostor?;
  75831. private _headsetMesh?;
  75832. private _lastTimestamp;
  75833. private _tmpQuaternion;
  75834. private _tmpVector;
  75835. /**
  75836. * The module's name
  75837. */
  75838. static readonly Name: string;
  75839. /**
  75840. * The (Babylon) version of this module.
  75841. * This is an integer representing the implementation version.
  75842. * This number does not correspond to the webxr specs version
  75843. */
  75844. static readonly Version: number;
  75845. /**
  75846. * Construct a new Controller Physics Feature
  75847. * @param _xrSessionManager the corresponding xr session manager
  75848. * @param _options options to create this feature with
  75849. */
  75850. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75851. /**
  75852. * @hidden
  75853. * enable debugging - will show console outputs and the impostor mesh
  75854. */
  75855. _enablePhysicsDebug(): void;
  75856. /**
  75857. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75858. * @param xrController the controller to add
  75859. */
  75860. addController(xrController: WebXRInputSource): void;
  75861. /**
  75862. * attach this feature
  75863. * Will usually be called by the features manager
  75864. *
  75865. * @returns true if successful.
  75866. */
  75867. attach(): boolean;
  75868. /**
  75869. * detach this feature.
  75870. * Will usually be called by the features manager
  75871. *
  75872. * @returns true if successful.
  75873. */
  75874. detach(): boolean;
  75875. /**
  75876. * Get the headset impostor, if enabled
  75877. * @returns the impostor
  75878. */
  75879. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75880. /**
  75881. * Get the physics impostor of a specific controller.
  75882. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75883. * @param controller the controller or the controller id of which to get the impostor
  75884. * @returns the impostor or null
  75885. */
  75886. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75887. /**
  75888. * Update the physics properties provided in the constructor
  75889. * @param newProperties the new properties object
  75890. */
  75891. setPhysicsProperties(newProperties: {
  75892. impostorType?: number;
  75893. impostorSize?: number | {
  75894. width: number;
  75895. height: number;
  75896. depth: number;
  75897. };
  75898. friction?: number;
  75899. restitution?: number;
  75900. }): void;
  75901. protected _onXRFrame(_xrFrame: any): void;
  75902. private _detachController;
  75903. }
  75904. }
  75905. declare module BABYLON {
  75906. /**
  75907. * A babylon interface for a "WebXR" feature point.
  75908. * Represents the position and confidence value of a given feature point.
  75909. */
  75910. export interface IWebXRFeaturePoint {
  75911. /**
  75912. * Represents the position of the feature point in world space.
  75913. */
  75914. position: Vector3;
  75915. /**
  75916. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75917. */
  75918. confidenceValue: number;
  75919. }
  75920. /**
  75921. * The feature point system is used to detect feature points from real world geometry.
  75922. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75923. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75924. */
  75925. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75926. private _enabled;
  75927. private _featurePointCloud;
  75928. /**
  75929. * The module's name
  75930. */
  75931. static readonly Name: string;
  75932. /**
  75933. * The (Babylon) version of this module.
  75934. * This is an integer representing the implementation version.
  75935. * This number does not correspond to the WebXR specs version
  75936. */
  75937. static readonly Version: number;
  75938. /**
  75939. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75940. * Will notify the observers about which feature points have been added.
  75941. */
  75942. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75943. /**
  75944. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75945. * Will notify the observers about which feature points have been updated.
  75946. */
  75947. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75948. /**
  75949. * The current feature point cloud maintained across frames.
  75950. */
  75951. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75952. /**
  75953. * construct the feature point system
  75954. * @param _xrSessionManager an instance of xr Session manager
  75955. */
  75956. constructor(_xrSessionManager: WebXRSessionManager);
  75957. /**
  75958. * Detach this feature.
  75959. * Will usually be called by the features manager
  75960. *
  75961. * @returns true if successful.
  75962. */
  75963. detach(): boolean;
  75964. /**
  75965. * Dispose this feature and all of the resources attached
  75966. */
  75967. dispose(): void;
  75968. /**
  75969. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75970. */
  75971. protected _onXRFrame(frame: XRFrame): void;
  75972. /**
  75973. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75974. */
  75975. private _init;
  75976. }
  75977. }
  75978. declare module BABYLON {
  75979. /**
  75980. * Configuration interface for the hand tracking feature
  75981. */
  75982. export interface IWebXRHandTrackingOptions {
  75983. /**
  75984. * The xrInput that will be used as source for new hands
  75985. */
  75986. xrInput: WebXRInput;
  75987. /**
  75988. * Configuration object for the joint meshes
  75989. */
  75990. jointMeshes?: {
  75991. /**
  75992. * Should the meshes created be invisible (defaults to false)
  75993. */
  75994. invisible?: boolean;
  75995. /**
  75996. * A source mesh to be used to create instances. Defaults to a sphere.
  75997. * This mesh will be the source for all other (25) meshes.
  75998. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75999. */
  76000. sourceMesh?: Mesh;
  76001. /**
  76002. * This function will be called after a mesh was created for a specific joint.
  76003. * Using this function you can either manipulate the instance or return a new mesh.
  76004. * When returning a new mesh the instance created before will be disposed
  76005. */
  76006. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76007. /**
  76008. * Should the source mesh stay visible. Defaults to false
  76009. */
  76010. keepOriginalVisible?: boolean;
  76011. /**
  76012. * Scale factor for all instances (defaults to 2)
  76013. */
  76014. scaleFactor?: number;
  76015. /**
  76016. * Should each instance have its own physics impostor
  76017. */
  76018. enablePhysics?: boolean;
  76019. /**
  76020. * If enabled, override default physics properties
  76021. */
  76022. physicsProps?: {
  76023. friction?: number;
  76024. restitution?: number;
  76025. impostorType?: number;
  76026. };
  76027. /**
  76028. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76029. */
  76030. handMesh?: AbstractMesh;
  76031. };
  76032. }
  76033. /**
  76034. * Parts of the hands divided to writs and finger names
  76035. */
  76036. export const enum HandPart {
  76037. /**
  76038. * HandPart - Wrist
  76039. */
  76040. WRIST = "wrist",
  76041. /**
  76042. * HandPart - The THumb
  76043. */
  76044. THUMB = "thumb",
  76045. /**
  76046. * HandPart - Index finger
  76047. */
  76048. INDEX = "index",
  76049. /**
  76050. * HandPart - Middle finger
  76051. */
  76052. MIDDLE = "middle",
  76053. /**
  76054. * HandPart - Ring finger
  76055. */
  76056. RING = "ring",
  76057. /**
  76058. * HandPart - Little finger
  76059. */
  76060. LITTLE = "little"
  76061. }
  76062. /**
  76063. * Representing a single hand (with its corresponding native XRHand object)
  76064. */
  76065. export class WebXRHand implements IDisposable {
  76066. /** the controller to which the hand correlates */
  76067. readonly xrController: WebXRInputSource;
  76068. /** the meshes to be used to track the hand joints */
  76069. readonly trackedMeshes: AbstractMesh[];
  76070. /**
  76071. * Hand-parts definition (key is HandPart)
  76072. */
  76073. handPartsDefinition: {
  76074. [key: string]: number[];
  76075. };
  76076. /**
  76077. * Populate the HandPartsDefinition object.
  76078. * This is called as a side effect since certain browsers don't have XRHand defined.
  76079. */
  76080. private generateHandPartsDefinition;
  76081. /**
  76082. * Construct a new hand object
  76083. * @param xrController the controller to which the hand correlates
  76084. * @param trackedMeshes the meshes to be used to track the hand joints
  76085. */
  76086. constructor(
  76087. /** the controller to which the hand correlates */
  76088. xrController: WebXRInputSource,
  76089. /** the meshes to be used to track the hand joints */
  76090. trackedMeshes: AbstractMesh[]);
  76091. /**
  76092. * Update this hand from the latest xr frame
  76093. * @param xrFrame xrFrame to update from
  76094. * @param referenceSpace The current viewer reference space
  76095. * @param scaleFactor optional scale factor for the meshes
  76096. */
  76097. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76098. /**
  76099. * Get meshes of part of the hand
  76100. * @param part the part of hand to get
  76101. * @returns An array of meshes that correlate to the hand part requested
  76102. */
  76103. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76104. /**
  76105. * Dispose this Hand object
  76106. */
  76107. dispose(): void;
  76108. }
  76109. /**
  76110. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76111. */
  76112. export class WebXRHandTracking extends WebXRAbstractFeature {
  76113. /**
  76114. * options to use when constructing this feature
  76115. */
  76116. readonly options: IWebXRHandTrackingOptions;
  76117. private static _idCounter;
  76118. /**
  76119. * The module's name
  76120. */
  76121. static readonly Name: string;
  76122. /**
  76123. * The (Babylon) version of this module.
  76124. * This is an integer representing the implementation version.
  76125. * This number does not correspond to the WebXR specs version
  76126. */
  76127. static readonly Version: number;
  76128. /**
  76129. * This observable will notify registered observers when a new hand object was added and initialized
  76130. */
  76131. onHandAddedObservable: Observable<WebXRHand>;
  76132. /**
  76133. * This observable will notify its observers right before the hand object is disposed
  76134. */
  76135. onHandRemovedObservable: Observable<WebXRHand>;
  76136. private _hands;
  76137. /**
  76138. * Creates a new instance of the hit test feature
  76139. * @param _xrSessionManager an instance of WebXRSessionManager
  76140. * @param options options to use when constructing this feature
  76141. */
  76142. constructor(_xrSessionManager: WebXRSessionManager,
  76143. /**
  76144. * options to use when constructing this feature
  76145. */
  76146. options: IWebXRHandTrackingOptions);
  76147. /**
  76148. * Check if the needed objects are defined.
  76149. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76150. */
  76151. isCompatible(): boolean;
  76152. /**
  76153. * attach this feature
  76154. * Will usually be called by the features manager
  76155. *
  76156. * @returns true if successful.
  76157. */
  76158. attach(): boolean;
  76159. /**
  76160. * detach this feature.
  76161. * Will usually be called by the features manager
  76162. *
  76163. * @returns true if successful.
  76164. */
  76165. detach(): boolean;
  76166. /**
  76167. * Dispose this feature and all of the resources attached
  76168. */
  76169. dispose(): void;
  76170. /**
  76171. * Get the hand object according to the controller id
  76172. * @param controllerId the controller id to which we want to get the hand
  76173. * @returns null if not found or the WebXRHand object if found
  76174. */
  76175. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76176. /**
  76177. * Get a hand object according to the requested handedness
  76178. * @param handedness the handedness to request
  76179. * @returns null if not found or the WebXRHand object if found
  76180. */
  76181. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76182. protected _onXRFrame(_xrFrame: XRFrame): void;
  76183. private _attachHand;
  76184. private _detachHand;
  76185. }
  76186. }
  76187. declare module BABYLON {
  76188. /**
  76189. * The motion controller class for all microsoft mixed reality controllers
  76190. */
  76191. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76192. protected readonly _mapping: {
  76193. defaultButton: {
  76194. valueNodeName: string;
  76195. unpressedNodeName: string;
  76196. pressedNodeName: string;
  76197. };
  76198. defaultAxis: {
  76199. valueNodeName: string;
  76200. minNodeName: string;
  76201. maxNodeName: string;
  76202. };
  76203. buttons: {
  76204. "xr-standard-trigger": {
  76205. rootNodeName: string;
  76206. componentProperty: string;
  76207. states: string[];
  76208. };
  76209. "xr-standard-squeeze": {
  76210. rootNodeName: string;
  76211. componentProperty: string;
  76212. states: string[];
  76213. };
  76214. "xr-standard-touchpad": {
  76215. rootNodeName: string;
  76216. labelAnchorNodeName: string;
  76217. touchPointNodeName: string;
  76218. };
  76219. "xr-standard-thumbstick": {
  76220. rootNodeName: string;
  76221. componentProperty: string;
  76222. states: string[];
  76223. };
  76224. };
  76225. axes: {
  76226. "xr-standard-touchpad": {
  76227. "x-axis": {
  76228. rootNodeName: string;
  76229. };
  76230. "y-axis": {
  76231. rootNodeName: string;
  76232. };
  76233. };
  76234. "xr-standard-thumbstick": {
  76235. "x-axis": {
  76236. rootNodeName: string;
  76237. };
  76238. "y-axis": {
  76239. rootNodeName: string;
  76240. };
  76241. };
  76242. };
  76243. };
  76244. /**
  76245. * The base url used to load the left and right controller models
  76246. */
  76247. static MODEL_BASE_URL: string;
  76248. /**
  76249. * The name of the left controller model file
  76250. */
  76251. static MODEL_LEFT_FILENAME: string;
  76252. /**
  76253. * The name of the right controller model file
  76254. */
  76255. static MODEL_RIGHT_FILENAME: string;
  76256. profileId: string;
  76257. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76258. protected _getFilenameAndPath(): {
  76259. filename: string;
  76260. path: string;
  76261. };
  76262. protected _getModelLoadingConstraints(): boolean;
  76263. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76264. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76265. protected _updateModel(): void;
  76266. }
  76267. }
  76268. declare module BABYLON {
  76269. /**
  76270. * The motion controller class for oculus touch (quest, rift).
  76271. * This class supports legacy mapping as well the standard xr mapping
  76272. */
  76273. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76274. private _forceLegacyControllers;
  76275. private _modelRootNode;
  76276. /**
  76277. * The base url used to load the left and right controller models
  76278. */
  76279. static MODEL_BASE_URL: string;
  76280. /**
  76281. * The name of the left controller model file
  76282. */
  76283. static MODEL_LEFT_FILENAME: string;
  76284. /**
  76285. * The name of the right controller model file
  76286. */
  76287. static MODEL_RIGHT_FILENAME: string;
  76288. /**
  76289. * Base Url for the Quest controller model.
  76290. */
  76291. static QUEST_MODEL_BASE_URL: string;
  76292. profileId: string;
  76293. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76294. protected _getFilenameAndPath(): {
  76295. filename: string;
  76296. path: string;
  76297. };
  76298. protected _getModelLoadingConstraints(): boolean;
  76299. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76300. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76301. protected _updateModel(): void;
  76302. /**
  76303. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76304. * between the touch and touch 2.
  76305. */
  76306. private _isQuest;
  76307. }
  76308. }
  76309. declare module BABYLON {
  76310. /**
  76311. * The motion controller class for the standard HTC-Vive controllers
  76312. */
  76313. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76314. private _modelRootNode;
  76315. /**
  76316. * The base url used to load the left and right controller models
  76317. */
  76318. static MODEL_BASE_URL: string;
  76319. /**
  76320. * File name for the controller model.
  76321. */
  76322. static MODEL_FILENAME: string;
  76323. profileId: string;
  76324. /**
  76325. * Create a new Vive motion controller object
  76326. * @param scene the scene to use to create this controller
  76327. * @param gamepadObject the corresponding gamepad object
  76328. * @param handedness the handedness of the controller
  76329. */
  76330. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76331. protected _getFilenameAndPath(): {
  76332. filename: string;
  76333. path: string;
  76334. };
  76335. protected _getModelLoadingConstraints(): boolean;
  76336. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76337. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76338. protected _updateModel(): void;
  76339. }
  76340. }
  76341. declare module BABYLON {
  76342. /**
  76343. * A cursor which tracks a point on a path
  76344. */
  76345. export class PathCursor {
  76346. private path;
  76347. /**
  76348. * Stores path cursor callbacks for when an onchange event is triggered
  76349. */
  76350. private _onchange;
  76351. /**
  76352. * The value of the path cursor
  76353. */
  76354. value: number;
  76355. /**
  76356. * The animation array of the path cursor
  76357. */
  76358. animations: Animation[];
  76359. /**
  76360. * Initializes the path cursor
  76361. * @param path The path to track
  76362. */
  76363. constructor(path: Path2);
  76364. /**
  76365. * Gets the cursor point on the path
  76366. * @returns A point on the path cursor at the cursor location
  76367. */
  76368. getPoint(): Vector3;
  76369. /**
  76370. * Moves the cursor ahead by the step amount
  76371. * @param step The amount to move the cursor forward
  76372. * @returns This path cursor
  76373. */
  76374. moveAhead(step?: number): PathCursor;
  76375. /**
  76376. * Moves the cursor behind by the step amount
  76377. * @param step The amount to move the cursor back
  76378. * @returns This path cursor
  76379. */
  76380. moveBack(step?: number): PathCursor;
  76381. /**
  76382. * Moves the cursor by the step amount
  76383. * If the step amount is greater than one, an exception is thrown
  76384. * @param step The amount to move the cursor
  76385. * @returns This path cursor
  76386. */
  76387. move(step: number): PathCursor;
  76388. /**
  76389. * Ensures that the value is limited between zero and one
  76390. * @returns This path cursor
  76391. */
  76392. private ensureLimits;
  76393. /**
  76394. * Runs onchange callbacks on change (used by the animation engine)
  76395. * @returns This path cursor
  76396. */
  76397. private raiseOnChange;
  76398. /**
  76399. * Executes a function on change
  76400. * @param f A path cursor onchange callback
  76401. * @returns This path cursor
  76402. */
  76403. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76404. }
  76405. }
  76406. declare module BABYLON {
  76407. /** @hidden */
  76408. export var blurPixelShader: {
  76409. name: string;
  76410. shader: string;
  76411. };
  76412. }
  76413. declare module BABYLON {
  76414. /** @hidden */
  76415. export var pointCloudVertexDeclaration: {
  76416. name: string;
  76417. shader: string;
  76418. };
  76419. }
  76420. // Mixins
  76421. interface Window {
  76422. mozIndexedDB: IDBFactory;
  76423. webkitIndexedDB: IDBFactory;
  76424. msIndexedDB: IDBFactory;
  76425. webkitURL: typeof URL;
  76426. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76427. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76428. WebGLRenderingContext: WebGLRenderingContext;
  76429. MSGesture: MSGesture;
  76430. CANNON: any;
  76431. AudioContext: AudioContext;
  76432. webkitAudioContext: AudioContext;
  76433. PointerEvent: any;
  76434. Math: Math;
  76435. Uint8Array: Uint8ArrayConstructor;
  76436. Float32Array: Float32ArrayConstructor;
  76437. mozURL: typeof URL;
  76438. msURL: typeof URL;
  76439. VRFrameData: any; // WebVR, from specs 1.1
  76440. DracoDecoderModule: any;
  76441. setImmediate(handler: (...args: any[]) => void): number;
  76442. }
  76443. interface HTMLCanvasElement {
  76444. requestPointerLock(): void;
  76445. msRequestPointerLock?(): void;
  76446. mozRequestPointerLock?(): void;
  76447. webkitRequestPointerLock?(): void;
  76448. /** Track wether a record is in progress */
  76449. isRecording: boolean;
  76450. /** Capture Stream method defined by some browsers */
  76451. captureStream(fps?: number): MediaStream;
  76452. }
  76453. interface CanvasRenderingContext2D {
  76454. msImageSmoothingEnabled: boolean;
  76455. }
  76456. interface MouseEvent {
  76457. mozMovementX: number;
  76458. mozMovementY: number;
  76459. webkitMovementX: number;
  76460. webkitMovementY: number;
  76461. msMovementX: number;
  76462. msMovementY: number;
  76463. }
  76464. interface Navigator {
  76465. mozGetVRDevices: (any: any) => any;
  76466. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76467. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76468. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76469. webkitGetGamepads(): Gamepad[];
  76470. msGetGamepads(): Gamepad[];
  76471. webkitGamepads(): Gamepad[];
  76472. }
  76473. interface HTMLVideoElement {
  76474. mozSrcObject: any;
  76475. }
  76476. interface Math {
  76477. fround(x: number): number;
  76478. imul(a: number, b: number): number;
  76479. }
  76480. interface WebGLRenderingContext {
  76481. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76482. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76483. vertexAttribDivisor(index: number, divisor: number): void;
  76484. createVertexArray(): any;
  76485. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76486. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76487. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76488. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76489. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76490. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76491. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76492. // Queries
  76493. createQuery(): WebGLQuery;
  76494. deleteQuery(query: WebGLQuery): void;
  76495. beginQuery(target: number, query: WebGLQuery): void;
  76496. endQuery(target: number): void;
  76497. getQueryParameter(query: WebGLQuery, pname: number): any;
  76498. getQuery(target: number, pname: number): any;
  76499. MAX_SAMPLES: number;
  76500. RGBA8: number;
  76501. READ_FRAMEBUFFER: number;
  76502. DRAW_FRAMEBUFFER: number;
  76503. UNIFORM_BUFFER: number;
  76504. HALF_FLOAT_OES: number;
  76505. RGBA16F: number;
  76506. RGBA32F: number;
  76507. R32F: number;
  76508. RG32F: number;
  76509. RGB32F: number;
  76510. R16F: number;
  76511. RG16F: number;
  76512. RGB16F: number;
  76513. RED: number;
  76514. RG: number;
  76515. R8: number;
  76516. RG8: number;
  76517. UNSIGNED_INT_24_8: number;
  76518. DEPTH24_STENCIL8: number;
  76519. MIN: number;
  76520. MAX: number;
  76521. /* Multiple Render Targets */
  76522. drawBuffers(buffers: number[]): void;
  76523. readBuffer(src: number): void;
  76524. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76525. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76526. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76527. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76528. // Occlusion Query
  76529. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76530. ANY_SAMPLES_PASSED: number;
  76531. QUERY_RESULT_AVAILABLE: number;
  76532. QUERY_RESULT: number;
  76533. }
  76534. interface WebGLProgram {
  76535. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76536. }
  76537. interface EXT_disjoint_timer_query {
  76538. QUERY_COUNTER_BITS_EXT: number;
  76539. TIME_ELAPSED_EXT: number;
  76540. TIMESTAMP_EXT: number;
  76541. GPU_DISJOINT_EXT: number;
  76542. QUERY_RESULT_EXT: number;
  76543. QUERY_RESULT_AVAILABLE_EXT: number;
  76544. queryCounterEXT(query: WebGLQuery, target: number): void;
  76545. createQueryEXT(): WebGLQuery;
  76546. beginQueryEXT(target: number, query: WebGLQuery): void;
  76547. endQueryEXT(target: number): void;
  76548. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76549. deleteQueryEXT(query: WebGLQuery): void;
  76550. }
  76551. interface WebGLUniformLocation {
  76552. _currentState: any;
  76553. }
  76554. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76555. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76556. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76557. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76558. interface WebGLRenderingContext {
  76559. readonly RASTERIZER_DISCARD: number;
  76560. readonly DEPTH_COMPONENT24: number;
  76561. readonly TEXTURE_3D: number;
  76562. readonly TEXTURE_2D_ARRAY: number;
  76563. readonly TEXTURE_COMPARE_FUNC: number;
  76564. readonly TEXTURE_COMPARE_MODE: number;
  76565. readonly COMPARE_REF_TO_TEXTURE: number;
  76566. readonly TEXTURE_WRAP_R: number;
  76567. readonly HALF_FLOAT: number;
  76568. readonly RGB8: number;
  76569. readonly RED_INTEGER: number;
  76570. readonly RG_INTEGER: number;
  76571. readonly RGB_INTEGER: number;
  76572. readonly RGBA_INTEGER: number;
  76573. readonly R8_SNORM: number;
  76574. readonly RG8_SNORM: number;
  76575. readonly RGB8_SNORM: number;
  76576. readonly RGBA8_SNORM: number;
  76577. readonly R8I: number;
  76578. readonly RG8I: number;
  76579. readonly RGB8I: number;
  76580. readonly RGBA8I: number;
  76581. readonly R8UI: number;
  76582. readonly RG8UI: number;
  76583. readonly RGB8UI: number;
  76584. readonly RGBA8UI: number;
  76585. readonly R16I: number;
  76586. readonly RG16I: number;
  76587. readonly RGB16I: number;
  76588. readonly RGBA16I: number;
  76589. readonly R16UI: number;
  76590. readonly RG16UI: number;
  76591. readonly RGB16UI: number;
  76592. readonly RGBA16UI: number;
  76593. readonly R32I: number;
  76594. readonly RG32I: number;
  76595. readonly RGB32I: number;
  76596. readonly RGBA32I: number;
  76597. readonly R32UI: number;
  76598. readonly RG32UI: number;
  76599. readonly RGB32UI: number;
  76600. readonly RGBA32UI: number;
  76601. readonly RGB10_A2UI: number;
  76602. readonly R11F_G11F_B10F: number;
  76603. readonly RGB9_E5: number;
  76604. readonly RGB10_A2: number;
  76605. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76606. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76607. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76608. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76609. readonly DEPTH_COMPONENT32F: number;
  76610. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76611. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76612. 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;
  76613. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76614. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76615. readonly TRANSFORM_FEEDBACK: number;
  76616. readonly INTERLEAVED_ATTRIBS: number;
  76617. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76618. createTransformFeedback(): WebGLTransformFeedback;
  76619. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76620. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76621. beginTransformFeedback(primitiveMode: number): void;
  76622. endTransformFeedback(): void;
  76623. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76624. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76625. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76626. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76627. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76628. }
  76629. interface ImageBitmap {
  76630. readonly width: number;
  76631. readonly height: number;
  76632. close(): void;
  76633. }
  76634. interface WebGLQuery extends WebGLObject {
  76635. }
  76636. declare var WebGLQuery: {
  76637. prototype: WebGLQuery;
  76638. new(): WebGLQuery;
  76639. };
  76640. interface WebGLSampler extends WebGLObject {
  76641. }
  76642. declare var WebGLSampler: {
  76643. prototype: WebGLSampler;
  76644. new(): WebGLSampler;
  76645. };
  76646. interface WebGLSync extends WebGLObject {
  76647. }
  76648. declare var WebGLSync: {
  76649. prototype: WebGLSync;
  76650. new(): WebGLSync;
  76651. };
  76652. interface WebGLTransformFeedback extends WebGLObject {
  76653. }
  76654. declare var WebGLTransformFeedback: {
  76655. prototype: WebGLTransformFeedback;
  76656. new(): WebGLTransformFeedback;
  76657. };
  76658. interface WebGLVertexArrayObject extends WebGLObject {
  76659. }
  76660. declare var WebGLVertexArrayObject: {
  76661. prototype: WebGLVertexArrayObject;
  76662. new(): WebGLVertexArrayObject;
  76663. };
  76664. // Type definitions for WebVR API
  76665. // Project: https://w3c.github.io/webvr/
  76666. // Definitions by: six a <https://github.com/lostfictions>
  76667. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76668. interface VRDisplay extends EventTarget {
  76669. /**
  76670. * Dictionary of capabilities describing the VRDisplay.
  76671. */
  76672. readonly capabilities: VRDisplayCapabilities;
  76673. /**
  76674. * z-depth defining the far plane of the eye view frustum
  76675. * enables mapping of values in the render target depth
  76676. * attachment to scene coordinates. Initially set to 10000.0.
  76677. */
  76678. depthFar: number;
  76679. /**
  76680. * z-depth defining the near plane of the eye view frustum
  76681. * enables mapping of values in the render target depth
  76682. * attachment to scene coordinates. Initially set to 0.01.
  76683. */
  76684. depthNear: number;
  76685. /**
  76686. * An identifier for this distinct VRDisplay. Used as an
  76687. * association point in the Gamepad API.
  76688. */
  76689. readonly displayId: number;
  76690. /**
  76691. * A display name, a user-readable name identifying it.
  76692. */
  76693. readonly displayName: string;
  76694. readonly isConnected: boolean;
  76695. readonly isPresenting: boolean;
  76696. /**
  76697. * If this VRDisplay supports room-scale experiences, the optional
  76698. * stage attribute contains details on the room-scale parameters.
  76699. */
  76700. readonly stageParameters: VRStageParameters | null;
  76701. /**
  76702. * Passing the value returned by `requestAnimationFrame` to
  76703. * `cancelAnimationFrame` will unregister the callback.
  76704. * @param handle Define the hanle of the request to cancel
  76705. */
  76706. cancelAnimationFrame(handle: number): void;
  76707. /**
  76708. * Stops presenting to the VRDisplay.
  76709. * @returns a promise to know when it stopped
  76710. */
  76711. exitPresent(): Promise<void>;
  76712. /**
  76713. * Return the current VREyeParameters for the given eye.
  76714. * @param whichEye Define the eye we want the parameter for
  76715. * @returns the eye parameters
  76716. */
  76717. getEyeParameters(whichEye: string): VREyeParameters;
  76718. /**
  76719. * Populates the passed VRFrameData with the information required to render
  76720. * the current frame.
  76721. * @param frameData Define the data structure to populate
  76722. * @returns true if ok otherwise false
  76723. */
  76724. getFrameData(frameData: VRFrameData): boolean;
  76725. /**
  76726. * Get the layers currently being presented.
  76727. * @returns the list of VR layers
  76728. */
  76729. getLayers(): VRLayer[];
  76730. /**
  76731. * Return a VRPose containing the future predicted pose of the VRDisplay
  76732. * when the current frame will be presented. The value returned will not
  76733. * change until JavaScript has returned control to the browser.
  76734. *
  76735. * The VRPose will contain the position, orientation, velocity,
  76736. * and acceleration of each of these properties.
  76737. * @returns the pose object
  76738. */
  76739. getPose(): VRPose;
  76740. /**
  76741. * Return the current instantaneous pose of the VRDisplay, with no
  76742. * prediction applied.
  76743. * @returns the current instantaneous pose
  76744. */
  76745. getImmediatePose(): VRPose;
  76746. /**
  76747. * The callback passed to `requestAnimationFrame` will be called
  76748. * any time a new frame should be rendered. When the VRDisplay is
  76749. * presenting the callback will be called at the native refresh
  76750. * rate of the HMD. When not presenting this function acts
  76751. * identically to how window.requestAnimationFrame acts. Content should
  76752. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76753. * asynchronously from other displays and at differing refresh rates.
  76754. * @param callback Define the eaction to run next frame
  76755. * @returns the request handle it
  76756. */
  76757. requestAnimationFrame(callback: FrameRequestCallback): number;
  76758. /**
  76759. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76760. * Repeat calls while already presenting will update the VRLayers being displayed.
  76761. * @param layers Define the list of layer to present
  76762. * @returns a promise to know when the request has been fulfilled
  76763. */
  76764. requestPresent(layers: VRLayer[]): Promise<void>;
  76765. /**
  76766. * Reset the pose for this display, treating its current position and
  76767. * orientation as the "origin/zero" values. VRPose.position,
  76768. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76769. * updated when calling resetPose(). This should be called in only
  76770. * sitting-space experiences.
  76771. */
  76772. resetPose(): void;
  76773. /**
  76774. * The VRLayer provided to the VRDisplay will be captured and presented
  76775. * in the HMD. Calling this function has the same effect on the source
  76776. * canvas as any other operation that uses its source image, and canvases
  76777. * created without preserveDrawingBuffer set to true will be cleared.
  76778. * @param pose Define the pose to submit
  76779. */
  76780. submitFrame(pose?: VRPose): void;
  76781. }
  76782. declare var VRDisplay: {
  76783. prototype: VRDisplay;
  76784. new(): VRDisplay;
  76785. };
  76786. interface VRLayer {
  76787. leftBounds?: number[] | Float32Array | null;
  76788. rightBounds?: number[] | Float32Array | null;
  76789. source?: HTMLCanvasElement | null;
  76790. }
  76791. interface VRDisplayCapabilities {
  76792. readonly canPresent: boolean;
  76793. readonly hasExternalDisplay: boolean;
  76794. readonly hasOrientation: boolean;
  76795. readonly hasPosition: boolean;
  76796. readonly maxLayers: number;
  76797. }
  76798. interface VREyeParameters {
  76799. /** @deprecated */
  76800. readonly fieldOfView: VRFieldOfView;
  76801. readonly offset: Float32Array;
  76802. readonly renderHeight: number;
  76803. readonly renderWidth: number;
  76804. }
  76805. interface VRFieldOfView {
  76806. readonly downDegrees: number;
  76807. readonly leftDegrees: number;
  76808. readonly rightDegrees: number;
  76809. readonly upDegrees: number;
  76810. }
  76811. interface VRFrameData {
  76812. readonly leftProjectionMatrix: Float32Array;
  76813. readonly leftViewMatrix: Float32Array;
  76814. readonly pose: VRPose;
  76815. readonly rightProjectionMatrix: Float32Array;
  76816. readonly rightViewMatrix: Float32Array;
  76817. readonly timestamp: number;
  76818. }
  76819. interface VRPose {
  76820. readonly angularAcceleration: Float32Array | null;
  76821. readonly angularVelocity: Float32Array | null;
  76822. readonly linearAcceleration: Float32Array | null;
  76823. readonly linearVelocity: Float32Array | null;
  76824. readonly orientation: Float32Array | null;
  76825. readonly position: Float32Array | null;
  76826. readonly timestamp: number;
  76827. }
  76828. interface VRStageParameters {
  76829. sittingToStandingTransform?: Float32Array;
  76830. sizeX?: number;
  76831. sizeY?: number;
  76832. }
  76833. interface Navigator {
  76834. getVRDisplays(): Promise<VRDisplay[]>;
  76835. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76836. }
  76837. interface Window {
  76838. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76839. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76840. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76841. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76842. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76843. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76844. }
  76845. interface Gamepad {
  76846. readonly displayId: number;
  76847. }
  76848. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76849. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76850. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76851. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76852. type XRHandedness = "none" | "left" | "right";
  76853. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76854. type XREye = "none" | "left" | "right";
  76855. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76856. interface XRSpace extends EventTarget {}
  76857. interface XRRenderState {
  76858. depthNear?: number;
  76859. depthFar?: number;
  76860. inlineVerticalFieldOfView?: number;
  76861. baseLayer?: XRWebGLLayer;
  76862. }
  76863. interface XRInputSource {
  76864. handedness: XRHandedness;
  76865. targetRayMode: XRTargetRayMode;
  76866. targetRaySpace: XRSpace;
  76867. gripSpace: XRSpace | undefined;
  76868. gamepad: Gamepad | undefined;
  76869. profiles: Array<string>;
  76870. hand: XRHand | undefined;
  76871. }
  76872. interface XRSessionInit {
  76873. optionalFeatures?: string[];
  76874. requiredFeatures?: string[];
  76875. }
  76876. interface XRSession {
  76877. addEventListener: Function;
  76878. removeEventListener: Function;
  76879. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76880. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76881. requestAnimationFrame: Function;
  76882. end(): Promise<void>;
  76883. renderState: XRRenderState;
  76884. inputSources: Array<XRInputSource>;
  76885. // hit test
  76886. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76887. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76888. // legacy AR hit test
  76889. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76890. // legacy plane detection
  76891. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76892. }
  76893. interface XRReferenceSpace extends XRSpace {
  76894. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76895. onreset: any;
  76896. }
  76897. type XRPlaneSet = Set<XRPlane>;
  76898. type XRAnchorSet = Set<XRAnchor>;
  76899. interface XRFrame {
  76900. session: XRSession;
  76901. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76902. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76903. // AR
  76904. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76905. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76906. // Anchors
  76907. trackedAnchors?: XRAnchorSet;
  76908. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76909. // Planes
  76910. worldInformation: {
  76911. detectedPlanes?: XRPlaneSet;
  76912. };
  76913. // Hand tracking
  76914. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76915. }
  76916. interface XRViewerPose extends XRPose {
  76917. views: Array<XRView>;
  76918. }
  76919. interface XRPose {
  76920. transform: XRRigidTransform;
  76921. emulatedPosition: boolean;
  76922. }
  76923. interface XRWebGLLayerOptions {
  76924. antialias?: boolean;
  76925. depth?: boolean;
  76926. stencil?: boolean;
  76927. alpha?: boolean;
  76928. multiview?: boolean;
  76929. framebufferScaleFactor?: number;
  76930. }
  76931. declare var XRWebGLLayer: {
  76932. prototype: XRWebGLLayer;
  76933. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76934. };
  76935. interface XRWebGLLayer {
  76936. framebuffer: WebGLFramebuffer;
  76937. framebufferWidth: number;
  76938. framebufferHeight: number;
  76939. getViewport: Function;
  76940. }
  76941. declare class XRRigidTransform {
  76942. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76943. position: DOMPointReadOnly;
  76944. orientation: DOMPointReadOnly;
  76945. matrix: Float32Array;
  76946. inverse: XRRigidTransform;
  76947. }
  76948. interface XRView {
  76949. eye: XREye;
  76950. projectionMatrix: Float32Array;
  76951. transform: XRRigidTransform;
  76952. }
  76953. interface XRInputSourceChangeEvent {
  76954. session: XRSession;
  76955. removed: Array<XRInputSource>;
  76956. added: Array<XRInputSource>;
  76957. }
  76958. interface XRInputSourceEvent extends Event {
  76959. readonly frame: XRFrame;
  76960. readonly inputSource: XRInputSource;
  76961. }
  76962. // Experimental(er) features
  76963. declare class XRRay {
  76964. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76965. origin: DOMPointReadOnly;
  76966. direction: DOMPointReadOnly;
  76967. matrix: Float32Array;
  76968. }
  76969. declare enum XRHitTestTrackableType {
  76970. "point",
  76971. "plane",
  76972. "mesh",
  76973. }
  76974. interface XRHitResult {
  76975. hitMatrix: Float32Array;
  76976. }
  76977. interface XRTransientInputHitTestResult {
  76978. readonly inputSource: XRInputSource;
  76979. readonly results: Array<XRHitTestResult>;
  76980. }
  76981. interface XRHitTestResult {
  76982. getPose(baseSpace: XRSpace): XRPose | undefined;
  76983. // When anchor system is enabled
  76984. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76985. }
  76986. interface XRHitTestSource {
  76987. cancel(): void;
  76988. }
  76989. interface XRTransientInputHitTestSource {
  76990. cancel(): void;
  76991. }
  76992. interface XRHitTestOptionsInit {
  76993. space: XRSpace;
  76994. entityTypes?: Array<XRHitTestTrackableType>;
  76995. offsetRay?: XRRay;
  76996. }
  76997. interface XRTransientInputHitTestOptionsInit {
  76998. profile: string;
  76999. entityTypes?: Array<XRHitTestTrackableType>;
  77000. offsetRay?: XRRay;
  77001. }
  77002. interface XRAnchor {
  77003. anchorSpace: XRSpace;
  77004. delete(): void;
  77005. }
  77006. interface XRPlane {
  77007. orientation: "Horizontal" | "Vertical";
  77008. planeSpace: XRSpace;
  77009. polygon: Array<DOMPointReadOnly>;
  77010. lastChangedTime: number;
  77011. }
  77012. interface XRJointSpace extends XRSpace {}
  77013. interface XRJointPose extends XRPose {
  77014. radius: number | undefined;
  77015. }
  77016. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  77017. readonly length: number;
  77018. [index: number]: XRJointSpace;
  77019. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  77020. readonly WRIST: number;
  77021. readonly THUMB_METACARPAL: number;
  77022. readonly THUMB_PHALANX_PROXIMAL: number;
  77023. readonly THUMB_PHALANX_DISTAL: number;
  77024. readonly THUMB_PHALANX_TIP: number;
  77025. readonly INDEX_METACARPAL: number;
  77026. readonly INDEX_PHALANX_PROXIMAL: number;
  77027. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77028. readonly INDEX_PHALANX_DISTAL: number;
  77029. readonly INDEX_PHALANX_TIP: number;
  77030. readonly MIDDLE_METACARPAL: number;
  77031. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77032. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77033. readonly MIDDLE_PHALANX_DISTAL: number;
  77034. readonly MIDDLE_PHALANX_TIP: number;
  77035. readonly RING_METACARPAL: number;
  77036. readonly RING_PHALANX_PROXIMAL: number;
  77037. readonly RING_PHALANX_INTERMEDIATE: number;
  77038. readonly RING_PHALANX_DISTAL: number;
  77039. readonly RING_PHALANX_TIP: number;
  77040. readonly LITTLE_METACARPAL: number;
  77041. readonly LITTLE_PHALANX_PROXIMAL: number;
  77042. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77043. readonly LITTLE_PHALANX_DISTAL: number;
  77044. readonly LITTLE_PHALANX_TIP: number;
  77045. }
  77046. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77047. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77048. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77049. interface XRSession {
  77050. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77051. }
  77052. interface XRFrame {
  77053. featurePointCloud? : Array<number>;
  77054. }
  77055. /**
  77056. * @ignore
  77057. */
  77058. declare module BABYLON.GLTF2.Exporter {
  77059. }
  77060. /**
  77061. * @ignore
  77062. */
  77063. declare module BABYLON.GLTF1 {
  77064. }
  77065. declare module BABYLON.GUI {
  77066. /**
  77067. * Class used to specific a value and its associated unit
  77068. */
  77069. export class ValueAndUnit {
  77070. /** defines the unit to store */
  77071. unit: number;
  77072. /** defines a boolean indicating if the value can be negative */
  77073. negativeValueAllowed: boolean;
  77074. private _value;
  77075. private _originalUnit;
  77076. /**
  77077. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77078. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77079. */
  77080. ignoreAdaptiveScaling: boolean;
  77081. /**
  77082. * Creates a new ValueAndUnit
  77083. * @param value defines the value to store
  77084. * @param unit defines the unit to store
  77085. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77086. */
  77087. constructor(value: number,
  77088. /** defines the unit to store */
  77089. unit?: number,
  77090. /** defines a boolean indicating if the value can be negative */
  77091. negativeValueAllowed?: boolean);
  77092. /** Gets a boolean indicating if the value is a percentage */
  77093. get isPercentage(): boolean;
  77094. /** Gets a boolean indicating if the value is store as pixel */
  77095. get isPixel(): boolean;
  77096. /** Gets direct internal value */
  77097. get internalValue(): number;
  77098. /**
  77099. * Gets value as pixel
  77100. * @param host defines the root host
  77101. * @param refValue defines the reference value for percentages
  77102. * @returns the value as pixel
  77103. */
  77104. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77105. /**
  77106. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77107. * @param value defines the value to store
  77108. * @param unit defines the unit to store
  77109. * @returns the current ValueAndUnit
  77110. */
  77111. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77112. /**
  77113. * Gets the value accordingly to its unit
  77114. * @param host defines the root host
  77115. * @returns the value
  77116. */
  77117. getValue(host: AdvancedDynamicTexture): number;
  77118. /**
  77119. * Gets a string representation of the value
  77120. * @param host defines the root host
  77121. * @param decimals defines an optional number of decimals to display
  77122. * @returns a string
  77123. */
  77124. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77125. /**
  77126. * Store a value parsed from a string
  77127. * @param source defines the source string
  77128. * @returns true if the value was successfully parsed
  77129. */
  77130. fromString(source: string | number): boolean;
  77131. private static _Regex;
  77132. private static _UNITMODE_PERCENTAGE;
  77133. private static _UNITMODE_PIXEL;
  77134. /** UNITMODE_PERCENTAGE */
  77135. static get UNITMODE_PERCENTAGE(): number;
  77136. /** UNITMODE_PIXEL */
  77137. static get UNITMODE_PIXEL(): number;
  77138. }
  77139. }
  77140. declare module BABYLON.GUI {
  77141. /**
  77142. * Define a style used by control to automatically setup properties based on a template.
  77143. * Only support font related properties so far
  77144. */
  77145. export class Style implements BABYLON.IDisposable {
  77146. private _fontFamily;
  77147. private _fontStyle;
  77148. private _fontWeight;
  77149. /** @hidden */
  77150. _host: AdvancedDynamicTexture;
  77151. /** @hidden */
  77152. _fontSize: ValueAndUnit;
  77153. /**
  77154. * BABYLON.Observable raised when the style values are changed
  77155. */
  77156. onChangedObservable: BABYLON.Observable<Style>;
  77157. /**
  77158. * Creates a new style object
  77159. * @param host defines the AdvancedDynamicTexture which hosts this style
  77160. */
  77161. constructor(host: AdvancedDynamicTexture);
  77162. /**
  77163. * Gets or sets the font size
  77164. */
  77165. get fontSize(): string | number;
  77166. set fontSize(value: string | number);
  77167. /**
  77168. * Gets or sets the font family
  77169. */
  77170. get fontFamily(): string;
  77171. set fontFamily(value: string);
  77172. /**
  77173. * Gets or sets the font style
  77174. */
  77175. get fontStyle(): string;
  77176. set fontStyle(value: string);
  77177. /** Gets or sets font weight */
  77178. get fontWeight(): string;
  77179. set fontWeight(value: string);
  77180. /** Dispose all associated resources */
  77181. dispose(): void;
  77182. }
  77183. }
  77184. declare module BABYLON.GUI {
  77185. /**
  77186. * Class used to transport BABYLON.Vector2 information for pointer events
  77187. */
  77188. export class Vector2WithInfo extends BABYLON.Vector2 {
  77189. /** defines the current mouse button index */
  77190. buttonIndex: number;
  77191. /**
  77192. * Creates a new Vector2WithInfo
  77193. * @param source defines the vector2 data to transport
  77194. * @param buttonIndex defines the current mouse button index
  77195. */
  77196. constructor(source: BABYLON.Vector2,
  77197. /** defines the current mouse button index */
  77198. buttonIndex?: number);
  77199. }
  77200. /** Class used to provide 2D matrix features */
  77201. export class Matrix2D {
  77202. /** Gets the internal array of 6 floats used to store matrix data */
  77203. m: Float32Array;
  77204. /**
  77205. * Creates a new matrix
  77206. * @param m00 defines value for (0, 0)
  77207. * @param m01 defines value for (0, 1)
  77208. * @param m10 defines value for (1, 0)
  77209. * @param m11 defines value for (1, 1)
  77210. * @param m20 defines value for (2, 0)
  77211. * @param m21 defines value for (2, 1)
  77212. */
  77213. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77214. /**
  77215. * Fills the matrix from direct values
  77216. * @param m00 defines value for (0, 0)
  77217. * @param m01 defines value for (0, 1)
  77218. * @param m10 defines value for (1, 0)
  77219. * @param m11 defines value for (1, 1)
  77220. * @param m20 defines value for (2, 0)
  77221. * @param m21 defines value for (2, 1)
  77222. * @returns the current modified matrix
  77223. */
  77224. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77225. /**
  77226. * Gets matrix determinant
  77227. * @returns the determinant
  77228. */
  77229. determinant(): number;
  77230. /**
  77231. * Inverses the matrix and stores it in a target matrix
  77232. * @param result defines the target matrix
  77233. * @returns the current matrix
  77234. */
  77235. invertToRef(result: Matrix2D): Matrix2D;
  77236. /**
  77237. * Multiplies the current matrix with another one
  77238. * @param other defines the second operand
  77239. * @param result defines the target matrix
  77240. * @returns the current matrix
  77241. */
  77242. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77243. /**
  77244. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77245. * @param x defines the x coordinate to transform
  77246. * @param y defines the x coordinate to transform
  77247. * @param result defines the target vector2
  77248. * @returns the current matrix
  77249. */
  77250. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77251. /**
  77252. * Creates an identity matrix
  77253. * @returns a new matrix
  77254. */
  77255. static Identity(): Matrix2D;
  77256. /**
  77257. * Creates a translation matrix and stores it in a target matrix
  77258. * @param x defines the x coordinate of the translation
  77259. * @param y defines the y coordinate of the translation
  77260. * @param result defines the target matrix
  77261. */
  77262. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77263. /**
  77264. * Creates a scaling matrix and stores it in a target matrix
  77265. * @param x defines the x coordinate of the scaling
  77266. * @param y defines the y coordinate of the scaling
  77267. * @param result defines the target matrix
  77268. */
  77269. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77270. /**
  77271. * Creates a rotation matrix and stores it in a target matrix
  77272. * @param angle defines the rotation angle
  77273. * @param result defines the target matrix
  77274. */
  77275. static RotationToRef(angle: number, result: Matrix2D): void;
  77276. private static _TempPreTranslationMatrix;
  77277. private static _TempPostTranslationMatrix;
  77278. private static _TempRotationMatrix;
  77279. private static _TempScalingMatrix;
  77280. private static _TempCompose0;
  77281. private static _TempCompose1;
  77282. private static _TempCompose2;
  77283. /**
  77284. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77285. * @param tx defines the x coordinate of the translation
  77286. * @param ty defines the y coordinate of the translation
  77287. * @param angle defines the rotation angle
  77288. * @param scaleX defines the x coordinate of the scaling
  77289. * @param scaleY defines the y coordinate of the scaling
  77290. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77291. * @param result defines the target matrix
  77292. */
  77293. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77294. }
  77295. }
  77296. declare module BABYLON.GUI {
  77297. /**
  77298. * Class used to store 2D control sizes
  77299. */
  77300. export class Measure {
  77301. /** defines left coordinate */
  77302. left: number;
  77303. /** defines top coordinate */
  77304. top: number;
  77305. /** defines width dimension */
  77306. width: number;
  77307. /** defines height dimension */
  77308. height: number;
  77309. /**
  77310. * Creates a new measure
  77311. * @param left defines left coordinate
  77312. * @param top defines top coordinate
  77313. * @param width defines width dimension
  77314. * @param height defines height dimension
  77315. */
  77316. constructor(
  77317. /** defines left coordinate */
  77318. left: number,
  77319. /** defines top coordinate */
  77320. top: number,
  77321. /** defines width dimension */
  77322. width: number,
  77323. /** defines height dimension */
  77324. height: number);
  77325. /**
  77326. * Copy from another measure
  77327. * @param other defines the other measure to copy from
  77328. */
  77329. copyFrom(other: Measure): void;
  77330. /**
  77331. * Copy from a group of 4 floats
  77332. * @param left defines left coordinate
  77333. * @param top defines top coordinate
  77334. * @param width defines width dimension
  77335. * @param height defines height dimension
  77336. */
  77337. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77338. /**
  77339. * Computes the axis aligned bounding box measure for two given measures
  77340. * @param a Input measure
  77341. * @param b Input measure
  77342. * @param result the resulting bounding measure
  77343. */
  77344. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77345. /**
  77346. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77347. * @param transform the matrix to transform the measure before computing the AABB
  77348. * @param addX number to add to left
  77349. * @param addY number to add to top
  77350. * @param addWidth number to add to width
  77351. * @param addHeight number to add to height
  77352. * @param result the resulting AABB
  77353. */
  77354. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77355. /**
  77356. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77357. * @param transform the matrix to transform the measure before computing the AABB
  77358. * @param result the resulting AABB
  77359. */
  77360. transformToRef(transform: Matrix2D, result: Measure): void;
  77361. /**
  77362. * Check equality between this measure and another one
  77363. * @param other defines the other measures
  77364. * @returns true if both measures are equals
  77365. */
  77366. isEqualsTo(other: Measure): boolean;
  77367. /**
  77368. * Creates an empty measure
  77369. * @returns a new measure
  77370. */
  77371. static Empty(): Measure;
  77372. }
  77373. }
  77374. declare module BABYLON.GUI {
  77375. /**
  77376. * Interface used to define a control that can receive focus
  77377. */
  77378. export interface IFocusableControl {
  77379. /**
  77380. * Function called when the control receives the focus
  77381. */
  77382. onFocus(): void;
  77383. /**
  77384. * Function called when the control loses the focus
  77385. */
  77386. onBlur(): void;
  77387. /**
  77388. * Function called to let the control handle keyboard events
  77389. * @param evt defines the current keyboard event
  77390. */
  77391. processKeyboard(evt: KeyboardEvent): void;
  77392. /**
  77393. * Function called to get the list of controls that should not steal the focus from this control
  77394. * @returns an array of controls
  77395. */
  77396. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77397. }
  77398. /**
  77399. * Class used to create texture to support 2D GUI elements
  77400. * @see https://doc.babylonjs.com/how_to/gui
  77401. */
  77402. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77403. private _isDirty;
  77404. private _renderObserver;
  77405. private _resizeObserver;
  77406. private _preKeyboardObserver;
  77407. private _pointerMoveObserver;
  77408. private _pointerObserver;
  77409. private _canvasPointerOutObserver;
  77410. private _canvasBlurObserver;
  77411. private _background;
  77412. /** @hidden */
  77413. _rootContainer: Container;
  77414. /** @hidden */
  77415. _lastPickedControl: Control;
  77416. /** @hidden */
  77417. _lastControlOver: {
  77418. [pointerId: number]: Control;
  77419. };
  77420. /** @hidden */
  77421. _lastControlDown: {
  77422. [pointerId: number]: Control;
  77423. };
  77424. /** @hidden */
  77425. _capturingControl: {
  77426. [pointerId: number]: Control;
  77427. };
  77428. /** @hidden */
  77429. _shouldBlockPointer: boolean;
  77430. /** @hidden */
  77431. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77432. /** @hidden */
  77433. _linkedControls: Control[];
  77434. private _isFullscreen;
  77435. private _fullscreenViewport;
  77436. private _idealWidth;
  77437. private _idealHeight;
  77438. private _useSmallestIdeal;
  77439. private _renderAtIdealSize;
  77440. private _focusedControl;
  77441. private _blockNextFocusCheck;
  77442. private _renderScale;
  77443. private _rootElement;
  77444. private _cursorChanged;
  77445. private _defaultMousePointerId;
  77446. /** @hidden */
  77447. _numLayoutCalls: number;
  77448. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77449. get numLayoutCalls(): number;
  77450. /** @hidden */
  77451. _numRenderCalls: number;
  77452. /** Gets the number of render calls made the last time the ADT has been rendered */
  77453. get numRenderCalls(): number;
  77454. /**
  77455. * Define type to string to ensure compatibility across browsers
  77456. * Safari doesn't support DataTransfer constructor
  77457. */
  77458. private _clipboardData;
  77459. /**
  77460. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77461. */
  77462. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77463. /**
  77464. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77465. */
  77466. onControlPickedObservable: BABYLON.Observable<Control>;
  77467. /**
  77468. * BABYLON.Observable event triggered before layout is evaluated
  77469. */
  77470. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77471. /**
  77472. * BABYLON.Observable event triggered after the layout was evaluated
  77473. */
  77474. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77475. /**
  77476. * BABYLON.Observable event triggered before the texture is rendered
  77477. */
  77478. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77479. /**
  77480. * BABYLON.Observable event triggered after the texture was rendered
  77481. */
  77482. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77483. /**
  77484. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77485. */
  77486. premulAlpha: boolean;
  77487. /**
  77488. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77489. * Useful when you want more antialiasing
  77490. */
  77491. get renderScale(): number;
  77492. set renderScale(value: number);
  77493. /** Gets or sets the background color */
  77494. get background(): string;
  77495. set background(value: string);
  77496. /**
  77497. * Gets or sets the ideal width used to design controls.
  77498. * The GUI will then rescale everything accordingly
  77499. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77500. */
  77501. get idealWidth(): number;
  77502. set idealWidth(value: number);
  77503. /**
  77504. * Gets or sets the ideal height used to design controls.
  77505. * The GUI will then rescale everything accordingly
  77506. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77507. */
  77508. get idealHeight(): number;
  77509. set idealHeight(value: number);
  77510. /**
  77511. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77512. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77513. */
  77514. get useSmallestIdeal(): boolean;
  77515. set useSmallestIdeal(value: boolean);
  77516. /**
  77517. * Gets or sets a boolean indicating if adaptive scaling must be used
  77518. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77519. */
  77520. get renderAtIdealSize(): boolean;
  77521. set renderAtIdealSize(value: boolean);
  77522. /**
  77523. * Gets the ratio used when in "ideal mode"
  77524. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77525. * */
  77526. get idealRatio(): number;
  77527. /**
  77528. * Gets the underlying layer used to render the texture when in fullscreen mode
  77529. */
  77530. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77531. /**
  77532. * Gets the root container control
  77533. */
  77534. get rootContainer(): Container;
  77535. /**
  77536. * Returns an array containing the root container.
  77537. * This is mostly used to let the Inspector introspects the ADT
  77538. * @returns an array containing the rootContainer
  77539. */
  77540. getChildren(): Array<Container>;
  77541. /**
  77542. * Will return all controls that are inside this texture
  77543. * @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
  77544. * @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
  77545. * @return all child controls
  77546. */
  77547. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77548. /**
  77549. * Gets or sets the current focused control
  77550. */
  77551. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77552. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77553. /**
  77554. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77555. */
  77556. get isForeground(): boolean;
  77557. set isForeground(value: boolean);
  77558. /**
  77559. * Gets or set information about clipboardData
  77560. */
  77561. get clipboardData(): string;
  77562. set clipboardData(value: string);
  77563. /**
  77564. * Creates a new AdvancedDynamicTexture
  77565. * @param name defines the name of the texture
  77566. * @param width defines the width of the texture
  77567. * @param height defines the height of the texture
  77568. * @param scene defines the hosting scene
  77569. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77570. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77571. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77572. */
  77573. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77574. /**
  77575. * Get the current class name of the texture useful for serialization or dynamic coding.
  77576. * @returns "AdvancedDynamicTexture"
  77577. */
  77578. getClassName(): string;
  77579. /**
  77580. * Function used to execute a function on all controls
  77581. * @param func defines the function to execute
  77582. * @param container defines the container where controls belong. If null the root container will be used
  77583. */
  77584. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77585. private _useInvalidateRectOptimization;
  77586. /**
  77587. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77588. */
  77589. get useInvalidateRectOptimization(): boolean;
  77590. set useInvalidateRectOptimization(value: boolean);
  77591. private _invalidatedRectangle;
  77592. /**
  77593. * Invalidates a rectangle area on the gui texture
  77594. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77595. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77596. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77597. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77598. */
  77599. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77600. /**
  77601. * Marks the texture as dirty forcing a complete update
  77602. */
  77603. markAsDirty(): void;
  77604. /**
  77605. * Helper function used to create a new style
  77606. * @returns a new style
  77607. * @see https://doc.babylonjs.com/how_to/gui#styles
  77608. */
  77609. createStyle(): Style;
  77610. /**
  77611. * Adds a new control to the root container
  77612. * @param control defines the control to add
  77613. * @returns the current texture
  77614. */
  77615. addControl(control: Control): AdvancedDynamicTexture;
  77616. /**
  77617. * Removes a control from the root container
  77618. * @param control defines the control to remove
  77619. * @returns the current texture
  77620. */
  77621. removeControl(control: Control): AdvancedDynamicTexture;
  77622. /**
  77623. * Release all resources
  77624. */
  77625. dispose(): void;
  77626. private _onResize;
  77627. /** @hidden */
  77628. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77629. /**
  77630. * Get screen coordinates for a vector3
  77631. * @param position defines the position to project
  77632. * @param worldMatrix defines the world matrix to use
  77633. * @returns the projected position
  77634. */
  77635. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77636. private _checkUpdate;
  77637. private _clearMeasure;
  77638. private _render;
  77639. /** @hidden */
  77640. _changeCursor(cursor: string): void;
  77641. /** @hidden */
  77642. _registerLastControlDown(control: Control, pointerId: number): void;
  77643. private _doPicking;
  77644. /** @hidden */
  77645. _cleanControlAfterRemovalFromList(list: {
  77646. [pointerId: number]: Control;
  77647. }, control: Control): void;
  77648. /** @hidden */
  77649. _cleanControlAfterRemoval(control: Control): void;
  77650. /** Attach to all scene events required to support pointer events */
  77651. attach(): void;
  77652. /** @hidden */
  77653. private onClipboardCopy;
  77654. /** @hidden */
  77655. private onClipboardCut;
  77656. /** @hidden */
  77657. private onClipboardPaste;
  77658. /**
  77659. * Register the clipboard Events onto the canvas
  77660. */
  77661. registerClipboardEvents(): void;
  77662. /**
  77663. * Unregister the clipboard Events from the canvas
  77664. */
  77665. unRegisterClipboardEvents(): void;
  77666. /**
  77667. * Connect the texture to a hosting mesh to enable interactions
  77668. * @param mesh defines the mesh to attach to
  77669. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77670. */
  77671. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77672. /**
  77673. * Move the focus to a specific control
  77674. * @param control defines the control which will receive the focus
  77675. */
  77676. moveFocusToControl(control: IFocusableControl): void;
  77677. private _manageFocus;
  77678. private _attachToOnPointerOut;
  77679. private _attachToOnBlur;
  77680. /**
  77681. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77682. * @param mesh defines the mesh which will receive the texture
  77683. * @param width defines the texture width (1024 by default)
  77684. * @param height defines the texture height (1024 by default)
  77685. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77686. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77687. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77688. * @returns a new AdvancedDynamicTexture
  77689. */
  77690. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77691. /**
  77692. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77693. * In this mode the texture will rely on a layer for its rendering.
  77694. * This allows it to be treated like any other layer.
  77695. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77696. * LayerMask is set through advancedTexture.layer.layerMask
  77697. * @param name defines name for the texture
  77698. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77699. * @param scene defines the hsoting scene
  77700. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77701. * @returns a new AdvancedDynamicTexture
  77702. */
  77703. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77704. }
  77705. }
  77706. declare module BABYLON.GUI {
  77707. /**
  77708. * Root class used for all 2D controls
  77709. * @see https://doc.babylonjs.com/how_to/gui#controls
  77710. */
  77711. export class Control {
  77712. /** defines the name of the control */
  77713. name?: string | undefined;
  77714. /**
  77715. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77716. */
  77717. static AllowAlphaInheritance: boolean;
  77718. private _alpha;
  77719. private _alphaSet;
  77720. private _zIndex;
  77721. /** @hidden */
  77722. _host: AdvancedDynamicTexture;
  77723. /** Gets or sets the control parent */
  77724. parent: BABYLON.Nullable<Container>;
  77725. /** @hidden */
  77726. _currentMeasure: Measure;
  77727. private _fontFamily;
  77728. private _fontStyle;
  77729. private _fontWeight;
  77730. private _fontSize;
  77731. private _font;
  77732. /** @hidden */
  77733. _width: ValueAndUnit;
  77734. /** @hidden */
  77735. _height: ValueAndUnit;
  77736. /** @hidden */
  77737. protected _fontOffset: {
  77738. ascent: number;
  77739. height: number;
  77740. descent: number;
  77741. };
  77742. private _color;
  77743. private _style;
  77744. private _styleObserver;
  77745. /** @hidden */
  77746. protected _horizontalAlignment: number;
  77747. /** @hidden */
  77748. protected _verticalAlignment: number;
  77749. /** @hidden */
  77750. protected _isDirty: boolean;
  77751. /** @hidden */
  77752. protected _wasDirty: boolean;
  77753. /** @hidden */
  77754. _tempParentMeasure: Measure;
  77755. /** @hidden */
  77756. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77757. /** @hidden */
  77758. protected _cachedParentMeasure: Measure;
  77759. private _paddingLeft;
  77760. private _paddingRight;
  77761. private _paddingTop;
  77762. private _paddingBottom;
  77763. /** @hidden */
  77764. _left: ValueAndUnit;
  77765. /** @hidden */
  77766. _top: ValueAndUnit;
  77767. private _scaleX;
  77768. private _scaleY;
  77769. private _rotation;
  77770. private _transformCenterX;
  77771. private _transformCenterY;
  77772. /** @hidden */
  77773. _transformMatrix: Matrix2D;
  77774. /** @hidden */
  77775. protected _invertTransformMatrix: Matrix2D;
  77776. /** @hidden */
  77777. protected _transformedPosition: BABYLON.Vector2;
  77778. private _isMatrixDirty;
  77779. private _cachedOffsetX;
  77780. private _cachedOffsetY;
  77781. private _isVisible;
  77782. private _isHighlighted;
  77783. /** @hidden */
  77784. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77785. private _fontSet;
  77786. private _dummyVector2;
  77787. private _downCount;
  77788. private _enterCount;
  77789. private _doNotRender;
  77790. private _downPointerIds;
  77791. protected _isEnabled: boolean;
  77792. protected _disabledColor: string;
  77793. protected _disabledColorItem: string;
  77794. /** @hidden */
  77795. protected _rebuildLayout: boolean;
  77796. /** @hidden */
  77797. _customData: any;
  77798. /** @hidden */
  77799. _isClipped: boolean;
  77800. /** @hidden */
  77801. _automaticSize: boolean;
  77802. /** @hidden */
  77803. _tag: any;
  77804. /**
  77805. * 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
  77806. */
  77807. uniqueId: number;
  77808. /**
  77809. * Gets or sets an object used to store user defined information for the node
  77810. */
  77811. metadata: any;
  77812. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77813. isHitTestVisible: boolean;
  77814. /** Gets or sets a boolean indicating if the control can block pointer events */
  77815. isPointerBlocker: boolean;
  77816. /** Gets or sets a boolean indicating if the control can be focusable */
  77817. isFocusInvisible: boolean;
  77818. /**
  77819. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77820. * 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
  77821. */
  77822. clipChildren: boolean;
  77823. /**
  77824. * Gets or sets a boolean indicating that control content must be clipped
  77825. * 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
  77826. */
  77827. clipContent: boolean;
  77828. /**
  77829. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77830. */
  77831. useBitmapCache: boolean;
  77832. private _cacheData;
  77833. private _shadowOffsetX;
  77834. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77835. get shadowOffsetX(): number;
  77836. set shadowOffsetX(value: number);
  77837. private _shadowOffsetY;
  77838. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77839. get shadowOffsetY(): number;
  77840. set shadowOffsetY(value: number);
  77841. private _shadowBlur;
  77842. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77843. get shadowBlur(): number;
  77844. set shadowBlur(value: number);
  77845. private _shadowColor;
  77846. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77847. get shadowColor(): string;
  77848. set shadowColor(value: string);
  77849. /** Gets or sets the cursor to use when the control is hovered */
  77850. hoverCursor: string;
  77851. /** @hidden */
  77852. protected _linkOffsetX: ValueAndUnit;
  77853. /** @hidden */
  77854. protected _linkOffsetY: ValueAndUnit;
  77855. /** Gets the control type name */
  77856. get typeName(): string;
  77857. /**
  77858. * Get the current class name of the control.
  77859. * @returns current class name
  77860. */
  77861. getClassName(): string;
  77862. /**
  77863. * An event triggered when pointer wheel is scrolled
  77864. */
  77865. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77866. /**
  77867. * An event triggered when the pointer move over the control.
  77868. */
  77869. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77870. /**
  77871. * An event triggered when the pointer move out of the control.
  77872. */
  77873. onPointerOutObservable: BABYLON.Observable<Control>;
  77874. /**
  77875. * An event triggered when the pointer taps the control
  77876. */
  77877. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77878. /**
  77879. * An event triggered when pointer up
  77880. */
  77881. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77882. /**
  77883. * An event triggered when a control is clicked on
  77884. */
  77885. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77886. /**
  77887. * An event triggered when pointer enters the control
  77888. */
  77889. onPointerEnterObservable: BABYLON.Observable<Control>;
  77890. /**
  77891. * An event triggered when the control is marked as dirty
  77892. */
  77893. onDirtyObservable: BABYLON.Observable<Control>;
  77894. /**
  77895. * An event triggered before drawing the control
  77896. */
  77897. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77898. /**
  77899. * An event triggered after the control was drawn
  77900. */
  77901. onAfterDrawObservable: BABYLON.Observable<Control>;
  77902. /**
  77903. * An event triggered when the control has been disposed
  77904. */
  77905. onDisposeObservable: BABYLON.Observable<Control>;
  77906. /**
  77907. * Get the hosting AdvancedDynamicTexture
  77908. */
  77909. get host(): AdvancedDynamicTexture;
  77910. /** Gets or set information about font offsets (used to render and align text) */
  77911. get fontOffset(): {
  77912. ascent: number;
  77913. height: number;
  77914. descent: number;
  77915. };
  77916. set fontOffset(offset: {
  77917. ascent: number;
  77918. height: number;
  77919. descent: number;
  77920. });
  77921. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77922. get alpha(): number;
  77923. set alpha(value: number);
  77924. /**
  77925. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77926. */
  77927. get isHighlighted(): boolean;
  77928. set isHighlighted(value: boolean);
  77929. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77930. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77931. */
  77932. get scaleX(): number;
  77933. set scaleX(value: number);
  77934. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77935. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77936. */
  77937. get scaleY(): number;
  77938. set scaleY(value: number);
  77939. /** Gets or sets the rotation angle (0 by default)
  77940. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77941. */
  77942. get rotation(): number;
  77943. set rotation(value: number);
  77944. /** Gets or sets the transformation center on Y axis (0 by default)
  77945. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77946. */
  77947. get transformCenterY(): number;
  77948. set transformCenterY(value: number);
  77949. /** Gets or sets the transformation center on X axis (0 by default)
  77950. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77951. */
  77952. get transformCenterX(): number;
  77953. set transformCenterX(value: number);
  77954. /**
  77955. * Gets or sets the horizontal alignment
  77956. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77957. */
  77958. get horizontalAlignment(): number;
  77959. set horizontalAlignment(value: number);
  77960. /**
  77961. * Gets or sets the vertical alignment
  77962. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77963. */
  77964. get verticalAlignment(): number;
  77965. set verticalAlignment(value: number);
  77966. /**
  77967. * Gets or sets a fixed ratio for this control.
  77968. * When different from 0, the ratio is used to compute the "second" dimension.
  77969. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77970. * second dimension is computed as first dimension * fixedRatio
  77971. */
  77972. fixedRatio: number;
  77973. private _fixedRatioMasterIsWidth;
  77974. /**
  77975. * Gets or sets control width
  77976. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77977. */
  77978. get width(): string | number;
  77979. set width(value: string | number);
  77980. /**
  77981. * Gets or sets the control width in pixel
  77982. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77983. */
  77984. get widthInPixels(): number;
  77985. set widthInPixels(value: number);
  77986. /**
  77987. * Gets or sets control height
  77988. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77989. */
  77990. get height(): string | number;
  77991. set height(value: string | number);
  77992. /**
  77993. * Gets or sets control height in pixel
  77994. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77995. */
  77996. get heightInPixels(): number;
  77997. set heightInPixels(value: number);
  77998. /** Gets or set font family */
  77999. get fontFamily(): string;
  78000. set fontFamily(value: string);
  78001. /** Gets or sets font style */
  78002. get fontStyle(): string;
  78003. set fontStyle(value: string);
  78004. /** Gets or sets font weight */
  78005. get fontWeight(): string;
  78006. set fontWeight(value: string);
  78007. /**
  78008. * Gets or sets style
  78009. * @see https://doc.babylonjs.com/how_to/gui#styles
  78010. */
  78011. get style(): BABYLON.Nullable<Style>;
  78012. set style(value: BABYLON.Nullable<Style>);
  78013. /** @hidden */
  78014. get _isFontSizeInPercentage(): boolean;
  78015. /** Gets or sets font size in pixels */
  78016. get fontSizeInPixels(): number;
  78017. set fontSizeInPixels(value: number);
  78018. /** Gets or sets font size */
  78019. get fontSize(): string | number;
  78020. set fontSize(value: string | number);
  78021. /** Gets or sets foreground color */
  78022. get color(): string;
  78023. set color(value: string);
  78024. /** Gets or sets z index which is used to reorder controls on the z axis */
  78025. get zIndex(): number;
  78026. set zIndex(value: number);
  78027. /** Gets or sets a boolean indicating if the control can be rendered */
  78028. get notRenderable(): boolean;
  78029. set notRenderable(value: boolean);
  78030. /** Gets or sets a boolean indicating if the control is visible */
  78031. get isVisible(): boolean;
  78032. set isVisible(value: boolean);
  78033. /** Gets a boolean indicating that the control needs to update its rendering */
  78034. get isDirty(): boolean;
  78035. /**
  78036. * Gets the current linked mesh (or null if none)
  78037. */
  78038. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78039. /**
  78040. * Gets or sets a value indicating the padding to use on the left of the control
  78041. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78042. */
  78043. get paddingLeft(): string | number;
  78044. set paddingLeft(value: string | number);
  78045. /**
  78046. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78047. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78048. */
  78049. get paddingLeftInPixels(): number;
  78050. set paddingLeftInPixels(value: number);
  78051. /**
  78052. * Gets or sets a value indicating the padding to use on the right of the control
  78053. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78054. */
  78055. get paddingRight(): string | number;
  78056. set paddingRight(value: string | number);
  78057. /**
  78058. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78059. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78060. */
  78061. get paddingRightInPixels(): number;
  78062. set paddingRightInPixels(value: number);
  78063. /**
  78064. * Gets or sets a value indicating the padding to use on the top of the control
  78065. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78066. */
  78067. get paddingTop(): string | number;
  78068. set paddingTop(value: string | number);
  78069. /**
  78070. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78071. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78072. */
  78073. get paddingTopInPixels(): number;
  78074. set paddingTopInPixels(value: number);
  78075. /**
  78076. * Gets or sets a value indicating the padding to use on the bottom of the control
  78077. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78078. */
  78079. get paddingBottom(): string | number;
  78080. set paddingBottom(value: string | number);
  78081. /**
  78082. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78083. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78084. */
  78085. get paddingBottomInPixels(): number;
  78086. set paddingBottomInPixels(value: number);
  78087. /**
  78088. * Gets or sets a value indicating the left coordinate of the control
  78089. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78090. */
  78091. get left(): string | number;
  78092. set left(value: string | number);
  78093. /**
  78094. * Gets or sets a value indicating the left coordinate in pixels of the control
  78095. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78096. */
  78097. get leftInPixels(): number;
  78098. set leftInPixels(value: number);
  78099. /**
  78100. * Gets or sets a value indicating the top coordinate of the control
  78101. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78102. */
  78103. get top(): string | number;
  78104. set top(value: string | number);
  78105. /**
  78106. * Gets or sets a value indicating the top coordinate in pixels of the control
  78107. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78108. */
  78109. get topInPixels(): number;
  78110. set topInPixels(value: number);
  78111. /**
  78112. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78113. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78114. */
  78115. get linkOffsetX(): string | number;
  78116. set linkOffsetX(value: string | number);
  78117. /**
  78118. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78119. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78120. */
  78121. get linkOffsetXInPixels(): number;
  78122. set linkOffsetXInPixels(value: number);
  78123. /**
  78124. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78125. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78126. */
  78127. get linkOffsetY(): string | number;
  78128. set linkOffsetY(value: string | number);
  78129. /**
  78130. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78131. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78132. */
  78133. get linkOffsetYInPixels(): number;
  78134. set linkOffsetYInPixels(value: number);
  78135. /** Gets the center coordinate on X axis */
  78136. get centerX(): number;
  78137. /** Gets the center coordinate on Y axis */
  78138. get centerY(): number;
  78139. /** Gets or sets if control is Enabled*/
  78140. get isEnabled(): boolean;
  78141. set isEnabled(value: boolean);
  78142. /** Gets or sets background color of control if it's disabled*/
  78143. get disabledColor(): string;
  78144. set disabledColor(value: string);
  78145. /** Gets or sets front color of control if it's disabled*/
  78146. get disabledColorItem(): string;
  78147. set disabledColorItem(value: string);
  78148. /**
  78149. * Creates a new control
  78150. * @param name defines the name of the control
  78151. */
  78152. constructor(
  78153. /** defines the name of the control */
  78154. name?: string | undefined);
  78155. /** @hidden */
  78156. protected _getTypeName(): string;
  78157. /**
  78158. * Gets the first ascendant in the hierarchy of the given type
  78159. * @param className defines the required type
  78160. * @returns the ascendant or null if not found
  78161. */
  78162. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78163. /** @hidden */
  78164. _resetFontCache(): void;
  78165. /**
  78166. * Determines if a container is an ascendant of the current control
  78167. * @param container defines the container to look for
  78168. * @returns true if the container is one of the ascendant of the control
  78169. */
  78170. isAscendant(container: Control): boolean;
  78171. /**
  78172. * Gets coordinates in local control space
  78173. * @param globalCoordinates defines the coordinates to transform
  78174. * @returns the new coordinates in local space
  78175. */
  78176. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78177. /**
  78178. * Gets coordinates in local control space
  78179. * @param globalCoordinates defines the coordinates to transform
  78180. * @param result defines the target vector2 where to store the result
  78181. * @returns the current control
  78182. */
  78183. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78184. /**
  78185. * Gets coordinates in parent local control space
  78186. * @param globalCoordinates defines the coordinates to transform
  78187. * @returns the new coordinates in parent local space
  78188. */
  78189. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78190. /**
  78191. * Move the current control to a vector3 position projected onto the screen.
  78192. * @param position defines the target position
  78193. * @param scene defines the hosting scene
  78194. */
  78195. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78196. /**
  78197. * Will store all controls that have this control as ascendant in a given array
  78198. * @param results defines the array where to store the descendants
  78199. * @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
  78200. * @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
  78201. */
  78202. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78203. /**
  78204. * Will return all controls that have this control as ascendant
  78205. * @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
  78206. * @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
  78207. * @return all child controls
  78208. */
  78209. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78210. /**
  78211. * Link current control with a target mesh
  78212. * @param mesh defines the mesh to link with
  78213. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78214. */
  78215. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  78216. /** @hidden */
  78217. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78218. /** @hidden */
  78219. _offsetLeft(offset: number): void;
  78220. /** @hidden */
  78221. _offsetTop(offset: number): void;
  78222. /** @hidden */
  78223. _markMatrixAsDirty(): void;
  78224. /** @hidden */
  78225. _flagDescendantsAsMatrixDirty(): void;
  78226. /** @hidden */
  78227. _intersectsRect(rect: Measure): boolean;
  78228. /** @hidden */
  78229. protected invalidateRect(): void;
  78230. /** @hidden */
  78231. _markAsDirty(force?: boolean): void;
  78232. /** @hidden */
  78233. _markAllAsDirty(): void;
  78234. /** @hidden */
  78235. _link(host: AdvancedDynamicTexture): void;
  78236. /** @hidden */
  78237. protected _transform(context?: CanvasRenderingContext2D): void;
  78238. /** @hidden */
  78239. _renderHighlight(context: CanvasRenderingContext2D): void;
  78240. /** @hidden */
  78241. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78242. /** @hidden */
  78243. protected _applyStates(context: CanvasRenderingContext2D): void;
  78244. /** @hidden */
  78245. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78246. /** @hidden */
  78247. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78248. protected _evaluateClippingState(parentMeasure: Measure): void;
  78249. /** @hidden */
  78250. _measure(): void;
  78251. /** @hidden */
  78252. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78253. /** @hidden */
  78254. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78255. /** @hidden */
  78256. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78257. /** @hidden */
  78258. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78259. private static _ClipMeasure;
  78260. private _tmpMeasureA;
  78261. private _clip;
  78262. /** @hidden */
  78263. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78264. /** @hidden */
  78265. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78266. /**
  78267. * Tests if a given coordinates belong to the current control
  78268. * @param x defines x coordinate to test
  78269. * @param y defines y coordinate to test
  78270. * @returns true if the coordinates are inside the control
  78271. */
  78272. contains(x: number, y: number): boolean;
  78273. /** @hidden */
  78274. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78275. /** @hidden */
  78276. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78277. /** @hidden */
  78278. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78279. /** @hidden */
  78280. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78281. /** @hidden */
  78282. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78283. /** @hidden */
  78284. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78285. /** @hidden */
  78286. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78287. /** @hidden */
  78288. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78289. /** @hidden */
  78290. _onCanvasBlur(): void;
  78291. /** @hidden */
  78292. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78293. private _prepareFont;
  78294. /** Releases associated resources */
  78295. dispose(): void;
  78296. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78297. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78298. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78299. private static _VERTICAL_ALIGNMENT_TOP;
  78300. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78301. private static _VERTICAL_ALIGNMENT_CENTER;
  78302. /** HORIZONTAL_ALIGNMENT_LEFT */
  78303. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78304. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78305. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78306. /** HORIZONTAL_ALIGNMENT_CENTER */
  78307. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78308. /** VERTICAL_ALIGNMENT_TOP */
  78309. static get VERTICAL_ALIGNMENT_TOP(): number;
  78310. /** VERTICAL_ALIGNMENT_BOTTOM */
  78311. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78312. /** VERTICAL_ALIGNMENT_CENTER */
  78313. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78314. private static _FontHeightSizes;
  78315. /** @hidden */
  78316. static _GetFontOffset(font: string): {
  78317. ascent: number;
  78318. height: number;
  78319. descent: number;
  78320. };
  78321. /**
  78322. * Creates a stack panel that can be used to render headers
  78323. * @param control defines the control to associate with the header
  78324. * @param text defines the text of the header
  78325. * @param size defines the size of the header
  78326. * @param options defines options used to configure the header
  78327. * @returns a new StackPanel
  78328. * @ignore
  78329. * @hidden
  78330. */
  78331. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78332. isHorizontal: boolean;
  78333. controlFirst: boolean;
  78334. }) => any;
  78335. /** @hidden */
  78336. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78337. }
  78338. }
  78339. declare module BABYLON.GUI {
  78340. /**
  78341. * Root class for 2D containers
  78342. * @see https://doc.babylonjs.com/how_to/gui#containers
  78343. */
  78344. export class Container extends Control {
  78345. name?: string | undefined;
  78346. /** @hidden */
  78347. _children: Control[];
  78348. /** @hidden */
  78349. protected _measureForChildren: Measure;
  78350. /** @hidden */
  78351. protected _background: string;
  78352. /** @hidden */
  78353. protected _adaptWidthToChildren: boolean;
  78354. /** @hidden */
  78355. protected _adaptHeightToChildren: boolean;
  78356. /**
  78357. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78358. */
  78359. logLayoutCycleErrors: boolean;
  78360. /**
  78361. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78362. */
  78363. maxLayoutCycle: number;
  78364. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78365. get adaptHeightToChildren(): boolean;
  78366. set adaptHeightToChildren(value: boolean);
  78367. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78368. get adaptWidthToChildren(): boolean;
  78369. set adaptWidthToChildren(value: boolean);
  78370. /** Gets or sets background color */
  78371. get background(): string;
  78372. set background(value: string);
  78373. /** Gets the list of children */
  78374. get children(): Control[];
  78375. /**
  78376. * Creates a new Container
  78377. * @param name defines the name of the container
  78378. */
  78379. constructor(name?: string | undefined);
  78380. protected _getTypeName(): string;
  78381. _flagDescendantsAsMatrixDirty(): void;
  78382. /**
  78383. * Gets a child using its name
  78384. * @param name defines the child name to look for
  78385. * @returns the child control if found
  78386. */
  78387. getChildByName(name: string): BABYLON.Nullable<Control>;
  78388. /**
  78389. * Gets a child using its type and its name
  78390. * @param name defines the child name to look for
  78391. * @param type defines the child type to look for
  78392. * @returns the child control if found
  78393. */
  78394. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78395. /**
  78396. * Search for a specific control in children
  78397. * @param control defines the control to look for
  78398. * @returns true if the control is in child list
  78399. */
  78400. containsControl(control: Control): boolean;
  78401. /**
  78402. * Adds a new control to the current container
  78403. * @param control defines the control to add
  78404. * @returns the current container
  78405. */
  78406. addControl(control: BABYLON.Nullable<Control>): Container;
  78407. /**
  78408. * Removes all controls from the current container
  78409. * @returns the current container
  78410. */
  78411. clearControls(): Container;
  78412. /**
  78413. * Removes a control from the current container
  78414. * @param control defines the control to remove
  78415. * @returns the current container
  78416. */
  78417. removeControl(control: Control): Container;
  78418. /** @hidden */
  78419. _reOrderControl(control: Control): void;
  78420. /** @hidden */
  78421. _offsetLeft(offset: number): void;
  78422. /** @hidden */
  78423. _offsetTop(offset: number): void;
  78424. /** @hidden */
  78425. _markAllAsDirty(): void;
  78426. /** @hidden */
  78427. protected _localDraw(context: CanvasRenderingContext2D): void;
  78428. /** @hidden */
  78429. _link(host: AdvancedDynamicTexture): void;
  78430. /** @hidden */
  78431. protected _beforeLayout(): void;
  78432. /** @hidden */
  78433. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78434. /** @hidden */
  78435. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78436. protected _postMeasure(): void;
  78437. /** @hidden */
  78438. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78439. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78440. /** @hidden */
  78441. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78442. /** @hidden */
  78443. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78444. /** Releases associated resources */
  78445. dispose(): void;
  78446. }
  78447. }
  78448. declare module BABYLON.GUI {
  78449. /** Class used to create rectangle container */
  78450. export class Rectangle extends Container {
  78451. name?: string | undefined;
  78452. private _thickness;
  78453. private _cornerRadius;
  78454. /** Gets or sets border thickness */
  78455. get thickness(): number;
  78456. set thickness(value: number);
  78457. /** Gets or sets the corner radius angle */
  78458. get cornerRadius(): number;
  78459. set cornerRadius(value: number);
  78460. /**
  78461. * Creates a new Rectangle
  78462. * @param name defines the control name
  78463. */
  78464. constructor(name?: string | undefined);
  78465. protected _getTypeName(): string;
  78466. protected _localDraw(context: CanvasRenderingContext2D): void;
  78467. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78468. private _drawRoundedRect;
  78469. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78470. }
  78471. }
  78472. declare module BABYLON.GUI {
  78473. /**
  78474. * Enum that determines the text-wrapping mode to use.
  78475. */
  78476. export enum TextWrapping {
  78477. /**
  78478. * Clip the text when it's larger than Control.width; this is the default mode.
  78479. */
  78480. Clip = 0,
  78481. /**
  78482. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78483. */
  78484. WordWrap = 1,
  78485. /**
  78486. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78487. */
  78488. Ellipsis = 2
  78489. }
  78490. /**
  78491. * Class used to create text block control
  78492. */
  78493. export class TextBlock extends Control {
  78494. /**
  78495. * Defines the name of the control
  78496. */
  78497. name?: string | undefined;
  78498. private _text;
  78499. private _textWrapping;
  78500. private _textHorizontalAlignment;
  78501. private _textVerticalAlignment;
  78502. private _lines;
  78503. private _resizeToFit;
  78504. private _lineSpacing;
  78505. private _outlineWidth;
  78506. private _outlineColor;
  78507. private _underline;
  78508. private _lineThrough;
  78509. /**
  78510. * An event triggered after the text is changed
  78511. */
  78512. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78513. /**
  78514. * An event triggered after the text was broken up into lines
  78515. */
  78516. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78517. /**
  78518. * Function used to split a string into words. By default, a string is split at each space character found
  78519. */
  78520. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78521. /**
  78522. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78523. */
  78524. get lines(): any[];
  78525. /**
  78526. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78527. */
  78528. get resizeToFit(): boolean;
  78529. /**
  78530. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78531. */
  78532. set resizeToFit(value: boolean);
  78533. /**
  78534. * Gets or sets a boolean indicating if text must be wrapped
  78535. */
  78536. get textWrapping(): TextWrapping | boolean;
  78537. /**
  78538. * Gets or sets a boolean indicating if text must be wrapped
  78539. */
  78540. set textWrapping(value: TextWrapping | boolean);
  78541. /**
  78542. * Gets or sets text to display
  78543. */
  78544. get text(): string;
  78545. /**
  78546. * Gets or sets text to display
  78547. */
  78548. set text(value: string);
  78549. /**
  78550. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78551. */
  78552. get textHorizontalAlignment(): number;
  78553. /**
  78554. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78555. */
  78556. set textHorizontalAlignment(value: number);
  78557. /**
  78558. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78559. */
  78560. get textVerticalAlignment(): number;
  78561. /**
  78562. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78563. */
  78564. set textVerticalAlignment(value: number);
  78565. /**
  78566. * Gets or sets line spacing value
  78567. */
  78568. set lineSpacing(value: string | number);
  78569. /**
  78570. * Gets or sets line spacing value
  78571. */
  78572. get lineSpacing(): string | number;
  78573. /**
  78574. * Gets or sets outlineWidth of the text to display
  78575. */
  78576. get outlineWidth(): number;
  78577. /**
  78578. * Gets or sets outlineWidth of the text to display
  78579. */
  78580. set outlineWidth(value: number);
  78581. /**
  78582. * Gets or sets a boolean indicating that text must have underline
  78583. */
  78584. get underline(): boolean;
  78585. /**
  78586. * Gets or sets a boolean indicating that text must have underline
  78587. */
  78588. set underline(value: boolean);
  78589. /**
  78590. * Gets or sets an boolean indicating that text must be crossed out
  78591. */
  78592. get lineThrough(): boolean;
  78593. /**
  78594. * Gets or sets an boolean indicating that text must be crossed out
  78595. */
  78596. set lineThrough(value: boolean);
  78597. /**
  78598. * Gets or sets outlineColor of the text to display
  78599. */
  78600. get outlineColor(): string;
  78601. /**
  78602. * Gets or sets outlineColor of the text to display
  78603. */
  78604. set outlineColor(value: string);
  78605. /**
  78606. * Creates a new TextBlock object
  78607. * @param name defines the name of the control
  78608. * @param text defines the text to display (emptry string by default)
  78609. */
  78610. constructor(
  78611. /**
  78612. * Defines the name of the control
  78613. */
  78614. name?: string | undefined, text?: string);
  78615. protected _getTypeName(): string;
  78616. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78617. private _drawText;
  78618. /** @hidden */
  78619. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78620. protected _applyStates(context: CanvasRenderingContext2D): void;
  78621. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78622. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78623. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78624. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78625. protected _renderLines(context: CanvasRenderingContext2D): void;
  78626. /**
  78627. * Given a width constraint applied on the text block, find the expected height
  78628. * @returns expected height
  78629. */
  78630. computeExpectedHeight(): number;
  78631. dispose(): void;
  78632. }
  78633. }
  78634. declare module BABYLON.GUI {
  78635. /**
  78636. * Class used to create 2D images
  78637. */
  78638. export class Image extends Control {
  78639. name?: string | undefined;
  78640. private _workingCanvas;
  78641. private _domImage;
  78642. private _imageWidth;
  78643. private _imageHeight;
  78644. private _loaded;
  78645. private _stretch;
  78646. private _source;
  78647. private _autoScale;
  78648. private _sourceLeft;
  78649. private _sourceTop;
  78650. private _sourceWidth;
  78651. private _sourceHeight;
  78652. private _svgAttributesComputationCompleted;
  78653. private _isSVG;
  78654. private _cellWidth;
  78655. private _cellHeight;
  78656. private _cellId;
  78657. private _populateNinePatchSlicesFromImage;
  78658. private _sliceLeft;
  78659. private _sliceRight;
  78660. private _sliceTop;
  78661. private _sliceBottom;
  78662. private _detectPointerOnOpaqueOnly;
  78663. private _imageDataCache;
  78664. /**
  78665. * BABYLON.Observable notified when the content is loaded
  78666. */
  78667. onImageLoadedObservable: BABYLON.Observable<Image>;
  78668. /**
  78669. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78670. */
  78671. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78672. /**
  78673. * Gets a boolean indicating that the content is loaded
  78674. */
  78675. get isLoaded(): boolean;
  78676. /**
  78677. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78678. */
  78679. get populateNinePatchSlicesFromImage(): boolean;
  78680. set populateNinePatchSlicesFromImage(value: boolean);
  78681. /**
  78682. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78683. * Beware using this as this will comsume more memory as the image has to be stored twice
  78684. */
  78685. get detectPointerOnOpaqueOnly(): boolean;
  78686. set detectPointerOnOpaqueOnly(value: boolean);
  78687. /**
  78688. * Gets or sets the left value for slicing (9-patch)
  78689. */
  78690. get sliceLeft(): number;
  78691. set sliceLeft(value: number);
  78692. /**
  78693. * Gets or sets the right value for slicing (9-patch)
  78694. */
  78695. get sliceRight(): number;
  78696. set sliceRight(value: number);
  78697. /**
  78698. * Gets or sets the top value for slicing (9-patch)
  78699. */
  78700. get sliceTop(): number;
  78701. set sliceTop(value: number);
  78702. /**
  78703. * Gets or sets the bottom value for slicing (9-patch)
  78704. */
  78705. get sliceBottom(): number;
  78706. set sliceBottom(value: number);
  78707. /**
  78708. * Gets or sets the left coordinate in the source image
  78709. */
  78710. get sourceLeft(): number;
  78711. set sourceLeft(value: number);
  78712. /**
  78713. * Gets or sets the top coordinate in the source image
  78714. */
  78715. get sourceTop(): number;
  78716. set sourceTop(value: number);
  78717. /**
  78718. * Gets or sets the width to capture in the source image
  78719. */
  78720. get sourceWidth(): number;
  78721. set sourceWidth(value: number);
  78722. /**
  78723. * Gets or sets the height to capture in the source image
  78724. */
  78725. get sourceHeight(): number;
  78726. set sourceHeight(value: number);
  78727. /** Indicates if the format of the image is SVG */
  78728. get isSVG(): boolean;
  78729. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78730. get svgAttributesComputationCompleted(): boolean;
  78731. /**
  78732. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78733. * @see https://doc.babylonjs.com/how_to/gui#image
  78734. */
  78735. get autoScale(): boolean;
  78736. set autoScale(value: boolean);
  78737. /** Gets or sets the streching mode used by the image */
  78738. get stretch(): number;
  78739. set stretch(value: number);
  78740. /** @hidden */
  78741. _rotate90(n: number, preserveProperties?: boolean): Image;
  78742. private _handleRotationForSVGImage;
  78743. private _rotate90SourceProperties;
  78744. /**
  78745. * Gets or sets the internal DOM image used to render the control
  78746. */
  78747. set domImage(value: HTMLImageElement);
  78748. get domImage(): HTMLImageElement;
  78749. private _onImageLoaded;
  78750. private _extractNinePatchSliceDataFromImage;
  78751. /**
  78752. * Gets or sets image source url
  78753. */
  78754. set source(value: BABYLON.Nullable<string>);
  78755. /**
  78756. * Checks for svg document with icon id present
  78757. */
  78758. private _svgCheck;
  78759. /**
  78760. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78761. * given external svg file and icon id
  78762. */
  78763. private _getSVGAttribs;
  78764. /**
  78765. * Gets or sets the cell width to use when animation sheet is enabled
  78766. * @see https://doc.babylonjs.com/how_to/gui#image
  78767. */
  78768. get cellWidth(): number;
  78769. set cellWidth(value: number);
  78770. /**
  78771. * Gets or sets the cell height to use when animation sheet is enabled
  78772. * @see https://doc.babylonjs.com/how_to/gui#image
  78773. */
  78774. get cellHeight(): number;
  78775. set cellHeight(value: number);
  78776. /**
  78777. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78778. * @see https://doc.babylonjs.com/how_to/gui#image
  78779. */
  78780. get cellId(): number;
  78781. set cellId(value: number);
  78782. /**
  78783. * Creates a new Image
  78784. * @param name defines the control name
  78785. * @param url defines the image url
  78786. */
  78787. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78788. /**
  78789. * Tests if a given coordinates belong to the current control
  78790. * @param x defines x coordinate to test
  78791. * @param y defines y coordinate to test
  78792. * @returns true if the coordinates are inside the control
  78793. */
  78794. contains(x: number, y: number): boolean;
  78795. protected _getTypeName(): string;
  78796. /** Force the control to synchronize with its content */
  78797. synchronizeSizeWithContent(): void;
  78798. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78799. private _prepareWorkingCanvasForOpaqueDetection;
  78800. private _drawImage;
  78801. _draw(context: CanvasRenderingContext2D): void;
  78802. private _renderCornerPatch;
  78803. private _renderNinePatch;
  78804. dispose(): void;
  78805. /** STRETCH_NONE */
  78806. static readonly STRETCH_NONE: number;
  78807. /** STRETCH_FILL */
  78808. static readonly STRETCH_FILL: number;
  78809. /** STRETCH_UNIFORM */
  78810. static readonly STRETCH_UNIFORM: number;
  78811. /** STRETCH_EXTEND */
  78812. static readonly STRETCH_EXTEND: number;
  78813. /** NINE_PATCH */
  78814. static readonly STRETCH_NINE_PATCH: number;
  78815. }
  78816. }
  78817. declare module BABYLON.GUI {
  78818. /**
  78819. * Class used to create 2D buttons
  78820. */
  78821. export class Button extends Rectangle {
  78822. name?: string | undefined;
  78823. /**
  78824. * Function called to generate a pointer enter animation
  78825. */
  78826. pointerEnterAnimation: () => void;
  78827. /**
  78828. * Function called to generate a pointer out animation
  78829. */
  78830. pointerOutAnimation: () => void;
  78831. /**
  78832. * Function called to generate a pointer down animation
  78833. */
  78834. pointerDownAnimation: () => void;
  78835. /**
  78836. * Function called to generate a pointer up animation
  78837. */
  78838. pointerUpAnimation: () => void;
  78839. /**
  78840. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78841. */
  78842. delegatePickingToChildren: boolean;
  78843. private _image;
  78844. /**
  78845. * Returns the image part of the button (if any)
  78846. */
  78847. get image(): BABYLON.Nullable<Image>;
  78848. private _textBlock;
  78849. /**
  78850. * Returns the image part of the button (if any)
  78851. */
  78852. get textBlock(): BABYLON.Nullable<TextBlock>;
  78853. /**
  78854. * Creates a new Button
  78855. * @param name defines the name of the button
  78856. */
  78857. constructor(name?: string | undefined);
  78858. protected _getTypeName(): string;
  78859. /** @hidden */
  78860. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78861. /** @hidden */
  78862. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78863. /** @hidden */
  78864. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78865. /** @hidden */
  78866. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78867. /** @hidden */
  78868. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78869. /**
  78870. * Creates a new button made with an image and a text
  78871. * @param name defines the name of the button
  78872. * @param text defines the text of the button
  78873. * @param imageUrl defines the url of the image
  78874. * @returns a new Button
  78875. */
  78876. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78877. /**
  78878. * Creates a new button made with an image
  78879. * @param name defines the name of the button
  78880. * @param imageUrl defines the url of the image
  78881. * @returns a new Button
  78882. */
  78883. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78884. /**
  78885. * Creates a new button made with a text
  78886. * @param name defines the name of the button
  78887. * @param text defines the text of the button
  78888. * @returns a new Button
  78889. */
  78890. static CreateSimpleButton(name: string, text: string): Button;
  78891. /**
  78892. * Creates a new button made with an image and a centered text
  78893. * @param name defines the name of the button
  78894. * @param text defines the text of the button
  78895. * @param imageUrl defines the url of the image
  78896. * @returns a new Button
  78897. */
  78898. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78899. }
  78900. }
  78901. declare module BABYLON.GUI {
  78902. /**
  78903. * Class used to create a 2D stack panel container
  78904. */
  78905. export class StackPanel extends Container {
  78906. name?: string | undefined;
  78907. private _isVertical;
  78908. private _manualWidth;
  78909. private _manualHeight;
  78910. private _doNotTrackManualChanges;
  78911. /**
  78912. * Gets or sets a boolean indicating that layou warnings should be ignored
  78913. */
  78914. ignoreLayoutWarnings: boolean;
  78915. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78916. get isVertical(): boolean;
  78917. set isVertical(value: boolean);
  78918. /**
  78919. * Gets or sets panel width.
  78920. * This value should not be set when in horizontal mode as it will be computed automatically
  78921. */
  78922. set width(value: string | number);
  78923. get width(): string | number;
  78924. /**
  78925. * Gets or sets panel height.
  78926. * This value should not be set when in vertical mode as it will be computed automatically
  78927. */
  78928. set height(value: string | number);
  78929. get height(): string | number;
  78930. /**
  78931. * Creates a new StackPanel
  78932. * @param name defines control name
  78933. */
  78934. constructor(name?: string | undefined);
  78935. protected _getTypeName(): string;
  78936. /** @hidden */
  78937. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78938. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78939. protected _postMeasure(): void;
  78940. }
  78941. }
  78942. declare module BABYLON.GUI {
  78943. /**
  78944. * Class used to represent a 2D checkbox
  78945. */
  78946. export class Checkbox extends Control {
  78947. name?: string | undefined;
  78948. private _isChecked;
  78949. private _background;
  78950. private _checkSizeRatio;
  78951. private _thickness;
  78952. /** Gets or sets border thickness */
  78953. get thickness(): number;
  78954. set thickness(value: number);
  78955. /**
  78956. * BABYLON.Observable raised when isChecked property changes
  78957. */
  78958. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78959. /** Gets or sets a value indicating the ratio between overall size and check size */
  78960. get checkSizeRatio(): number;
  78961. set checkSizeRatio(value: number);
  78962. /** Gets or sets background color */
  78963. get background(): string;
  78964. set background(value: string);
  78965. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78966. get isChecked(): boolean;
  78967. set isChecked(value: boolean);
  78968. /**
  78969. * Creates a new CheckBox
  78970. * @param name defines the control name
  78971. */
  78972. constructor(name?: string | undefined);
  78973. protected _getTypeName(): string;
  78974. /** @hidden */
  78975. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78976. /** @hidden */
  78977. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78978. /**
  78979. * Utility function to easily create a checkbox with a header
  78980. * @param title defines the label to use for the header
  78981. * @param onValueChanged defines the callback to call when value changes
  78982. * @returns a StackPanel containing the checkbox and a textBlock
  78983. */
  78984. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78985. }
  78986. }
  78987. declare module BABYLON.GUI {
  78988. /**
  78989. * Class used to store key control properties
  78990. */
  78991. export class KeyPropertySet {
  78992. /** Width */
  78993. width?: string;
  78994. /** Height */
  78995. height?: string;
  78996. /** Left padding */
  78997. paddingLeft?: string;
  78998. /** Right padding */
  78999. paddingRight?: string;
  79000. /** Top padding */
  79001. paddingTop?: string;
  79002. /** Bottom padding */
  79003. paddingBottom?: string;
  79004. /** Foreground color */
  79005. color?: string;
  79006. /** Background color */
  79007. background?: string;
  79008. }
  79009. /**
  79010. * Class used to create virtual keyboard
  79011. */
  79012. export class VirtualKeyboard extends StackPanel {
  79013. /** BABYLON.Observable raised when a key is pressed */
  79014. onKeyPressObservable: BABYLON.Observable<string>;
  79015. /** Gets or sets default key button width */
  79016. defaultButtonWidth: string;
  79017. /** Gets or sets default key button height */
  79018. defaultButtonHeight: string;
  79019. /** Gets or sets default key button left padding */
  79020. defaultButtonPaddingLeft: string;
  79021. /** Gets or sets default key button right padding */
  79022. defaultButtonPaddingRight: string;
  79023. /** Gets or sets default key button top padding */
  79024. defaultButtonPaddingTop: string;
  79025. /** Gets or sets default key button bottom padding */
  79026. defaultButtonPaddingBottom: string;
  79027. /** Gets or sets default key button foreground color */
  79028. defaultButtonColor: string;
  79029. /** Gets or sets default key button background color */
  79030. defaultButtonBackground: string;
  79031. /** Gets or sets shift button foreground color */
  79032. shiftButtonColor: string;
  79033. /** Gets or sets shift button thickness*/
  79034. selectedShiftThickness: number;
  79035. /** Gets shift key state */
  79036. shiftState: number;
  79037. protected _getTypeName(): string;
  79038. private _createKey;
  79039. /**
  79040. * Adds a new row of keys
  79041. * @param keys defines the list of keys to add
  79042. * @param propertySets defines the associated property sets
  79043. */
  79044. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79045. /**
  79046. * Set the shift key to a specific state
  79047. * @param shiftState defines the new shift state
  79048. */
  79049. applyShiftState(shiftState: number): void;
  79050. private _currentlyConnectedInputText;
  79051. private _connectedInputTexts;
  79052. private _onKeyPressObserver;
  79053. /** Gets the input text control currently attached to the keyboard */
  79054. get connectedInputText(): BABYLON.Nullable<InputText>;
  79055. /**
  79056. * Connects the keyboard with an input text control
  79057. *
  79058. * @param input defines the target control
  79059. */
  79060. connect(input: InputText): void;
  79061. /**
  79062. * Disconnects the keyboard from connected InputText controls
  79063. *
  79064. * @param input optionally defines a target control, otherwise all are disconnected
  79065. */
  79066. disconnect(input?: InputText): void;
  79067. private _removeConnectedInputObservables;
  79068. /**
  79069. * Release all resources
  79070. */
  79071. dispose(): void;
  79072. /**
  79073. * Creates a new keyboard using a default layout
  79074. *
  79075. * @param name defines control name
  79076. * @returns a new VirtualKeyboard
  79077. */
  79078. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79079. }
  79080. }
  79081. declare module BABYLON.GUI {
  79082. /**
  79083. * Class used to create input text control
  79084. */
  79085. export class InputText extends Control implements IFocusableControl {
  79086. name?: string | undefined;
  79087. private _text;
  79088. private _placeholderText;
  79089. private _background;
  79090. private _focusedBackground;
  79091. private _focusedColor;
  79092. private _placeholderColor;
  79093. private _thickness;
  79094. private _margin;
  79095. private _autoStretchWidth;
  79096. private _maxWidth;
  79097. private _isFocused;
  79098. private _blinkTimeout;
  79099. private _blinkIsEven;
  79100. private _cursorOffset;
  79101. private _scrollLeft;
  79102. private _textWidth;
  79103. private _clickedCoordinate;
  79104. private _deadKey;
  79105. private _addKey;
  79106. private _currentKey;
  79107. private _isTextHighlightOn;
  79108. private _textHighlightColor;
  79109. private _highligherOpacity;
  79110. private _highlightedText;
  79111. private _startHighlightIndex;
  79112. private _endHighlightIndex;
  79113. private _cursorIndex;
  79114. private _onFocusSelectAll;
  79115. private _isPointerDown;
  79116. private _onClipboardObserver;
  79117. private _onPointerDblTapObserver;
  79118. /** @hidden */
  79119. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79120. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79121. promptMessage: string;
  79122. /** Force disable prompt on mobile device */
  79123. disableMobilePrompt: boolean;
  79124. /** BABYLON.Observable raised when the text changes */
  79125. onTextChangedObservable: BABYLON.Observable<InputText>;
  79126. /** BABYLON.Observable raised just before an entered character is to be added */
  79127. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79128. /** BABYLON.Observable raised when the control gets the focus */
  79129. onFocusObservable: BABYLON.Observable<InputText>;
  79130. /** BABYLON.Observable raised when the control loses the focus */
  79131. onBlurObservable: BABYLON.Observable<InputText>;
  79132. /**Observable raised when the text is highlighted */
  79133. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79134. /**Observable raised when copy event is triggered */
  79135. onTextCopyObservable: BABYLON.Observable<InputText>;
  79136. /** BABYLON.Observable raised when cut event is triggered */
  79137. onTextCutObservable: BABYLON.Observable<InputText>;
  79138. /** BABYLON.Observable raised when paste event is triggered */
  79139. onTextPasteObservable: BABYLON.Observable<InputText>;
  79140. /** BABYLON.Observable raised when a key event was processed */
  79141. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79142. /** Gets or sets the maximum width allowed by the control */
  79143. get maxWidth(): string | number;
  79144. /** Gets the maximum width allowed by the control in pixels */
  79145. get maxWidthInPixels(): number;
  79146. set maxWidth(value: string | number);
  79147. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79148. get highligherOpacity(): number;
  79149. set highligherOpacity(value: number);
  79150. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79151. get onFocusSelectAll(): boolean;
  79152. set onFocusSelectAll(value: boolean);
  79153. /** Gets or sets the text hightlight color */
  79154. get textHighlightColor(): string;
  79155. set textHighlightColor(value: string);
  79156. /** Gets or sets control margin */
  79157. get margin(): string;
  79158. /** Gets control margin in pixels */
  79159. get marginInPixels(): number;
  79160. set margin(value: string);
  79161. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79162. get autoStretchWidth(): boolean;
  79163. set autoStretchWidth(value: boolean);
  79164. /** Gets or sets border thickness */
  79165. get thickness(): number;
  79166. set thickness(value: number);
  79167. /** Gets or sets the background color when focused */
  79168. get focusedBackground(): string;
  79169. set focusedBackground(value: string);
  79170. /** Gets or sets the background color when focused */
  79171. get focusedColor(): string;
  79172. set focusedColor(value: string);
  79173. /** Gets or sets the background color */
  79174. get background(): string;
  79175. set background(value: string);
  79176. /** Gets or sets the placeholder color */
  79177. get placeholderColor(): string;
  79178. set placeholderColor(value: string);
  79179. /** Gets or sets the text displayed when the control is empty */
  79180. get placeholderText(): string;
  79181. set placeholderText(value: string);
  79182. /** Gets or sets the dead key flag */
  79183. get deadKey(): boolean;
  79184. set deadKey(flag: boolean);
  79185. /** Gets or sets the highlight text */
  79186. get highlightedText(): string;
  79187. set highlightedText(text: string);
  79188. /** Gets or sets if the current key should be added */
  79189. get addKey(): boolean;
  79190. set addKey(flag: boolean);
  79191. /** Gets or sets the value of the current key being entered */
  79192. get currentKey(): string;
  79193. set currentKey(key: string);
  79194. /** Gets or sets the text displayed in the control */
  79195. get text(): string;
  79196. set text(value: string);
  79197. /** Gets or sets control width */
  79198. get width(): string | number;
  79199. set width(value: string | number);
  79200. /**
  79201. * Creates a new InputText
  79202. * @param name defines the control name
  79203. * @param text defines the text of the control
  79204. */
  79205. constructor(name?: string | undefined, text?: string);
  79206. /** @hidden */
  79207. onBlur(): void;
  79208. /** @hidden */
  79209. onFocus(): void;
  79210. protected _getTypeName(): string;
  79211. /**
  79212. * Function called to get the list of controls that should not steal the focus from this control
  79213. * @returns an array of controls
  79214. */
  79215. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79216. /** @hidden */
  79217. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79218. /** @hidden */
  79219. private _updateValueFromCursorIndex;
  79220. /** @hidden */
  79221. private _processDblClick;
  79222. /** @hidden */
  79223. private _selectAllText;
  79224. /**
  79225. * Handles the keyboard event
  79226. * @param evt Defines the KeyboardEvent
  79227. */
  79228. processKeyboard(evt: KeyboardEvent): void;
  79229. /** @hidden */
  79230. private _onCopyText;
  79231. /** @hidden */
  79232. private _onCutText;
  79233. /** @hidden */
  79234. private _onPasteText;
  79235. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79236. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79237. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79238. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79239. protected _beforeRenderText(text: string): string;
  79240. dispose(): void;
  79241. }
  79242. }
  79243. declare module BABYLON.GUI {
  79244. /**
  79245. * Class used to create a 2D grid container
  79246. */
  79247. export class Grid extends Container {
  79248. name?: string | undefined;
  79249. private _rowDefinitions;
  79250. private _columnDefinitions;
  79251. private _cells;
  79252. private _childControls;
  79253. /**
  79254. * Gets the number of columns
  79255. */
  79256. get columnCount(): number;
  79257. /**
  79258. * Gets the number of rows
  79259. */
  79260. get rowCount(): number;
  79261. /** Gets the list of children */
  79262. get children(): Control[];
  79263. /** Gets the list of cells (e.g. the containers) */
  79264. get cells(): {
  79265. [key: string]: Container;
  79266. };
  79267. /**
  79268. * Gets the definition of a specific row
  79269. * @param index defines the index of the row
  79270. * @returns the row definition
  79271. */
  79272. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79273. /**
  79274. * Gets the definition of a specific column
  79275. * @param index defines the index of the column
  79276. * @returns the column definition
  79277. */
  79278. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79279. /**
  79280. * Adds a new row to the grid
  79281. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79282. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79283. * @returns the current grid
  79284. */
  79285. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79286. /**
  79287. * Adds a new column to the grid
  79288. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79289. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79290. * @returns the current grid
  79291. */
  79292. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79293. /**
  79294. * Update a row definition
  79295. * @param index defines the index of the row to update
  79296. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79297. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79298. * @returns the current grid
  79299. */
  79300. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79301. /**
  79302. * Update a column definition
  79303. * @param index defines the index of the column to update
  79304. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79305. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79306. * @returns the current grid
  79307. */
  79308. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79309. /**
  79310. * Gets the list of children stored in a specific cell
  79311. * @param row defines the row to check
  79312. * @param column defines the column to check
  79313. * @returns the list of controls
  79314. */
  79315. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79316. /**
  79317. * Gets a string representing the child cell info (row x column)
  79318. * @param child defines the control to get info from
  79319. * @returns a string containing the child cell info (row x column)
  79320. */
  79321. getChildCellInfo(child: Control): string;
  79322. private _removeCell;
  79323. private _offsetCell;
  79324. /**
  79325. * Remove a column definition at specified index
  79326. * @param index defines the index of the column to remove
  79327. * @returns the current grid
  79328. */
  79329. removeColumnDefinition(index: number): Grid;
  79330. /**
  79331. * Remove a row definition at specified index
  79332. * @param index defines the index of the row to remove
  79333. * @returns the current grid
  79334. */
  79335. removeRowDefinition(index: number): Grid;
  79336. /**
  79337. * Adds a new control to the current grid
  79338. * @param control defines the control to add
  79339. * @param row defines the row where to add the control (0 by default)
  79340. * @param column defines the column where to add the control (0 by default)
  79341. * @returns the current grid
  79342. */
  79343. addControl(control: Control, row?: number, column?: number): Grid;
  79344. /**
  79345. * Removes a control from the current container
  79346. * @param control defines the control to remove
  79347. * @returns the current container
  79348. */
  79349. removeControl(control: Control): Container;
  79350. /**
  79351. * Creates a new Grid
  79352. * @param name defines control name
  79353. */
  79354. constructor(name?: string | undefined);
  79355. protected _getTypeName(): string;
  79356. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79357. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79358. _flagDescendantsAsMatrixDirty(): void;
  79359. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79360. /** Releases associated resources */
  79361. dispose(): void;
  79362. }
  79363. }
  79364. declare module BABYLON.GUI {
  79365. /** Class used to create color pickers */
  79366. export class ColorPicker extends Control {
  79367. name?: string | undefined;
  79368. private static _Epsilon;
  79369. private _colorWheelCanvas;
  79370. private _value;
  79371. private _tmpColor;
  79372. private _pointerStartedOnSquare;
  79373. private _pointerStartedOnWheel;
  79374. private _squareLeft;
  79375. private _squareTop;
  79376. private _squareSize;
  79377. private _h;
  79378. private _s;
  79379. private _v;
  79380. private _lastPointerDownID;
  79381. /**
  79382. * BABYLON.Observable raised when the value changes
  79383. */
  79384. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79385. /** Gets or sets the color of the color picker */
  79386. get value(): BABYLON.Color3;
  79387. set value(value: BABYLON.Color3);
  79388. /**
  79389. * Gets or sets control width
  79390. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79391. */
  79392. get width(): string | number;
  79393. set width(value: string | number);
  79394. /**
  79395. * Gets or sets control height
  79396. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79397. */
  79398. get height(): string | number;
  79399. /** Gets or sets control height */
  79400. set height(value: string | number);
  79401. /** Gets or sets control size */
  79402. get size(): string | number;
  79403. set size(value: string | number);
  79404. /**
  79405. * Creates a new ColorPicker
  79406. * @param name defines the control name
  79407. */
  79408. constructor(name?: string | undefined);
  79409. protected _getTypeName(): string;
  79410. /** @hidden */
  79411. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79412. private _updateSquareProps;
  79413. private _drawGradientSquare;
  79414. private _drawCircle;
  79415. private _createColorWheelCanvas;
  79416. /** @hidden */
  79417. _draw(context: CanvasRenderingContext2D): void;
  79418. private _pointerIsDown;
  79419. private _updateValueFromPointer;
  79420. private _isPointOnSquare;
  79421. private _isPointOnWheel;
  79422. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79423. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79424. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79425. _onCanvasBlur(): void;
  79426. /**
  79427. * This function expands the color picker by creating a color picker dialog with manual
  79428. * color value input and the ability to save colors into an array to be used later in
  79429. * subsequent launches of the dialogue.
  79430. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79431. * @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.
  79432. * @returns picked color as a hex string and the saved colors array as hex strings.
  79433. */
  79434. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79435. pickerWidth?: string;
  79436. pickerHeight?: string;
  79437. headerHeight?: string;
  79438. lastColor?: string;
  79439. swatchLimit?: number;
  79440. numSwatchesPerLine?: number;
  79441. savedColors?: Array<string>;
  79442. }): Promise<{
  79443. savedColors?: string[];
  79444. pickedColor: string;
  79445. }>;
  79446. }
  79447. }
  79448. declare module BABYLON.GUI {
  79449. /** Class used to create 2D ellipse containers */
  79450. export class Ellipse extends Container {
  79451. name?: string | undefined;
  79452. private _thickness;
  79453. /** Gets or sets border thickness */
  79454. get thickness(): number;
  79455. set thickness(value: number);
  79456. /**
  79457. * Creates a new Ellipse
  79458. * @param name defines the control name
  79459. */
  79460. constructor(name?: string | undefined);
  79461. protected _getTypeName(): string;
  79462. protected _localDraw(context: CanvasRenderingContext2D): void;
  79463. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79464. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79465. }
  79466. }
  79467. declare module BABYLON.GUI {
  79468. /**
  79469. * Class used to create a password control
  79470. */
  79471. export class InputPassword extends InputText {
  79472. protected _beforeRenderText(text: string): string;
  79473. }
  79474. }
  79475. declare module BABYLON.GUI {
  79476. /** Class used to render 2D lines */
  79477. export class Line extends Control {
  79478. name?: string | undefined;
  79479. private _lineWidth;
  79480. private _x1;
  79481. private _y1;
  79482. private _x2;
  79483. private _y2;
  79484. private _dash;
  79485. private _connectedControl;
  79486. private _connectedControlDirtyObserver;
  79487. /** Gets or sets the dash pattern */
  79488. get dash(): Array<number>;
  79489. set dash(value: Array<number>);
  79490. /** Gets or sets the control connected with the line end */
  79491. get connectedControl(): Control;
  79492. set connectedControl(value: Control);
  79493. /** Gets or sets start coordinates on X axis */
  79494. get x1(): string | number;
  79495. set x1(value: string | number);
  79496. /** Gets or sets start coordinates on Y axis */
  79497. get y1(): string | number;
  79498. set y1(value: string | number);
  79499. /** Gets or sets end coordinates on X axis */
  79500. get x2(): string | number;
  79501. set x2(value: string | number);
  79502. /** Gets or sets end coordinates on Y axis */
  79503. get y2(): string | number;
  79504. set y2(value: string | number);
  79505. /** Gets or sets line width */
  79506. get lineWidth(): number;
  79507. set lineWidth(value: number);
  79508. /** Gets or sets horizontal alignment */
  79509. set horizontalAlignment(value: number);
  79510. /** Gets or sets vertical alignment */
  79511. set verticalAlignment(value: number);
  79512. private get _effectiveX2();
  79513. private get _effectiveY2();
  79514. /**
  79515. * Creates a new Line
  79516. * @param name defines the control name
  79517. */
  79518. constructor(name?: string | undefined);
  79519. protected _getTypeName(): string;
  79520. _draw(context: CanvasRenderingContext2D): void;
  79521. _measure(): void;
  79522. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79523. /**
  79524. * Move one end of the line given 3D cartesian coordinates.
  79525. * @param position Targeted world position
  79526. * @param scene BABYLON.Scene
  79527. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79528. */
  79529. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79530. /**
  79531. * Move one end of the line to a position in screen absolute space.
  79532. * @param projectedPosition Position in screen absolute space (X, Y)
  79533. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79534. */
  79535. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79536. }
  79537. }
  79538. declare module BABYLON.GUI {
  79539. /**
  79540. * Class used to store a point for a MultiLine object.
  79541. * The point can be pure 2D coordinates, a mesh or a control
  79542. */
  79543. export class MultiLinePoint {
  79544. private _multiLine;
  79545. private _x;
  79546. private _y;
  79547. private _control;
  79548. private _mesh;
  79549. private _controlObserver;
  79550. private _meshObserver;
  79551. /** @hidden */
  79552. _point: BABYLON.Vector2;
  79553. /**
  79554. * Creates a new MultiLinePoint
  79555. * @param multiLine defines the source MultiLine object
  79556. */
  79557. constructor(multiLine: MultiLine);
  79558. /** Gets or sets x coordinate */
  79559. get x(): string | number;
  79560. set x(value: string | number);
  79561. /** Gets or sets y coordinate */
  79562. get y(): string | number;
  79563. set y(value: string | number);
  79564. /** Gets or sets the control associated with this point */
  79565. get control(): BABYLON.Nullable<Control>;
  79566. set control(value: BABYLON.Nullable<Control>);
  79567. /** Gets or sets the mesh associated with this point */
  79568. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79569. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79570. /** Resets links */
  79571. resetLinks(): void;
  79572. /**
  79573. * Gets a translation vector
  79574. * @returns the translation vector
  79575. */
  79576. translate(): BABYLON.Vector2;
  79577. private _translatePoint;
  79578. /** Release associated resources */
  79579. dispose(): void;
  79580. }
  79581. }
  79582. declare module BABYLON.GUI {
  79583. /**
  79584. * Class used to create multi line control
  79585. */
  79586. export class MultiLine extends Control {
  79587. name?: string | undefined;
  79588. private _lineWidth;
  79589. private _dash;
  79590. private _points;
  79591. private _minX;
  79592. private _minY;
  79593. private _maxX;
  79594. private _maxY;
  79595. /**
  79596. * Creates a new MultiLine
  79597. * @param name defines the control name
  79598. */
  79599. constructor(name?: string | undefined);
  79600. /** Gets or sets dash pattern */
  79601. get dash(): Array<number>;
  79602. set dash(value: Array<number>);
  79603. /**
  79604. * Gets point stored at specified index
  79605. * @param index defines the index to look for
  79606. * @returns the requested point if found
  79607. */
  79608. getAt(index: number): MultiLinePoint;
  79609. /** Function called when a point is updated */
  79610. onPointUpdate: () => void;
  79611. /**
  79612. * Adds new points to the point collection
  79613. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79614. * @returns the list of created MultiLinePoint
  79615. */
  79616. add(...items: (AbstractMesh | Control | {
  79617. x: string | number;
  79618. y: string | number;
  79619. })[]): MultiLinePoint[];
  79620. /**
  79621. * Adds a new point to the point collection
  79622. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79623. * @returns the created MultiLinePoint
  79624. */
  79625. push(item?: (AbstractMesh | Control | {
  79626. x: string | number;
  79627. y: string | number;
  79628. })): MultiLinePoint;
  79629. /**
  79630. * Remove a specific value or point from the active point collection
  79631. * @param value defines the value or point to remove
  79632. */
  79633. remove(value: number | MultiLinePoint): void;
  79634. /**
  79635. * Resets this object to initial state (no point)
  79636. */
  79637. reset(): void;
  79638. /**
  79639. * Resets all links
  79640. */
  79641. resetLinks(): void;
  79642. /** Gets or sets line width */
  79643. get lineWidth(): number;
  79644. set lineWidth(value: number);
  79645. set horizontalAlignment(value: number);
  79646. set verticalAlignment(value: number);
  79647. protected _getTypeName(): string;
  79648. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79649. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79650. _measure(): void;
  79651. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79652. dispose(): void;
  79653. }
  79654. }
  79655. declare module BABYLON.GUI {
  79656. /**
  79657. * Class used to create radio button controls
  79658. */
  79659. export class RadioButton extends Control {
  79660. name?: string | undefined;
  79661. private _isChecked;
  79662. private _background;
  79663. private _checkSizeRatio;
  79664. private _thickness;
  79665. /** Gets or sets border thickness */
  79666. get thickness(): number;
  79667. set thickness(value: number);
  79668. /** Gets or sets group name */
  79669. group: string;
  79670. /** BABYLON.Observable raised when isChecked is changed */
  79671. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79672. /** Gets or sets a value indicating the ratio between overall size and check size */
  79673. get checkSizeRatio(): number;
  79674. set checkSizeRatio(value: number);
  79675. /** Gets or sets background color */
  79676. get background(): string;
  79677. set background(value: string);
  79678. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79679. get isChecked(): boolean;
  79680. set isChecked(value: boolean);
  79681. /**
  79682. * Creates a new RadioButton
  79683. * @param name defines the control name
  79684. */
  79685. constructor(name?: string | undefined);
  79686. protected _getTypeName(): string;
  79687. _draw(context: CanvasRenderingContext2D): void;
  79688. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79689. /**
  79690. * Utility function to easily create a radio button with a header
  79691. * @param title defines the label to use for the header
  79692. * @param group defines the group to use for the radio button
  79693. * @param isChecked defines the initial state of the radio button
  79694. * @param onValueChanged defines the callback to call when value changes
  79695. * @returns a StackPanel containing the radio button and a textBlock
  79696. */
  79697. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79698. }
  79699. }
  79700. declare module BABYLON.GUI {
  79701. /**
  79702. * Class used to create slider controls
  79703. */
  79704. export class BaseSlider extends Control {
  79705. name?: string | undefined;
  79706. protected _thumbWidth: ValueAndUnit;
  79707. private _minimum;
  79708. private _maximum;
  79709. private _value;
  79710. private _isVertical;
  79711. protected _barOffset: ValueAndUnit;
  79712. private _isThumbClamped;
  79713. protected _displayThumb: boolean;
  79714. private _step;
  79715. private _lastPointerDownID;
  79716. protected _effectiveBarOffset: number;
  79717. protected _renderLeft: number;
  79718. protected _renderTop: number;
  79719. protected _renderWidth: number;
  79720. protected _renderHeight: number;
  79721. protected _backgroundBoxLength: number;
  79722. protected _backgroundBoxThickness: number;
  79723. protected _effectiveThumbThickness: number;
  79724. /** BABYLON.Observable raised when the sldier value changes */
  79725. onValueChangedObservable: BABYLON.Observable<number>;
  79726. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79727. get displayThumb(): boolean;
  79728. set displayThumb(value: boolean);
  79729. /** Gets or sets a step to apply to values (0 by default) */
  79730. get step(): number;
  79731. set step(value: number);
  79732. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79733. get barOffset(): string | number;
  79734. /** Gets main bar offset in pixels*/
  79735. get barOffsetInPixels(): number;
  79736. set barOffset(value: string | number);
  79737. /** Gets or sets thumb width */
  79738. get thumbWidth(): string | number;
  79739. /** Gets thumb width in pixels */
  79740. get thumbWidthInPixels(): number;
  79741. set thumbWidth(value: string | number);
  79742. /** Gets or sets minimum value */
  79743. get minimum(): number;
  79744. set minimum(value: number);
  79745. /** Gets or sets maximum value */
  79746. get maximum(): number;
  79747. set maximum(value: number);
  79748. /** Gets or sets current value */
  79749. get value(): number;
  79750. set value(value: number);
  79751. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79752. get isVertical(): boolean;
  79753. set isVertical(value: boolean);
  79754. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79755. get isThumbClamped(): boolean;
  79756. set isThumbClamped(value: boolean);
  79757. /**
  79758. * Creates a new BaseSlider
  79759. * @param name defines the control name
  79760. */
  79761. constructor(name?: string | undefined);
  79762. protected _getTypeName(): string;
  79763. protected _getThumbPosition(): number;
  79764. protected _getThumbThickness(type: string): number;
  79765. protected _prepareRenderingData(type: string): void;
  79766. private _pointerIsDown;
  79767. /** @hidden */
  79768. protected _updateValueFromPointer(x: number, y: number): void;
  79769. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79770. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79771. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79772. _onCanvasBlur(): void;
  79773. }
  79774. }
  79775. declare module BABYLON.GUI {
  79776. /**
  79777. * Class used to create slider controls
  79778. */
  79779. export class Slider extends BaseSlider {
  79780. name?: string | undefined;
  79781. private _background;
  79782. private _borderColor;
  79783. private _thumbColor;
  79784. private _isThumbCircle;
  79785. protected _displayValueBar: boolean;
  79786. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79787. get displayValueBar(): boolean;
  79788. set displayValueBar(value: boolean);
  79789. /** Gets or sets border color */
  79790. get borderColor(): string;
  79791. set borderColor(value: string);
  79792. /** Gets or sets background color */
  79793. get background(): string;
  79794. set background(value: string);
  79795. /** Gets or sets thumb's color */
  79796. get thumbColor(): string;
  79797. set thumbColor(value: string);
  79798. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79799. get isThumbCircle(): boolean;
  79800. set isThumbCircle(value: boolean);
  79801. /**
  79802. * Creates a new Slider
  79803. * @param name defines the control name
  79804. */
  79805. constructor(name?: string | undefined);
  79806. protected _getTypeName(): string;
  79807. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79808. }
  79809. }
  79810. declare module BABYLON.GUI {
  79811. /** Class used to create a RadioGroup
  79812. * which contains groups of radio buttons
  79813. */
  79814. export class SelectorGroup {
  79815. /** name of SelectorGroup */
  79816. name: string;
  79817. private _groupPanel;
  79818. private _selectors;
  79819. private _groupHeader;
  79820. /**
  79821. * Creates a new SelectorGroup
  79822. * @param name of group, used as a group heading
  79823. */
  79824. constructor(
  79825. /** name of SelectorGroup */
  79826. name: string);
  79827. /** Gets the groupPanel of the SelectorGroup */
  79828. get groupPanel(): StackPanel;
  79829. /** Gets the selectors array */
  79830. get selectors(): StackPanel[];
  79831. /** Gets and sets the group header */
  79832. get header(): string;
  79833. set header(label: string);
  79834. /** @hidden */
  79835. private _addGroupHeader;
  79836. /** @hidden*/
  79837. _getSelector(selectorNb: number): StackPanel | undefined;
  79838. /** Removes the selector at the given position
  79839. * @param selectorNb the position of the selector within the group
  79840. */
  79841. removeSelector(selectorNb: number): void;
  79842. }
  79843. /** Class used to create a CheckboxGroup
  79844. * which contains groups of checkbox buttons
  79845. */
  79846. export class CheckboxGroup extends SelectorGroup {
  79847. /** Adds a checkbox as a control
  79848. * @param text is the label for the selector
  79849. * @param func is the function called when the Selector is checked
  79850. * @param checked is true when Selector is checked
  79851. */
  79852. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79853. /** @hidden */
  79854. _setSelectorLabel(selectorNb: number, label: string): void;
  79855. /** @hidden */
  79856. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79857. /** @hidden */
  79858. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79859. /** @hidden */
  79860. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79861. }
  79862. /** Class used to create a RadioGroup
  79863. * which contains groups of radio buttons
  79864. */
  79865. export class RadioGroup extends SelectorGroup {
  79866. private _selectNb;
  79867. /** Adds a radio button as a control
  79868. * @param label is the label for the selector
  79869. * @param func is the function called when the Selector is checked
  79870. * @param checked is true when Selector is checked
  79871. */
  79872. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79873. /** @hidden */
  79874. _setSelectorLabel(selectorNb: number, label: string): void;
  79875. /** @hidden */
  79876. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79877. /** @hidden */
  79878. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79879. /** @hidden */
  79880. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79881. }
  79882. /** Class used to create a SliderGroup
  79883. * which contains groups of slider buttons
  79884. */
  79885. export class SliderGroup extends SelectorGroup {
  79886. /**
  79887. * Adds a slider to the SelectorGroup
  79888. * @param label is the label for the SliderBar
  79889. * @param func is the function called when the Slider moves
  79890. * @param unit is a string describing the units used, eg degrees or metres
  79891. * @param min is the minimum value for the Slider
  79892. * @param max is the maximum value for the Slider
  79893. * @param value is the start value for the Slider between min and max
  79894. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79895. */
  79896. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79897. /** @hidden */
  79898. _setSelectorLabel(selectorNb: number, label: string): void;
  79899. /** @hidden */
  79900. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79901. /** @hidden */
  79902. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79903. /** @hidden */
  79904. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79905. }
  79906. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79907. * @see https://doc.babylonjs.com/how_to/selector
  79908. */
  79909. export class SelectionPanel extends Rectangle {
  79910. /** name of SelectionPanel */
  79911. name: string;
  79912. /** an array of SelectionGroups */
  79913. groups: SelectorGroup[];
  79914. private _panel;
  79915. private _buttonColor;
  79916. private _buttonBackground;
  79917. private _headerColor;
  79918. private _barColor;
  79919. private _barHeight;
  79920. private _spacerHeight;
  79921. private _labelColor;
  79922. private _groups;
  79923. private _bars;
  79924. /**
  79925. * Creates a new SelectionPanel
  79926. * @param name of SelectionPanel
  79927. * @param groups is an array of SelectionGroups
  79928. */
  79929. constructor(
  79930. /** name of SelectionPanel */
  79931. name: string,
  79932. /** an array of SelectionGroups */
  79933. groups?: SelectorGroup[]);
  79934. protected _getTypeName(): string;
  79935. /** Gets the (stack) panel of the SelectionPanel */
  79936. get panel(): StackPanel;
  79937. /** Gets or sets the headerColor */
  79938. get headerColor(): string;
  79939. set headerColor(color: string);
  79940. private _setHeaderColor;
  79941. /** Gets or sets the button color */
  79942. get buttonColor(): string;
  79943. set buttonColor(color: string);
  79944. private _setbuttonColor;
  79945. /** Gets or sets the label color */
  79946. get labelColor(): string;
  79947. set labelColor(color: string);
  79948. private _setLabelColor;
  79949. /** Gets or sets the button background */
  79950. get buttonBackground(): string;
  79951. set buttonBackground(color: string);
  79952. private _setButtonBackground;
  79953. /** Gets or sets the color of separator bar */
  79954. get barColor(): string;
  79955. set barColor(color: string);
  79956. private _setBarColor;
  79957. /** Gets or sets the height of separator bar */
  79958. get barHeight(): string;
  79959. set barHeight(value: string);
  79960. private _setBarHeight;
  79961. /** Gets or sets the height of spacers*/
  79962. get spacerHeight(): string;
  79963. set spacerHeight(value: string);
  79964. private _setSpacerHeight;
  79965. /** Adds a bar between groups */
  79966. private _addSpacer;
  79967. /** Add a group to the selection panel
  79968. * @param group is the selector group to add
  79969. */
  79970. addGroup(group: SelectorGroup): void;
  79971. /** Remove the group from the given position
  79972. * @param groupNb is the position of the group in the list
  79973. */
  79974. removeGroup(groupNb: number): void;
  79975. /** Change a group header label
  79976. * @param label is the new group header label
  79977. * @param groupNb is the number of the group to relabel
  79978. * */
  79979. setHeaderName(label: string, groupNb: number): void;
  79980. /** Change selector label to the one given
  79981. * @param label is the new selector label
  79982. * @param groupNb is the number of the groupcontaining the selector
  79983. * @param selectorNb is the number of the selector within a group to relabel
  79984. * */
  79985. relabel(label: string, groupNb: number, selectorNb: number): void;
  79986. /** For a given group position remove the selector at the given position
  79987. * @param groupNb is the number of the group to remove the selector from
  79988. * @param selectorNb is the number of the selector within the group
  79989. */
  79990. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79991. /** For a given group position of correct type add a checkbox button
  79992. * @param groupNb is the number of the group to remove the selector from
  79993. * @param label is the label for the selector
  79994. * @param func is the function called when the Selector is checked
  79995. * @param checked is true when Selector is checked
  79996. */
  79997. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79998. /** For a given group position of correct type add a radio button
  79999. * @param groupNb is the number of the group to remove the selector from
  80000. * @param label is the label for the selector
  80001. * @param func is the function called when the Selector is checked
  80002. * @param checked is true when Selector is checked
  80003. */
  80004. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80005. /**
  80006. * For a given slider group add a slider
  80007. * @param groupNb is the number of the group to add the slider to
  80008. * @param label is the label for the Slider
  80009. * @param func is the function called when the Slider moves
  80010. * @param unit is a string describing the units used, eg degrees or metres
  80011. * @param min is the minimum value for the Slider
  80012. * @param max is the maximum value for the Slider
  80013. * @param value is the start value for the Slider between min and max
  80014. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80015. */
  80016. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80017. }
  80018. }
  80019. declare module BABYLON.GUI {
  80020. /**
  80021. * Class used to hold a the container for ScrollViewer
  80022. * @hidden
  80023. */
  80024. export class _ScrollViewerWindow extends Container {
  80025. parentClientWidth: number;
  80026. parentClientHeight: number;
  80027. private _freezeControls;
  80028. private _parentMeasure;
  80029. private _oldLeft;
  80030. private _oldTop;
  80031. get freezeControls(): boolean;
  80032. set freezeControls(value: boolean);
  80033. private _bucketWidth;
  80034. private _bucketHeight;
  80035. private _buckets;
  80036. private _bucketLen;
  80037. get bucketWidth(): number;
  80038. get bucketHeight(): number;
  80039. setBucketSizes(width: number, height: number): void;
  80040. private _useBuckets;
  80041. private _makeBuckets;
  80042. private _dispatchInBuckets;
  80043. private _updateMeasures;
  80044. private _updateChildrenMeasures;
  80045. private _restoreMeasures;
  80046. /**
  80047. * Creates a new ScrollViewerWindow
  80048. * @param name of ScrollViewerWindow
  80049. */
  80050. constructor(name?: string);
  80051. protected _getTypeName(): string;
  80052. /** @hidden */
  80053. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80054. /** @hidden */
  80055. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80056. private _scrollChildren;
  80057. private _scrollChildrenWithBuckets;
  80058. /** @hidden */
  80059. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80060. protected _postMeasure(): void;
  80061. }
  80062. }
  80063. declare module BABYLON.GUI {
  80064. /**
  80065. * Class used to create slider controls
  80066. */
  80067. export class ScrollBar extends BaseSlider {
  80068. name?: string | undefined;
  80069. private _background;
  80070. private _borderColor;
  80071. private _tempMeasure;
  80072. /** Gets or sets border color */
  80073. get borderColor(): string;
  80074. set borderColor(value: string);
  80075. /** Gets or sets background color */
  80076. get background(): string;
  80077. set background(value: string);
  80078. /**
  80079. * Creates a new Slider
  80080. * @param name defines the control name
  80081. */
  80082. constructor(name?: string | undefined);
  80083. protected _getTypeName(): string;
  80084. protected _getThumbThickness(): number;
  80085. _draw(context: CanvasRenderingContext2D): void;
  80086. private _first;
  80087. private _originX;
  80088. private _originY;
  80089. /** @hidden */
  80090. protected _updateValueFromPointer(x: number, y: number): void;
  80091. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80092. }
  80093. }
  80094. declare module BABYLON.GUI {
  80095. /**
  80096. * Class used to create slider controls
  80097. */
  80098. export class ImageScrollBar extends BaseSlider {
  80099. name?: string | undefined;
  80100. private _backgroundBaseImage;
  80101. private _backgroundImage;
  80102. private _thumbImage;
  80103. private _thumbBaseImage;
  80104. private _thumbLength;
  80105. private _thumbHeight;
  80106. private _barImageHeight;
  80107. private _tempMeasure;
  80108. /** Number of 90° rotation to apply on the images when in vertical mode */
  80109. num90RotationInVerticalMode: number;
  80110. /**
  80111. * Gets or sets the image used to render the background for horizontal bar
  80112. */
  80113. get backgroundImage(): Image;
  80114. set backgroundImage(value: Image);
  80115. /**
  80116. * Gets or sets the image used to render the thumb
  80117. */
  80118. get thumbImage(): Image;
  80119. set thumbImage(value: Image);
  80120. /**
  80121. * Gets or sets the length of the thumb
  80122. */
  80123. get thumbLength(): number;
  80124. set thumbLength(value: number);
  80125. /**
  80126. * Gets or sets the height of the thumb
  80127. */
  80128. get thumbHeight(): number;
  80129. set thumbHeight(value: number);
  80130. /**
  80131. * Gets or sets the height of the bar image
  80132. */
  80133. get barImageHeight(): number;
  80134. set barImageHeight(value: number);
  80135. /**
  80136. * Creates a new ImageScrollBar
  80137. * @param name defines the control name
  80138. */
  80139. constructor(name?: string | undefined);
  80140. protected _getTypeName(): string;
  80141. protected _getThumbThickness(): number;
  80142. _draw(context: CanvasRenderingContext2D): void;
  80143. private _first;
  80144. private _originX;
  80145. private _originY;
  80146. /** @hidden */
  80147. protected _updateValueFromPointer(x: number, y: number): void;
  80148. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80149. }
  80150. }
  80151. declare module BABYLON.GUI {
  80152. /**
  80153. * Class used to hold a viewer window and sliders in a grid
  80154. */
  80155. export class ScrollViewer extends Rectangle {
  80156. private _grid;
  80157. private _horizontalBarSpace;
  80158. private _verticalBarSpace;
  80159. private _dragSpace;
  80160. private _horizontalBar;
  80161. private _verticalBar;
  80162. private _barColor;
  80163. private _barBackground;
  80164. private _barImage;
  80165. private _horizontalBarImage;
  80166. private _verticalBarImage;
  80167. private _barBackgroundImage;
  80168. private _horizontalBarBackgroundImage;
  80169. private _verticalBarBackgroundImage;
  80170. private _barSize;
  80171. private _window;
  80172. private _pointerIsOver;
  80173. private _wheelPrecision;
  80174. private _onWheelObserver;
  80175. private _clientWidth;
  80176. private _clientHeight;
  80177. private _useImageBar;
  80178. private _thumbLength;
  80179. private _thumbHeight;
  80180. private _barImageHeight;
  80181. private _horizontalBarImageHeight;
  80182. private _verticalBarImageHeight;
  80183. private _oldWindowContentsWidth;
  80184. private _oldWindowContentsHeight;
  80185. /**
  80186. * Gets the horizontal scrollbar
  80187. */
  80188. get horizontalBar(): ScrollBar | ImageScrollBar;
  80189. /**
  80190. * Gets the vertical scrollbar
  80191. */
  80192. get verticalBar(): ScrollBar | ImageScrollBar;
  80193. /**
  80194. * Adds a new control to the current container
  80195. * @param control defines the control to add
  80196. * @returns the current container
  80197. */
  80198. addControl(control: BABYLON.Nullable<Control>): Container;
  80199. /**
  80200. * Removes a control from the current container
  80201. * @param control defines the control to remove
  80202. * @returns the current container
  80203. */
  80204. removeControl(control: Control): Container;
  80205. /** Gets the list of children */
  80206. get children(): Control[];
  80207. _flagDescendantsAsMatrixDirty(): void;
  80208. /**
  80209. * Freezes or unfreezes the controls in the window.
  80210. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80211. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80212. */
  80213. get freezeControls(): boolean;
  80214. set freezeControls(value: boolean);
  80215. /** Gets the bucket width */
  80216. get bucketWidth(): number;
  80217. /** Gets the bucket height */
  80218. get bucketHeight(): number;
  80219. /**
  80220. * Sets the bucket sizes.
  80221. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80222. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80223. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80224. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80225. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80226. * used), that's why it is not enabled by default.
  80227. * @param width width of the bucket
  80228. * @param height height of the bucket
  80229. */
  80230. setBucketSizes(width: number, height: number): void;
  80231. private _forceHorizontalBar;
  80232. private _forceVerticalBar;
  80233. /**
  80234. * Forces the horizontal scroll bar to be displayed
  80235. */
  80236. get forceHorizontalBar(): boolean;
  80237. set forceHorizontalBar(value: boolean);
  80238. /**
  80239. * Forces the vertical scroll bar to be displayed
  80240. */
  80241. get forceVerticalBar(): boolean;
  80242. set forceVerticalBar(value: boolean);
  80243. /**
  80244. * Creates a new ScrollViewer
  80245. * @param name of ScrollViewer
  80246. */
  80247. constructor(name?: string, isImageBased?: boolean);
  80248. /** Reset the scroll viewer window to initial size */
  80249. resetWindow(): void;
  80250. protected _getTypeName(): string;
  80251. private _buildClientSizes;
  80252. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80253. protected _postMeasure(): void;
  80254. /**
  80255. * Gets or sets the mouse wheel precision
  80256. * from 0 to 1 with a default value of 0.05
  80257. * */
  80258. get wheelPrecision(): number;
  80259. set wheelPrecision(value: number);
  80260. /** Gets or sets the scroll bar container background color */
  80261. get scrollBackground(): string;
  80262. set scrollBackground(color: string);
  80263. /** Gets or sets the bar color */
  80264. get barColor(): string;
  80265. set barColor(color: string);
  80266. /** Gets or sets the bar image */
  80267. get thumbImage(): Image;
  80268. set thumbImage(value: Image);
  80269. /** Gets or sets the horizontal bar image */
  80270. get horizontalThumbImage(): Image;
  80271. set horizontalThumbImage(value: Image);
  80272. /** Gets or sets the vertical bar image */
  80273. get verticalThumbImage(): Image;
  80274. set verticalThumbImage(value: Image);
  80275. /** Gets or sets the size of the bar */
  80276. get barSize(): number;
  80277. set barSize(value: number);
  80278. /** Gets or sets the length of the thumb */
  80279. get thumbLength(): number;
  80280. set thumbLength(value: number);
  80281. /** Gets or sets the height of the thumb */
  80282. get thumbHeight(): number;
  80283. set thumbHeight(value: number);
  80284. /** Gets or sets the height of the bar image */
  80285. get barImageHeight(): number;
  80286. set barImageHeight(value: number);
  80287. /** Gets or sets the height of the horizontal bar image */
  80288. get horizontalBarImageHeight(): number;
  80289. set horizontalBarImageHeight(value: number);
  80290. /** Gets or sets the height of the vertical bar image */
  80291. get verticalBarImageHeight(): number;
  80292. set verticalBarImageHeight(value: number);
  80293. /** Gets or sets the bar background */
  80294. get barBackground(): string;
  80295. set barBackground(color: string);
  80296. /** Gets or sets the bar background image */
  80297. get barImage(): Image;
  80298. set barImage(value: Image);
  80299. /** Gets or sets the horizontal bar background image */
  80300. get horizontalBarImage(): Image;
  80301. set horizontalBarImage(value: Image);
  80302. /** Gets or sets the vertical bar background image */
  80303. get verticalBarImage(): Image;
  80304. set verticalBarImage(value: Image);
  80305. private _setWindowPosition;
  80306. /** @hidden */
  80307. private _updateScroller;
  80308. _link(host: AdvancedDynamicTexture): void;
  80309. /** @hidden */
  80310. private _addBar;
  80311. /** @hidden */
  80312. private _attachWheel;
  80313. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80314. /** Releases associated resources */
  80315. dispose(): void;
  80316. }
  80317. }
  80318. declare module BABYLON.GUI {
  80319. /** Class used to render a grid */
  80320. export class DisplayGrid extends Control {
  80321. name?: string | undefined;
  80322. private _cellWidth;
  80323. private _cellHeight;
  80324. private _minorLineTickness;
  80325. private _minorLineColor;
  80326. private _majorLineTickness;
  80327. private _majorLineColor;
  80328. private _majorLineFrequency;
  80329. private _background;
  80330. private _displayMajorLines;
  80331. private _displayMinorLines;
  80332. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80333. get displayMinorLines(): boolean;
  80334. set displayMinorLines(value: boolean);
  80335. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80336. get displayMajorLines(): boolean;
  80337. set displayMajorLines(value: boolean);
  80338. /** Gets or sets background color (Black by default) */
  80339. get background(): string;
  80340. set background(value: string);
  80341. /** Gets or sets the width of each cell (20 by default) */
  80342. get cellWidth(): number;
  80343. set cellWidth(value: number);
  80344. /** Gets or sets the height of each cell (20 by default) */
  80345. get cellHeight(): number;
  80346. set cellHeight(value: number);
  80347. /** Gets or sets the tickness of minor lines (1 by default) */
  80348. get minorLineTickness(): number;
  80349. set minorLineTickness(value: number);
  80350. /** Gets or sets the color of minor lines (DarkGray by default) */
  80351. get minorLineColor(): string;
  80352. set minorLineColor(value: string);
  80353. /** Gets or sets the tickness of major lines (2 by default) */
  80354. get majorLineTickness(): number;
  80355. set majorLineTickness(value: number);
  80356. /** Gets or sets the color of major lines (White by default) */
  80357. get majorLineColor(): string;
  80358. set majorLineColor(value: string);
  80359. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80360. get majorLineFrequency(): number;
  80361. set majorLineFrequency(value: number);
  80362. /**
  80363. * Creates a new GridDisplayRectangle
  80364. * @param name defines the control name
  80365. */
  80366. constructor(name?: string | undefined);
  80367. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80368. protected _getTypeName(): string;
  80369. }
  80370. }
  80371. declare module BABYLON.GUI {
  80372. /**
  80373. * Class used to create slider controls based on images
  80374. */
  80375. export class ImageBasedSlider extends BaseSlider {
  80376. name?: string | undefined;
  80377. private _backgroundImage;
  80378. private _thumbImage;
  80379. private _valueBarImage;
  80380. private _tempMeasure;
  80381. get displayThumb(): boolean;
  80382. set displayThumb(value: boolean);
  80383. /**
  80384. * Gets or sets the image used to render the background
  80385. */
  80386. get backgroundImage(): Image;
  80387. set backgroundImage(value: Image);
  80388. /**
  80389. * Gets or sets the image used to render the value bar
  80390. */
  80391. get valueBarImage(): Image;
  80392. set valueBarImage(value: Image);
  80393. /**
  80394. * Gets or sets the image used to render the thumb
  80395. */
  80396. get thumbImage(): Image;
  80397. set thumbImage(value: Image);
  80398. /**
  80399. * Creates a new ImageBasedSlider
  80400. * @param name defines the control name
  80401. */
  80402. constructor(name?: string | undefined);
  80403. protected _getTypeName(): string;
  80404. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80405. }
  80406. }
  80407. declare module BABYLON.GUI {
  80408. /**
  80409. * Forcing an export so that this code will execute
  80410. * @hidden
  80411. */
  80412. const name = "Statics";
  80413. }
  80414. declare module BABYLON.GUI {
  80415. /**
  80416. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80417. */
  80418. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80419. /**
  80420. * Define the instrumented AdvancedDynamicTexture.
  80421. */
  80422. texture: AdvancedDynamicTexture;
  80423. private _captureRenderTime;
  80424. private _renderTime;
  80425. private _captureLayoutTime;
  80426. private _layoutTime;
  80427. private _onBeginRenderObserver;
  80428. private _onEndRenderObserver;
  80429. private _onBeginLayoutObserver;
  80430. private _onEndLayoutObserver;
  80431. /**
  80432. * Gets the perf counter used to capture render time
  80433. */
  80434. get renderTimeCounter(): BABYLON.PerfCounter;
  80435. /**
  80436. * Gets the perf counter used to capture layout time
  80437. */
  80438. get layoutTimeCounter(): BABYLON.PerfCounter;
  80439. /**
  80440. * Enable or disable the render time capture
  80441. */
  80442. get captureRenderTime(): boolean;
  80443. set captureRenderTime(value: boolean);
  80444. /**
  80445. * Enable or disable the layout time capture
  80446. */
  80447. get captureLayoutTime(): boolean;
  80448. set captureLayoutTime(value: boolean);
  80449. /**
  80450. * Instantiates a new advanced dynamic texture instrumentation.
  80451. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80452. * @param texture Defines the AdvancedDynamicTexture to instrument
  80453. */
  80454. constructor(
  80455. /**
  80456. * Define the instrumented AdvancedDynamicTexture.
  80457. */
  80458. texture: AdvancedDynamicTexture);
  80459. /**
  80460. * Dispose and release associated resources.
  80461. */
  80462. dispose(): void;
  80463. }
  80464. }
  80465. declare module BABYLON.GUI {
  80466. /**
  80467. * Class used to load GUI via XML.
  80468. */
  80469. export class XmlLoader {
  80470. private _nodes;
  80471. private _nodeTypes;
  80472. private _isLoaded;
  80473. private _objectAttributes;
  80474. private _parentClass;
  80475. /**
  80476. * Create a new xml loader
  80477. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80478. */
  80479. constructor(parentClass?: null);
  80480. private _getChainElement;
  80481. private _getClassAttribute;
  80482. private _createGuiElement;
  80483. private _parseGrid;
  80484. private _parseElement;
  80485. private _prepareSourceElement;
  80486. private _parseElementsFromSource;
  80487. private _parseXml;
  80488. /**
  80489. * Gets if the loading has finished.
  80490. * @returns whether the loading has finished or not
  80491. */
  80492. isLoaded(): boolean;
  80493. /**
  80494. * Gets a loaded node / control by id.
  80495. * @param id the Controls id set in the xml
  80496. * @returns element of type Control
  80497. */
  80498. getNodeById(id: string): any;
  80499. /**
  80500. * Gets all loaded nodes / controls
  80501. * @returns Array of controls
  80502. */
  80503. getNodes(): any;
  80504. /**
  80505. * Initiates the xml layout loading
  80506. * @param xmlFile defines the xml layout to load
  80507. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80508. * @param callback defines the callback called on layout load.
  80509. */
  80510. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80511. }
  80512. }
  80513. declare module BABYLON.GUI {
  80514. /**
  80515. * Class used to create containers for controls
  80516. */
  80517. export class Container3D extends Control3D {
  80518. private _blockLayout;
  80519. /**
  80520. * Gets the list of child controls
  80521. */
  80522. protected _children: Control3D[];
  80523. /**
  80524. * Gets the list of child controls
  80525. */
  80526. get children(): Array<Control3D>;
  80527. /**
  80528. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80529. * This is helpful to optimize layout operation when adding multiple children in a row
  80530. */
  80531. get blockLayout(): boolean;
  80532. set blockLayout(value: boolean);
  80533. /**
  80534. * Creates a new container
  80535. * @param name defines the container name
  80536. */
  80537. constructor(name?: string);
  80538. /**
  80539. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80540. * @returns the current container
  80541. */
  80542. updateLayout(): Container3D;
  80543. /**
  80544. * Gets a boolean indicating if the given control is in the children of this control
  80545. * @param control defines the control to check
  80546. * @returns true if the control is in the child list
  80547. */
  80548. containsControl(control: Control3D): boolean;
  80549. /**
  80550. * Adds a control to the children of this control
  80551. * @param control defines the control to add
  80552. * @returns the current container
  80553. */
  80554. addControl(control: Control3D): Container3D;
  80555. /**
  80556. * This function will be called everytime a new control is added
  80557. */
  80558. protected _arrangeChildren(): void;
  80559. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80560. /**
  80561. * Removes a control from the children of this control
  80562. * @param control defines the control to remove
  80563. * @returns the current container
  80564. */
  80565. removeControl(control: Control3D): Container3D;
  80566. protected _getTypeName(): string;
  80567. /**
  80568. * Releases all associated resources
  80569. */
  80570. dispose(): void;
  80571. /** Control rotation will remain unchanged */
  80572. static readonly UNSET_ORIENTATION: number;
  80573. /** Control will rotate to make it look at sphere central axis */
  80574. static readonly FACEORIGIN_ORIENTATION: number;
  80575. /** Control will rotate to make it look back at sphere central axis */
  80576. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80577. /** Control will rotate to look at z axis (0, 0, 1) */
  80578. static readonly FACEFORWARD_ORIENTATION: number;
  80579. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80580. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80581. }
  80582. }
  80583. declare module BABYLON.GUI {
  80584. /**
  80585. * Class used to manage 3D user interface
  80586. * @see https://doc.babylonjs.com/how_to/gui3d
  80587. */
  80588. export class GUI3DManager implements BABYLON.IDisposable {
  80589. private _scene;
  80590. private _sceneDisposeObserver;
  80591. private _utilityLayer;
  80592. private _rootContainer;
  80593. private _pointerObserver;
  80594. private _pointerOutObserver;
  80595. /** @hidden */
  80596. _lastPickedControl: Control3D;
  80597. /** @hidden */
  80598. _lastControlOver: {
  80599. [pointerId: number]: Control3D;
  80600. };
  80601. /** @hidden */
  80602. _lastControlDown: {
  80603. [pointerId: number]: Control3D;
  80604. };
  80605. /**
  80606. * BABYLON.Observable raised when the point picked by the pointer events changed
  80607. */
  80608. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80609. /** @hidden */
  80610. _sharedMaterials: {
  80611. [key: string]: BABYLON.Material;
  80612. };
  80613. /** Gets the hosting scene */
  80614. get scene(): BABYLON.Scene;
  80615. /** Gets associated utility layer */
  80616. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80617. /**
  80618. * Creates a new GUI3DManager
  80619. * @param scene
  80620. */
  80621. constructor(scene?: BABYLON.Scene);
  80622. private _handlePointerOut;
  80623. private _doPicking;
  80624. /**
  80625. * Gets the root container
  80626. */
  80627. get rootContainer(): Container3D;
  80628. /**
  80629. * Gets a boolean indicating if the given control is in the root child list
  80630. * @param control defines the control to check
  80631. * @returns true if the control is in the root child list
  80632. */
  80633. containsControl(control: Control3D): boolean;
  80634. /**
  80635. * Adds a control to the root child list
  80636. * @param control defines the control to add
  80637. * @returns the current manager
  80638. */
  80639. addControl(control: Control3D): GUI3DManager;
  80640. /**
  80641. * Removes a control from the root child list
  80642. * @param control defines the control to remove
  80643. * @returns the current container
  80644. */
  80645. removeControl(control: Control3D): GUI3DManager;
  80646. /**
  80647. * Releases all associated resources
  80648. */
  80649. dispose(): void;
  80650. }
  80651. }
  80652. declare module BABYLON.GUI {
  80653. /**
  80654. * Class used to transport BABYLON.Vector3 information for pointer events
  80655. */
  80656. export class Vector3WithInfo extends BABYLON.Vector3 {
  80657. /** defines the current mouse button index */
  80658. buttonIndex: number;
  80659. /**
  80660. * Creates a new Vector3WithInfo
  80661. * @param source defines the vector3 data to transport
  80662. * @param buttonIndex defines the current mouse button index
  80663. */
  80664. constructor(source: BABYLON.Vector3,
  80665. /** defines the current mouse button index */
  80666. buttonIndex?: number);
  80667. }
  80668. }
  80669. declare module BABYLON.GUI {
  80670. /**
  80671. * Class used as base class for controls
  80672. */
  80673. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80674. /** Defines the control name */
  80675. name?: string | undefined;
  80676. /** @hidden */
  80677. _host: GUI3DManager;
  80678. private _node;
  80679. private _downCount;
  80680. private _enterCount;
  80681. private _downPointerIds;
  80682. private _isVisible;
  80683. /** Gets or sets the control position in world space */
  80684. get position(): BABYLON.Vector3;
  80685. set position(value: BABYLON.Vector3);
  80686. /** Gets or sets the control scaling in world space */
  80687. get scaling(): BABYLON.Vector3;
  80688. set scaling(value: BABYLON.Vector3);
  80689. /** Callback used to start pointer enter animation */
  80690. pointerEnterAnimation: () => void;
  80691. /** Callback used to start pointer out animation */
  80692. pointerOutAnimation: () => void;
  80693. /** Callback used to start pointer down animation */
  80694. pointerDownAnimation: () => void;
  80695. /** Callback used to start pointer up animation */
  80696. pointerUpAnimation: () => void;
  80697. /**
  80698. * An event triggered when the pointer move over the control
  80699. */
  80700. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80701. /**
  80702. * An event triggered when the pointer move out of the control
  80703. */
  80704. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80705. /**
  80706. * An event triggered when the pointer taps the control
  80707. */
  80708. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80709. /**
  80710. * An event triggered when pointer is up
  80711. */
  80712. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80713. /**
  80714. * An event triggered when a control is clicked on (with a mouse)
  80715. */
  80716. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80717. /**
  80718. * An event triggered when pointer enters the control
  80719. */
  80720. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80721. /**
  80722. * Gets or sets the parent container
  80723. */
  80724. parent: BABYLON.Nullable<Container3D>;
  80725. private _behaviors;
  80726. /**
  80727. * Gets the list of attached behaviors
  80728. * @see https://doc.babylonjs.com/features/behaviour
  80729. */
  80730. get behaviors(): BABYLON.Behavior<Control3D>[];
  80731. /**
  80732. * Attach a behavior to the control
  80733. * @see https://doc.babylonjs.com/features/behaviour
  80734. * @param behavior defines the behavior to attach
  80735. * @returns the current control
  80736. */
  80737. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80738. /**
  80739. * Remove an attached behavior
  80740. * @see https://doc.babylonjs.com/features/behaviour
  80741. * @param behavior defines the behavior to attach
  80742. * @returns the current control
  80743. */
  80744. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80745. /**
  80746. * Gets an attached behavior by name
  80747. * @param name defines the name of the behavior to look for
  80748. * @see https://doc.babylonjs.com/features/behaviour
  80749. * @returns null if behavior was not found else the requested behavior
  80750. */
  80751. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80752. /** Gets or sets a boolean indicating if the control is visible */
  80753. get isVisible(): boolean;
  80754. set isVisible(value: boolean);
  80755. /**
  80756. * Creates a new control
  80757. * @param name defines the control name
  80758. */
  80759. constructor(
  80760. /** Defines the control name */
  80761. name?: string | undefined);
  80762. /**
  80763. * Gets a string representing the class name
  80764. */
  80765. get typeName(): string;
  80766. /**
  80767. * Get the current class name of the control.
  80768. * @returns current class name
  80769. */
  80770. getClassName(): string;
  80771. protected _getTypeName(): string;
  80772. /**
  80773. * Gets the transform node used by this control
  80774. */
  80775. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80776. /**
  80777. * Gets the mesh used to render this control
  80778. */
  80779. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80780. /**
  80781. * Link the control as child of the given node
  80782. * @param node defines the node to link to. Use null to unlink the control
  80783. * @returns the current control
  80784. */
  80785. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80786. /** @hidden **/
  80787. _prepareNode(scene: BABYLON.Scene): void;
  80788. /**
  80789. * Node creation.
  80790. * Can be overriden by children
  80791. * @param scene defines the scene where the node must be attached
  80792. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80793. */
  80794. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80795. /**
  80796. * Affect a material to the given mesh
  80797. * @param mesh defines the mesh which will represent the control
  80798. */
  80799. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80800. /** @hidden */
  80801. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80802. /** @hidden */
  80803. _onPointerEnter(target: Control3D): boolean;
  80804. /** @hidden */
  80805. _onPointerOut(target: Control3D): void;
  80806. /** @hidden */
  80807. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80808. /** @hidden */
  80809. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80810. /** @hidden */
  80811. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80812. /** @hidden */
  80813. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80814. /** @hidden */
  80815. _disposeNode(): void;
  80816. /**
  80817. * Releases all associated resources
  80818. */
  80819. dispose(): void;
  80820. }
  80821. }
  80822. declare module BABYLON.GUI {
  80823. /**
  80824. * Class used as a root to all buttons
  80825. */
  80826. export class AbstractButton3D extends Control3D {
  80827. /**
  80828. * Creates a new button
  80829. * @param name defines the control name
  80830. */
  80831. constructor(name?: string);
  80832. protected _getTypeName(): string;
  80833. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80834. }
  80835. }
  80836. declare module BABYLON.GUI {
  80837. /**
  80838. * Class used to create a button in 3D
  80839. */
  80840. export class Button3D extends AbstractButton3D {
  80841. /** @hidden */
  80842. protected _currentMaterial: BABYLON.Material;
  80843. private _facadeTexture;
  80844. private _content;
  80845. private _contentResolution;
  80846. private _contentScaleRatio;
  80847. /**
  80848. * Gets or sets the texture resolution used to render content (512 by default)
  80849. */
  80850. get contentResolution(): BABYLON.int;
  80851. set contentResolution(value: BABYLON.int);
  80852. /**
  80853. * Gets or sets the texture scale ratio used to render content (2 by default)
  80854. */
  80855. get contentScaleRatio(): number;
  80856. set contentScaleRatio(value: number);
  80857. protected _disposeFacadeTexture(): void;
  80858. protected _resetContent(): void;
  80859. /**
  80860. * Creates a new button
  80861. * @param name defines the control name
  80862. */
  80863. constructor(name?: string);
  80864. /**
  80865. * Gets or sets the GUI 2D content used to display the button's facade
  80866. */
  80867. get content(): Control;
  80868. set content(value: Control);
  80869. /**
  80870. * Apply the facade texture (created from the content property).
  80871. * This function can be overloaded by child classes
  80872. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80873. */
  80874. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80875. protected _getTypeName(): string;
  80876. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80877. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80878. /**
  80879. * Releases all associated resources
  80880. */
  80881. dispose(): void;
  80882. }
  80883. }
  80884. declare module BABYLON.GUI {
  80885. /**
  80886. * Abstract class used to create a container panel deployed on the surface of a volume
  80887. */
  80888. export abstract class VolumeBasedPanel extends Container3D {
  80889. private _columns;
  80890. private _rows;
  80891. private _rowThenColum;
  80892. private _orientation;
  80893. protected _cellWidth: number;
  80894. protected _cellHeight: number;
  80895. /**
  80896. * Gets or sets the distance between elements
  80897. */
  80898. margin: number;
  80899. /**
  80900. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80901. * | Value | Type | Description |
  80902. * | ----- | ----------------------------------- | ----------- |
  80903. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80904. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80905. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80906. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80907. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80908. */
  80909. get orientation(): number;
  80910. set orientation(value: number);
  80911. /**
  80912. * Gets or sets the number of columns requested (10 by default).
  80913. * The panel will automatically compute the number of rows based on number of child controls.
  80914. */
  80915. get columns(): BABYLON.int;
  80916. set columns(value: BABYLON.int);
  80917. /**
  80918. * Gets or sets a the number of rows requested.
  80919. * The panel will automatically compute the number of columns based on number of child controls.
  80920. */
  80921. get rows(): BABYLON.int;
  80922. set rows(value: BABYLON.int);
  80923. /**
  80924. * Creates new VolumeBasedPanel
  80925. */
  80926. constructor();
  80927. protected _arrangeChildren(): void;
  80928. /** Child classes must implement this function to provide correct control positioning */
  80929. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80930. /** Child classes can implement this function to provide additional processing */
  80931. protected _finalProcessing(): void;
  80932. }
  80933. }
  80934. declare module BABYLON.GUI {
  80935. /**
  80936. * Class used to create a container panel deployed on the surface of a cylinder
  80937. */
  80938. export class CylinderPanel extends VolumeBasedPanel {
  80939. private _radius;
  80940. /**
  80941. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80942. */
  80943. get radius(): BABYLON.float;
  80944. set radius(value: BABYLON.float);
  80945. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80946. private _cylindricalMapping;
  80947. }
  80948. }
  80949. declare module BABYLON.GUI {
  80950. /** @hidden */
  80951. export var fluentVertexShader: {
  80952. name: string;
  80953. shader: string;
  80954. };
  80955. }
  80956. declare module BABYLON.GUI {
  80957. /** @hidden */
  80958. export var fluentPixelShader: {
  80959. name: string;
  80960. shader: string;
  80961. };
  80962. }
  80963. declare module BABYLON.GUI {
  80964. /** @hidden */
  80965. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80966. INNERGLOW: boolean;
  80967. BORDER: boolean;
  80968. HOVERLIGHT: boolean;
  80969. TEXTURE: boolean;
  80970. constructor();
  80971. }
  80972. /**
  80973. * Class used to render controls with fluent desgin
  80974. */
  80975. export class FluentMaterial extends BABYLON.PushMaterial {
  80976. /**
  80977. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80978. */
  80979. innerGlowColorIntensity: number;
  80980. /**
  80981. * Gets or sets the inner glow color (white by default)
  80982. */
  80983. innerGlowColor: BABYLON.Color3;
  80984. /**
  80985. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80986. */
  80987. albedoColor: BABYLON.Color3;
  80988. /**
  80989. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80990. */
  80991. renderBorders: boolean;
  80992. /**
  80993. * Gets or sets border width (default is 0.5)
  80994. */
  80995. borderWidth: number;
  80996. /**
  80997. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80998. */
  80999. edgeSmoothingValue: number;
  81000. /**
  81001. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81002. */
  81003. borderMinValue: number;
  81004. /**
  81005. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81006. */
  81007. renderHoverLight: boolean;
  81008. /**
  81009. * Gets or sets the radius used to render the hover light (default is 1.0)
  81010. */
  81011. hoverRadius: number;
  81012. /**
  81013. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81014. */
  81015. hoverColor: BABYLON.Color4;
  81016. /**
  81017. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81018. */
  81019. hoverPosition: BABYLON.Vector3;
  81020. private _albedoTexture;
  81021. /** Gets or sets the texture to use for albedo color */
  81022. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81023. /**
  81024. * Creates a new Fluent material
  81025. * @param name defines the name of the material
  81026. * @param scene defines the hosting scene
  81027. */
  81028. constructor(name: string, scene: BABYLON.Scene);
  81029. needAlphaBlending(): boolean;
  81030. needAlphaTesting(): boolean;
  81031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81034. getActiveTextures(): BABYLON.BaseTexture[];
  81035. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81036. dispose(forceDisposeEffect?: boolean): void;
  81037. clone(name: string): FluentMaterial;
  81038. serialize(): any;
  81039. getClassName(): string;
  81040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81041. }
  81042. }
  81043. declare module BABYLON.GUI {
  81044. /**
  81045. * Class used to create a holographic button in 3D
  81046. */
  81047. export class HolographicButton extends Button3D {
  81048. private _backPlate;
  81049. private _textPlate;
  81050. private _frontPlate;
  81051. private _text;
  81052. private _imageUrl;
  81053. private _shareMaterials;
  81054. private _frontMaterial;
  81055. private _backMaterial;
  81056. private _plateMaterial;
  81057. private _pickedPointObserver;
  81058. private _tooltipFade;
  81059. private _tooltipTextBlock;
  81060. private _tooltipTexture;
  81061. private _tooltipMesh;
  81062. private _tooltipHoverObserver;
  81063. private _tooltipOutObserver;
  81064. private _disposeTooltip;
  81065. /**
  81066. * Rendering ground id of all the mesh in the button
  81067. */
  81068. set renderingGroupId(id: number);
  81069. get renderingGroupId(): number;
  81070. /**
  81071. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81072. */
  81073. set tooltipText(text: BABYLON.Nullable<string>);
  81074. get tooltipText(): BABYLON.Nullable<string>;
  81075. /**
  81076. * Gets or sets text for the button
  81077. */
  81078. get text(): string;
  81079. set text(value: string);
  81080. /**
  81081. * Gets or sets the image url for the button
  81082. */
  81083. get imageUrl(): string;
  81084. set imageUrl(value: string);
  81085. /**
  81086. * Gets the back material used by this button
  81087. */
  81088. get backMaterial(): FluentMaterial;
  81089. /**
  81090. * Gets the front material used by this button
  81091. */
  81092. get frontMaterial(): FluentMaterial;
  81093. /**
  81094. * Gets the plate material used by this button
  81095. */
  81096. get plateMaterial(): BABYLON.StandardMaterial;
  81097. /**
  81098. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81099. */
  81100. get shareMaterials(): boolean;
  81101. /**
  81102. * Creates a new button
  81103. * @param name defines the control name
  81104. */
  81105. constructor(name?: string, shareMaterials?: boolean);
  81106. protected _getTypeName(): string;
  81107. private _rebuildContent;
  81108. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81109. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81110. private _createBackMaterial;
  81111. private _createFrontMaterial;
  81112. private _createPlateMaterial;
  81113. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81114. /**
  81115. * Releases all associated resources
  81116. */
  81117. dispose(): void;
  81118. }
  81119. }
  81120. declare module BABYLON.GUI {
  81121. /**
  81122. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81123. */
  81124. export class MeshButton3D extends Button3D {
  81125. /** @hidden */
  81126. protected _currentMesh: BABYLON.Mesh;
  81127. /**
  81128. * Creates a new 3D button based on a mesh
  81129. * @param mesh mesh to become a 3D button
  81130. * @param name defines the control name
  81131. */
  81132. constructor(mesh: BABYLON.Mesh, name?: string);
  81133. protected _getTypeName(): string;
  81134. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81135. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81136. }
  81137. }
  81138. declare module BABYLON.GUI {
  81139. /**
  81140. * Class used to create a container panel deployed on the surface of a plane
  81141. */
  81142. export class PlanePanel extends VolumeBasedPanel {
  81143. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81144. }
  81145. }
  81146. declare module BABYLON.GUI {
  81147. /**
  81148. * Class used to create a container panel where items get randomized planar mapping
  81149. */
  81150. export class ScatterPanel extends VolumeBasedPanel {
  81151. private _iteration;
  81152. /**
  81153. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81154. */
  81155. get iteration(): BABYLON.float;
  81156. set iteration(value: BABYLON.float);
  81157. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81158. private _scatterMapping;
  81159. protected _finalProcessing(): void;
  81160. }
  81161. }
  81162. declare module BABYLON.GUI {
  81163. /**
  81164. * Class used to create a container panel deployed on the surface of a sphere
  81165. */
  81166. export class SpherePanel extends VolumeBasedPanel {
  81167. private _radius;
  81168. /**
  81169. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81170. */
  81171. get radius(): BABYLON.float;
  81172. set radius(value: BABYLON.float);
  81173. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81174. private _sphericalMapping;
  81175. }
  81176. }
  81177. declare module BABYLON.GUI {
  81178. /**
  81179. * Class used to create a stack panel in 3D on XY plane
  81180. */
  81181. export class StackPanel3D extends Container3D {
  81182. private _isVertical;
  81183. /**
  81184. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81185. */
  81186. get isVertical(): boolean;
  81187. set isVertical(value: boolean);
  81188. /**
  81189. * Gets or sets the distance between elements
  81190. */
  81191. margin: number;
  81192. /**
  81193. * Creates new StackPanel
  81194. * @param isVertical
  81195. */
  81196. constructor(isVertical?: boolean);
  81197. protected _arrangeChildren(): void;
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. /**
  81202. * Configuration for glTF validation
  81203. */
  81204. export interface IGLTFValidationConfiguration {
  81205. /**
  81206. * The url of the glTF validator.
  81207. */
  81208. url: string;
  81209. }
  81210. /**
  81211. * glTF validation
  81212. */
  81213. export class GLTFValidation {
  81214. /**
  81215. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81216. */
  81217. static Configuration: IGLTFValidationConfiguration;
  81218. private static _LoadScriptPromise;
  81219. /**
  81220. * Validate a glTF asset using the glTF-Validator.
  81221. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81222. * @param rootUrl The root url for the glTF
  81223. * @param fileName The file name for the glTF
  81224. * @param getExternalResource The callback to get external resources for the glTF validator
  81225. * @returns A promise that resolves with the glTF validation results once complete
  81226. */
  81227. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81228. }
  81229. }
  81230. declare module BABYLON {
  81231. /**
  81232. * Mode that determines the coordinate system to use.
  81233. */
  81234. export enum GLTFLoaderCoordinateSystemMode {
  81235. /**
  81236. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81237. */
  81238. AUTO = 0,
  81239. /**
  81240. * Sets the useRightHandedSystem flag on the scene.
  81241. */
  81242. FORCE_RIGHT_HANDED = 1
  81243. }
  81244. /**
  81245. * Mode that determines what animations will start.
  81246. */
  81247. export enum GLTFLoaderAnimationStartMode {
  81248. /**
  81249. * No animation will start.
  81250. */
  81251. NONE = 0,
  81252. /**
  81253. * The first animation will start.
  81254. */
  81255. FIRST = 1,
  81256. /**
  81257. * All animations will start.
  81258. */
  81259. ALL = 2
  81260. }
  81261. /**
  81262. * Interface that contains the data for the glTF asset.
  81263. */
  81264. export interface IGLTFLoaderData {
  81265. /**
  81266. * The object that represents the glTF JSON.
  81267. */
  81268. json: Object;
  81269. /**
  81270. * The BIN chunk of a binary glTF.
  81271. */
  81272. bin: Nullable<IDataBuffer>;
  81273. }
  81274. /**
  81275. * Interface for extending the loader.
  81276. */
  81277. export interface IGLTFLoaderExtension {
  81278. /**
  81279. * The name of this extension.
  81280. */
  81281. readonly name: string;
  81282. /**
  81283. * Defines whether this extension is enabled.
  81284. */
  81285. enabled: boolean;
  81286. /**
  81287. * Defines the order of this extension.
  81288. * The loader sorts the extensions using these values when loading.
  81289. */
  81290. order?: number;
  81291. }
  81292. /**
  81293. * Loader state.
  81294. */
  81295. export enum GLTFLoaderState {
  81296. /**
  81297. * The asset is loading.
  81298. */
  81299. LOADING = 0,
  81300. /**
  81301. * The asset is ready for rendering.
  81302. */
  81303. READY = 1,
  81304. /**
  81305. * The asset is completely loaded.
  81306. */
  81307. COMPLETE = 2
  81308. }
  81309. /** @hidden */
  81310. export interface IImportMeshAsyncOutput {
  81311. meshes: AbstractMesh[];
  81312. particleSystems: IParticleSystem[];
  81313. skeletons: Skeleton[];
  81314. animationGroups: AnimationGroup[];
  81315. lights: Light[];
  81316. transformNodes: TransformNode[];
  81317. }
  81318. /** @hidden */
  81319. export interface IGLTFLoader extends IDisposable {
  81320. readonly state: Nullable<GLTFLoaderState>;
  81321. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81322. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81323. }
  81324. /**
  81325. * File loader for loading glTF files into a scene.
  81326. */
  81327. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81328. /** @hidden */
  81329. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81330. /** @hidden */
  81331. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81332. /**
  81333. * Raised when the asset has been parsed
  81334. */
  81335. onParsedObservable: Observable<IGLTFLoaderData>;
  81336. private _onParsedObserver;
  81337. /**
  81338. * Raised when the asset has been parsed
  81339. */
  81340. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81341. /**
  81342. * 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.
  81343. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81344. * Defaults to true.
  81345. * @hidden
  81346. */
  81347. static IncrementalLoading: boolean;
  81348. /**
  81349. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81350. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81351. * @hidden
  81352. */
  81353. static HomogeneousCoordinates: boolean;
  81354. /**
  81355. * The coordinate system mode. Defaults to AUTO.
  81356. */
  81357. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81358. /**
  81359. * The animation start mode. Defaults to FIRST.
  81360. */
  81361. animationStartMode: GLTFLoaderAnimationStartMode;
  81362. /**
  81363. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81364. */
  81365. compileMaterials: boolean;
  81366. /**
  81367. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81368. */
  81369. useClipPlane: boolean;
  81370. /**
  81371. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81372. */
  81373. compileShadowGenerators: boolean;
  81374. /**
  81375. * Defines if the Alpha blended materials are only applied as coverage.
  81376. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81377. * If true, no extra effects are applied to transparent pixels.
  81378. */
  81379. transparencyAsCoverage: boolean;
  81380. /**
  81381. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81382. * Enabling will disable offline support and glTF validator.
  81383. * Defaults to false.
  81384. */
  81385. useRangeRequests: boolean;
  81386. /**
  81387. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81388. */
  81389. createInstances: boolean;
  81390. /**
  81391. * 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.
  81392. */
  81393. alwaysComputeBoundingBox: boolean;
  81394. /**
  81395. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81396. */
  81397. loadAllMaterials: boolean;
  81398. /**
  81399. * Function called before loading a url referenced by the asset.
  81400. */
  81401. preprocessUrlAsync: (url: string) => Promise<string>;
  81402. /**
  81403. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81404. * 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, ...)
  81405. */
  81406. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81407. private _onMeshLoadedObserver;
  81408. /**
  81409. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81410. * 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, ...)
  81411. */
  81412. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81413. /**
  81414. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81415. */
  81416. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81417. private _onTextureLoadedObserver;
  81418. /**
  81419. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81420. */
  81421. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81422. /**
  81423. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81424. */
  81425. readonly onMaterialLoadedObservable: Observable<Material>;
  81426. private _onMaterialLoadedObserver;
  81427. /**
  81428. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81429. */
  81430. set onMaterialLoaded(callback: (material: Material) => void);
  81431. /**
  81432. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81433. */
  81434. readonly onCameraLoadedObservable: Observable<Camera>;
  81435. private _onCameraLoadedObserver;
  81436. /**
  81437. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81438. */
  81439. set onCameraLoaded(callback: (camera: Camera) => void);
  81440. /**
  81441. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81442. * For assets with LODs, raised when all of the LODs are complete.
  81443. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81444. */
  81445. readonly onCompleteObservable: Observable<void>;
  81446. private _onCompleteObserver;
  81447. /**
  81448. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81449. * For assets with LODs, raised when all of the LODs are complete.
  81450. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81451. */
  81452. set onComplete(callback: () => void);
  81453. /**
  81454. * Observable raised when an error occurs.
  81455. */
  81456. readonly onErrorObservable: Observable<any>;
  81457. private _onErrorObserver;
  81458. /**
  81459. * Callback raised when an error occurs.
  81460. */
  81461. set onError(callback: (reason: any) => void);
  81462. /**
  81463. * Observable raised after the loader is disposed.
  81464. */
  81465. readonly onDisposeObservable: Observable<void>;
  81466. private _onDisposeObserver;
  81467. /**
  81468. * Callback raised after the loader is disposed.
  81469. */
  81470. set onDispose(callback: () => void);
  81471. /**
  81472. * Observable raised after a loader extension is created.
  81473. * Set additional options for a loader extension in this event.
  81474. */
  81475. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81476. private _onExtensionLoadedObserver;
  81477. /**
  81478. * Callback raised after a loader extension is created.
  81479. */
  81480. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81481. /**
  81482. * Defines if the loader logging is enabled.
  81483. */
  81484. get loggingEnabled(): boolean;
  81485. set loggingEnabled(value: boolean);
  81486. /**
  81487. * Defines if the loader should capture performance counters.
  81488. */
  81489. get capturePerformanceCounters(): boolean;
  81490. set capturePerformanceCounters(value: boolean);
  81491. /**
  81492. * Defines if the loader should validate the asset.
  81493. */
  81494. validate: boolean;
  81495. /**
  81496. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81497. */
  81498. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81499. private _onValidatedObserver;
  81500. /**
  81501. * Callback raised after a loader extension is created.
  81502. */
  81503. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81504. private _loader;
  81505. private _progressCallback?;
  81506. private _requests;
  81507. private static magicBase64Encoded;
  81508. /**
  81509. * Name of the loader ("gltf")
  81510. */
  81511. name: string;
  81512. /** @hidden */
  81513. extensions: ISceneLoaderPluginExtensions;
  81514. /**
  81515. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81516. */
  81517. dispose(): void;
  81518. /** @hidden */
  81519. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81520. /** @hidden */
  81521. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81522. /** @hidden */
  81523. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81524. meshes: AbstractMesh[];
  81525. particleSystems: IParticleSystem[];
  81526. skeletons: Skeleton[];
  81527. animationGroups: AnimationGroup[];
  81528. }>;
  81529. /** @hidden */
  81530. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81531. /** @hidden */
  81532. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81533. /** @hidden */
  81534. canDirectLoad(data: string): boolean;
  81535. /** @hidden */
  81536. directLoad(scene: Scene, data: string): Promise<any>;
  81537. /**
  81538. * The callback that allows custom handling of the root url based on the response url.
  81539. * @param rootUrl the original root url
  81540. * @param responseURL the response url if available
  81541. * @returns the new root url
  81542. */
  81543. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81544. /** @hidden */
  81545. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81546. /**
  81547. * The loader state or null if the loader is not active.
  81548. */
  81549. get loaderState(): Nullable<GLTFLoaderState>;
  81550. /**
  81551. * Returns a promise that resolves when the asset is completely loaded.
  81552. * @returns a promise that resolves when the asset is completely loaded.
  81553. */
  81554. whenCompleteAsync(): Promise<void>;
  81555. /** @hidden */
  81556. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81557. /** @hidden */
  81558. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81559. private _onProgress;
  81560. private _validate;
  81561. private _getLoader;
  81562. private _parseJson;
  81563. private _unpackBinaryAsync;
  81564. private _unpackBinaryV1Async;
  81565. private _unpackBinaryV2Async;
  81566. private static _parseVersion;
  81567. private static _compareVersion;
  81568. private static readonly _logSpaces;
  81569. private _logIndentLevel;
  81570. private _loggingEnabled;
  81571. /** @hidden */
  81572. _log: (message: string) => void;
  81573. /** @hidden */
  81574. _logOpen(message: string): void;
  81575. /** @hidden */
  81576. _logClose(): void;
  81577. private _logEnabled;
  81578. private _logDisabled;
  81579. private _capturePerformanceCounters;
  81580. /** @hidden */
  81581. _startPerformanceCounter: (counterName: string) => void;
  81582. /** @hidden */
  81583. _endPerformanceCounter: (counterName: string) => void;
  81584. private _startPerformanceCounterEnabled;
  81585. private _startPerformanceCounterDisabled;
  81586. private _endPerformanceCounterEnabled;
  81587. private _endPerformanceCounterDisabled;
  81588. }
  81589. }
  81590. declare module BABYLON.GLTF1 {
  81591. /**
  81592. * Enums
  81593. * @hidden
  81594. */
  81595. export enum EComponentType {
  81596. BYTE = 5120,
  81597. UNSIGNED_BYTE = 5121,
  81598. SHORT = 5122,
  81599. UNSIGNED_SHORT = 5123,
  81600. FLOAT = 5126
  81601. }
  81602. /** @hidden */
  81603. export enum EShaderType {
  81604. FRAGMENT = 35632,
  81605. VERTEX = 35633
  81606. }
  81607. /** @hidden */
  81608. export enum EParameterType {
  81609. BYTE = 5120,
  81610. UNSIGNED_BYTE = 5121,
  81611. SHORT = 5122,
  81612. UNSIGNED_SHORT = 5123,
  81613. INT = 5124,
  81614. UNSIGNED_INT = 5125,
  81615. FLOAT = 5126,
  81616. FLOAT_VEC2 = 35664,
  81617. FLOAT_VEC3 = 35665,
  81618. FLOAT_VEC4 = 35666,
  81619. INT_VEC2 = 35667,
  81620. INT_VEC3 = 35668,
  81621. INT_VEC4 = 35669,
  81622. BOOL = 35670,
  81623. BOOL_VEC2 = 35671,
  81624. BOOL_VEC3 = 35672,
  81625. BOOL_VEC4 = 35673,
  81626. FLOAT_MAT2 = 35674,
  81627. FLOAT_MAT3 = 35675,
  81628. FLOAT_MAT4 = 35676,
  81629. SAMPLER_2D = 35678
  81630. }
  81631. /** @hidden */
  81632. export enum ETextureWrapMode {
  81633. CLAMP_TO_EDGE = 33071,
  81634. MIRRORED_REPEAT = 33648,
  81635. REPEAT = 10497
  81636. }
  81637. /** @hidden */
  81638. export enum ETextureFilterType {
  81639. NEAREST = 9728,
  81640. LINEAR = 9728,
  81641. NEAREST_MIPMAP_NEAREST = 9984,
  81642. LINEAR_MIPMAP_NEAREST = 9985,
  81643. NEAREST_MIPMAP_LINEAR = 9986,
  81644. LINEAR_MIPMAP_LINEAR = 9987
  81645. }
  81646. /** @hidden */
  81647. export enum ETextureFormat {
  81648. ALPHA = 6406,
  81649. RGB = 6407,
  81650. RGBA = 6408,
  81651. LUMINANCE = 6409,
  81652. LUMINANCE_ALPHA = 6410
  81653. }
  81654. /** @hidden */
  81655. export enum ECullingType {
  81656. FRONT = 1028,
  81657. BACK = 1029,
  81658. FRONT_AND_BACK = 1032
  81659. }
  81660. /** @hidden */
  81661. export enum EBlendingFunction {
  81662. ZERO = 0,
  81663. ONE = 1,
  81664. SRC_COLOR = 768,
  81665. ONE_MINUS_SRC_COLOR = 769,
  81666. DST_COLOR = 774,
  81667. ONE_MINUS_DST_COLOR = 775,
  81668. SRC_ALPHA = 770,
  81669. ONE_MINUS_SRC_ALPHA = 771,
  81670. DST_ALPHA = 772,
  81671. ONE_MINUS_DST_ALPHA = 773,
  81672. CONSTANT_COLOR = 32769,
  81673. ONE_MINUS_CONSTANT_COLOR = 32770,
  81674. CONSTANT_ALPHA = 32771,
  81675. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81676. SRC_ALPHA_SATURATE = 776
  81677. }
  81678. /** @hidden */
  81679. export interface IGLTFProperty {
  81680. extensions?: {
  81681. [key: string]: any;
  81682. };
  81683. extras?: Object;
  81684. }
  81685. /** @hidden */
  81686. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81687. name?: string;
  81688. }
  81689. /** @hidden */
  81690. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81691. bufferView: string;
  81692. byteOffset: number;
  81693. byteStride: number;
  81694. count: number;
  81695. type: string;
  81696. componentType: EComponentType;
  81697. max?: number[];
  81698. min?: number[];
  81699. name?: string;
  81700. }
  81701. /** @hidden */
  81702. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81703. buffer: string;
  81704. byteOffset: number;
  81705. byteLength: number;
  81706. byteStride: number;
  81707. target?: number;
  81708. }
  81709. /** @hidden */
  81710. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81711. uri: string;
  81712. byteLength?: number;
  81713. type?: string;
  81714. }
  81715. /** @hidden */
  81716. export interface IGLTFShader extends IGLTFChildRootProperty {
  81717. uri: string;
  81718. type: EShaderType;
  81719. }
  81720. /** @hidden */
  81721. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81722. attributes: string[];
  81723. fragmentShader: string;
  81724. vertexShader: string;
  81725. }
  81726. /** @hidden */
  81727. export interface IGLTFTechniqueParameter {
  81728. type: number;
  81729. count?: number;
  81730. semantic?: string;
  81731. node?: string;
  81732. value?: number | boolean | string | Array<any>;
  81733. source?: string;
  81734. babylonValue?: any;
  81735. }
  81736. /** @hidden */
  81737. export interface IGLTFTechniqueCommonProfile {
  81738. lightingModel: string;
  81739. texcoordBindings: Object;
  81740. parameters?: Array<any>;
  81741. }
  81742. /** @hidden */
  81743. export interface IGLTFTechniqueStatesFunctions {
  81744. blendColor?: number[];
  81745. blendEquationSeparate?: number[];
  81746. blendFuncSeparate?: number[];
  81747. colorMask: boolean[];
  81748. cullFace: number[];
  81749. }
  81750. /** @hidden */
  81751. export interface IGLTFTechniqueStates {
  81752. enable: number[];
  81753. functions: IGLTFTechniqueStatesFunctions;
  81754. }
  81755. /** @hidden */
  81756. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81757. parameters: {
  81758. [key: string]: IGLTFTechniqueParameter;
  81759. };
  81760. program: string;
  81761. attributes: {
  81762. [key: string]: string;
  81763. };
  81764. uniforms: {
  81765. [key: string]: string;
  81766. };
  81767. states: IGLTFTechniqueStates;
  81768. }
  81769. /** @hidden */
  81770. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81771. technique?: string;
  81772. values: string[];
  81773. }
  81774. /** @hidden */
  81775. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81776. attributes: {
  81777. [key: string]: string;
  81778. };
  81779. indices: string;
  81780. material: string;
  81781. mode?: number;
  81782. }
  81783. /** @hidden */
  81784. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81785. primitives: IGLTFMeshPrimitive[];
  81786. }
  81787. /** @hidden */
  81788. export interface IGLTFImage extends IGLTFChildRootProperty {
  81789. uri: string;
  81790. }
  81791. /** @hidden */
  81792. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81793. magFilter?: number;
  81794. minFilter?: number;
  81795. wrapS?: number;
  81796. wrapT?: number;
  81797. }
  81798. /** @hidden */
  81799. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81800. sampler: string;
  81801. source: string;
  81802. format?: ETextureFormat;
  81803. internalFormat?: ETextureFormat;
  81804. target?: number;
  81805. type?: number;
  81806. babylonTexture?: Texture;
  81807. }
  81808. /** @hidden */
  81809. export interface IGLTFAmbienLight {
  81810. color?: number[];
  81811. }
  81812. /** @hidden */
  81813. export interface IGLTFDirectionalLight {
  81814. color?: number[];
  81815. }
  81816. /** @hidden */
  81817. export interface IGLTFPointLight {
  81818. color?: number[];
  81819. constantAttenuation?: number;
  81820. linearAttenuation?: number;
  81821. quadraticAttenuation?: number;
  81822. }
  81823. /** @hidden */
  81824. export interface IGLTFSpotLight {
  81825. color?: number[];
  81826. constantAttenuation?: number;
  81827. fallOfAngle?: number;
  81828. fallOffExponent?: number;
  81829. linearAttenuation?: number;
  81830. quadraticAttenuation?: number;
  81831. }
  81832. /** @hidden */
  81833. export interface IGLTFLight extends IGLTFChildRootProperty {
  81834. type: string;
  81835. }
  81836. /** @hidden */
  81837. export interface IGLTFCameraOrthographic {
  81838. xmag: number;
  81839. ymag: number;
  81840. zfar: number;
  81841. znear: number;
  81842. }
  81843. /** @hidden */
  81844. export interface IGLTFCameraPerspective {
  81845. aspectRatio: number;
  81846. yfov: number;
  81847. zfar: number;
  81848. znear: number;
  81849. }
  81850. /** @hidden */
  81851. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81852. type: string;
  81853. }
  81854. /** @hidden */
  81855. export interface IGLTFAnimationChannelTarget {
  81856. id: string;
  81857. path: string;
  81858. }
  81859. /** @hidden */
  81860. export interface IGLTFAnimationChannel {
  81861. sampler: string;
  81862. target: IGLTFAnimationChannelTarget;
  81863. }
  81864. /** @hidden */
  81865. export interface IGLTFAnimationSampler {
  81866. input: string;
  81867. output: string;
  81868. interpolation?: string;
  81869. }
  81870. /** @hidden */
  81871. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81872. channels?: IGLTFAnimationChannel[];
  81873. parameters?: {
  81874. [key: string]: string;
  81875. };
  81876. samplers?: {
  81877. [key: string]: IGLTFAnimationSampler;
  81878. };
  81879. }
  81880. /** @hidden */
  81881. export interface IGLTFNodeInstanceSkin {
  81882. skeletons: string[];
  81883. skin: string;
  81884. meshes: string[];
  81885. }
  81886. /** @hidden */
  81887. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81888. bindShapeMatrix: number[];
  81889. inverseBindMatrices: string;
  81890. jointNames: string[];
  81891. babylonSkeleton?: Skeleton;
  81892. }
  81893. /** @hidden */
  81894. export interface IGLTFNode extends IGLTFChildRootProperty {
  81895. camera?: string;
  81896. children: string[];
  81897. skin?: string;
  81898. jointName?: string;
  81899. light?: string;
  81900. matrix: number[];
  81901. mesh?: string;
  81902. meshes?: string[];
  81903. rotation?: number[];
  81904. scale?: number[];
  81905. translation?: number[];
  81906. babylonNode?: Node;
  81907. }
  81908. /** @hidden */
  81909. export interface IGLTFScene extends IGLTFChildRootProperty {
  81910. nodes: string[];
  81911. }
  81912. /** @hidden */
  81913. export interface IGLTFRuntime {
  81914. extensions: {
  81915. [key: string]: any;
  81916. };
  81917. accessors: {
  81918. [key: string]: IGLTFAccessor;
  81919. };
  81920. buffers: {
  81921. [key: string]: IGLTFBuffer;
  81922. };
  81923. bufferViews: {
  81924. [key: string]: IGLTFBufferView;
  81925. };
  81926. meshes: {
  81927. [key: string]: IGLTFMesh;
  81928. };
  81929. lights: {
  81930. [key: string]: IGLTFLight;
  81931. };
  81932. cameras: {
  81933. [key: string]: IGLTFCamera;
  81934. };
  81935. nodes: {
  81936. [key: string]: IGLTFNode;
  81937. };
  81938. images: {
  81939. [key: string]: IGLTFImage;
  81940. };
  81941. textures: {
  81942. [key: string]: IGLTFTexture;
  81943. };
  81944. shaders: {
  81945. [key: string]: IGLTFShader;
  81946. };
  81947. programs: {
  81948. [key: string]: IGLTFProgram;
  81949. };
  81950. samplers: {
  81951. [key: string]: IGLTFSampler;
  81952. };
  81953. techniques: {
  81954. [key: string]: IGLTFTechnique;
  81955. };
  81956. materials: {
  81957. [key: string]: IGLTFMaterial;
  81958. };
  81959. animations: {
  81960. [key: string]: IGLTFAnimation;
  81961. };
  81962. skins: {
  81963. [key: string]: IGLTFSkins;
  81964. };
  81965. currentScene?: Object;
  81966. scenes: {
  81967. [key: string]: IGLTFScene;
  81968. };
  81969. extensionsUsed: string[];
  81970. extensionsRequired?: string[];
  81971. buffersCount: number;
  81972. shaderscount: number;
  81973. scene: Scene;
  81974. rootUrl: string;
  81975. loadedBufferCount: number;
  81976. loadedBufferViews: {
  81977. [name: string]: ArrayBufferView;
  81978. };
  81979. loadedShaderCount: number;
  81980. importOnlyMeshes: boolean;
  81981. importMeshesNames?: string[];
  81982. dummyNodes: Node[];
  81983. forAssetContainer: boolean;
  81984. }
  81985. /** @hidden */
  81986. export interface INodeToRoot {
  81987. bone: Bone;
  81988. node: IGLTFNode;
  81989. id: string;
  81990. }
  81991. /** @hidden */
  81992. export interface IJointNode {
  81993. node: IGLTFNode;
  81994. id: string;
  81995. }
  81996. }
  81997. declare module BABYLON.GLTF1 {
  81998. /**
  81999. * Utils functions for GLTF
  82000. * @hidden
  82001. */
  82002. export class GLTFUtils {
  82003. /**
  82004. * Sets the given "parameter" matrix
  82005. * @param scene: the Scene object
  82006. * @param source: the source node where to pick the matrix
  82007. * @param parameter: the GLTF technique parameter
  82008. * @param uniformName: the name of the shader's uniform
  82009. * @param shaderMaterial: the shader material
  82010. */
  82011. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82012. /**
  82013. * Sets the given "parameter" matrix
  82014. * @param shaderMaterial: the shader material
  82015. * @param uniform: the name of the shader's uniform
  82016. * @param value: the value of the uniform
  82017. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82018. */
  82019. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82020. /**
  82021. * Returns the wrap mode of the texture
  82022. * @param mode: the mode value
  82023. */
  82024. static GetWrapMode(mode: number): number;
  82025. /**
  82026. * Returns the byte stride giving an accessor
  82027. * @param accessor: the GLTF accessor objet
  82028. */
  82029. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82030. /**
  82031. * Returns the texture filter mode giving a mode value
  82032. * @param mode: the filter mode value
  82033. */
  82034. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82035. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82036. /**
  82037. * Returns a buffer from its accessor
  82038. * @param gltfRuntime: the GLTF runtime
  82039. * @param accessor: the GLTF accessor
  82040. */
  82041. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82042. /**
  82043. * Decodes a buffer view into a string
  82044. * @param view: the buffer view
  82045. */
  82046. static DecodeBufferToText(view: ArrayBufferView): string;
  82047. /**
  82048. * Returns the default material of gltf. Related to
  82049. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82050. * @param scene: the Babylon.js scene
  82051. */
  82052. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82053. private static _DefaultMaterial;
  82054. }
  82055. }
  82056. declare module BABYLON.GLTF1 {
  82057. /**
  82058. * Implementation of the base glTF spec
  82059. * @hidden
  82060. */
  82061. export class GLTFLoaderBase {
  82062. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82063. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82064. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82065. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82066. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82067. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82068. }
  82069. /**
  82070. * glTF V1 Loader
  82071. * @hidden
  82072. */
  82073. export class GLTFLoader implements IGLTFLoader {
  82074. static Extensions: {
  82075. [name: string]: GLTFLoaderExtension;
  82076. };
  82077. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82078. state: Nullable<GLTFLoaderState>;
  82079. dispose(): void;
  82080. private _importMeshAsync;
  82081. /**
  82082. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82083. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82084. * @param scene the scene the meshes should be added to
  82085. * @param forAssetContainer defines if the entities must be stored in the scene
  82086. * @param data gltf data containing information of the meshes in a loaded file
  82087. * @param rootUrl root url to load from
  82088. * @param onProgress event that fires when loading progress has occured
  82089. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82090. */
  82091. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82092. private _loadAsync;
  82093. /**
  82094. * Imports all objects from a loaded gltf file and adds them to the scene
  82095. * @param scene the scene the objects should be added to
  82096. * @param data gltf data containing information of the meshes in a loaded file
  82097. * @param rootUrl root url to load from
  82098. * @param onProgress event that fires when loading progress has occured
  82099. * @returns a promise which completes when objects have been loaded to the scene
  82100. */
  82101. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82102. private _loadShadersAsync;
  82103. private _loadBuffersAsync;
  82104. private _createNodes;
  82105. }
  82106. /** @hidden */
  82107. export abstract class GLTFLoaderExtension {
  82108. private _name;
  82109. constructor(name: string);
  82110. get name(): string;
  82111. /**
  82112. * Defines an override for loading the runtime
  82113. * Return true to stop further extensions from loading the runtime
  82114. */
  82115. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82116. /**
  82117. * Defines an onverride for creating gltf runtime
  82118. * Return true to stop further extensions from creating the runtime
  82119. */
  82120. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82121. /**
  82122. * Defines an override for loading buffers
  82123. * Return true to stop further extensions from loading this buffer
  82124. */
  82125. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82126. /**
  82127. * Defines an override for loading texture buffers
  82128. * Return true to stop further extensions from loading this texture data
  82129. */
  82130. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82131. /**
  82132. * Defines an override for creating textures
  82133. * Return true to stop further extensions from loading this texture
  82134. */
  82135. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82136. /**
  82137. * Defines an override for loading shader strings
  82138. * Return true to stop further extensions from loading this shader data
  82139. */
  82140. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82141. /**
  82142. * Defines an override for loading materials
  82143. * Return true to stop further extensions from loading this material
  82144. */
  82145. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82146. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82147. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82148. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82149. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82150. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82151. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82152. private static LoadTextureBufferAsync;
  82153. private static CreateTextureAsync;
  82154. private static ApplyExtensions;
  82155. }
  82156. }
  82157. declare module BABYLON.GLTF1 {
  82158. /** @hidden */
  82159. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82160. private _bin;
  82161. constructor();
  82162. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82163. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82164. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82165. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82166. }
  82167. }
  82168. declare module BABYLON.GLTF1 {
  82169. /** @hidden */
  82170. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82171. constructor();
  82172. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82173. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82174. private _loadTexture;
  82175. }
  82176. }
  82177. declare module BABYLON.GLTF2.Loader {
  82178. /**
  82179. * Loader interface with an index field.
  82180. */
  82181. export interface IArrayItem {
  82182. /**
  82183. * The index of this item in the array.
  82184. */
  82185. index: number;
  82186. }
  82187. /**
  82188. * Loader interface with additional members.
  82189. */
  82190. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82191. /** @hidden */
  82192. _data?: Promise<ArrayBufferView>;
  82193. /** @hidden */
  82194. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82195. }
  82196. /**
  82197. * Loader interface with additional members.
  82198. */
  82199. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82200. }
  82201. /** @hidden */
  82202. export interface _IAnimationSamplerData {
  82203. input: Float32Array;
  82204. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82205. output: Float32Array;
  82206. }
  82207. /**
  82208. * Loader interface with additional members.
  82209. */
  82210. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82211. /** @hidden */
  82212. _data?: Promise<_IAnimationSamplerData>;
  82213. }
  82214. /**
  82215. * Loader interface with additional members.
  82216. */
  82217. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82218. channels: IAnimationChannel[];
  82219. samplers: IAnimationSampler[];
  82220. /** @hidden */
  82221. _babylonAnimationGroup?: AnimationGroup;
  82222. }
  82223. /**
  82224. * Loader interface with additional members.
  82225. */
  82226. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82227. /** @hidden */
  82228. _data?: Promise<ArrayBufferView>;
  82229. }
  82230. /**
  82231. * Loader interface with additional members.
  82232. */
  82233. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82234. /** @hidden */
  82235. _data?: Promise<ArrayBufferView>;
  82236. /** @hidden */
  82237. _babylonBuffer?: Promise<Buffer>;
  82238. }
  82239. /**
  82240. * Loader interface with additional members.
  82241. */
  82242. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82243. }
  82244. /**
  82245. * Loader interface with additional members.
  82246. */
  82247. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82248. /** @hidden */
  82249. _data?: Promise<ArrayBufferView>;
  82250. }
  82251. /**
  82252. * Loader interface with additional members.
  82253. */
  82254. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82255. }
  82256. /**
  82257. * Loader interface with additional members.
  82258. */
  82259. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82260. }
  82261. /**
  82262. * Loader interface with additional members.
  82263. */
  82264. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82265. baseColorTexture?: ITextureInfo;
  82266. metallicRoughnessTexture?: ITextureInfo;
  82267. }
  82268. /**
  82269. * Loader interface with additional members.
  82270. */
  82271. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82272. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82273. normalTexture?: IMaterialNormalTextureInfo;
  82274. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82275. emissiveTexture?: ITextureInfo;
  82276. /** @hidden */
  82277. _data?: {
  82278. [babylonDrawMode: number]: {
  82279. babylonMaterial: Material;
  82280. babylonMeshes: AbstractMesh[];
  82281. promise: Promise<void>;
  82282. };
  82283. };
  82284. }
  82285. /**
  82286. * Loader interface with additional members.
  82287. */
  82288. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82289. primitives: IMeshPrimitive[];
  82290. }
  82291. /**
  82292. * Loader interface with additional members.
  82293. */
  82294. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82295. /** @hidden */
  82296. _instanceData?: {
  82297. babylonSourceMesh: Mesh;
  82298. promise: Promise<any>;
  82299. };
  82300. }
  82301. /**
  82302. * Loader interface with additional members.
  82303. */
  82304. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82305. /**
  82306. * The parent glTF node.
  82307. */
  82308. parent?: INode;
  82309. /** @hidden */
  82310. _babylonTransformNode?: TransformNode;
  82311. /** @hidden */
  82312. _primitiveBabylonMeshes?: AbstractMesh[];
  82313. /** @hidden */
  82314. _babylonBones?: Bone[];
  82315. /** @hidden */
  82316. _numMorphTargets?: number;
  82317. }
  82318. /** @hidden */
  82319. export interface _ISamplerData {
  82320. noMipMaps: boolean;
  82321. samplingMode: number;
  82322. wrapU: number;
  82323. wrapV: number;
  82324. }
  82325. /**
  82326. * Loader interface with additional members.
  82327. */
  82328. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82329. /** @hidden */
  82330. _data?: _ISamplerData;
  82331. }
  82332. /**
  82333. * Loader interface with additional members.
  82334. */
  82335. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82336. }
  82337. /**
  82338. * Loader interface with additional members.
  82339. */
  82340. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82341. /** @hidden */
  82342. _data?: {
  82343. babylonSkeleton: Skeleton;
  82344. promise: Promise<void>;
  82345. };
  82346. }
  82347. /**
  82348. * Loader interface with additional members.
  82349. */
  82350. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82351. }
  82352. /**
  82353. * Loader interface with additional members.
  82354. */
  82355. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82356. }
  82357. /**
  82358. * Loader interface with additional members.
  82359. */
  82360. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82361. accessors?: IAccessor[];
  82362. animations?: IAnimation[];
  82363. buffers?: IBuffer[];
  82364. bufferViews?: IBufferView[];
  82365. cameras?: ICamera[];
  82366. images?: IImage[];
  82367. materials?: IMaterial[];
  82368. meshes?: IMesh[];
  82369. nodes?: INode[];
  82370. samplers?: ISampler[];
  82371. scenes?: IScene[];
  82372. skins?: ISkin[];
  82373. textures?: ITexture[];
  82374. }
  82375. }
  82376. declare module BABYLON.GLTF2 {
  82377. /**
  82378. * Interface for a glTF loader extension.
  82379. */
  82380. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82381. /**
  82382. * Called after the loader state changes to LOADING.
  82383. */
  82384. onLoading?(): void;
  82385. /**
  82386. * Called after the loader state changes to READY.
  82387. */
  82388. onReady?(): void;
  82389. /**
  82390. * Define this method to modify the default behavior when loading scenes.
  82391. * @param context The context when loading the asset
  82392. * @param scene The glTF scene property
  82393. * @returns A promise that resolves when the load is complete or null if not handled
  82394. */
  82395. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82396. /**
  82397. * Define this method to modify the default behavior when loading nodes.
  82398. * @param context The context when loading the asset
  82399. * @param node The glTF node property
  82400. * @param assign A function called synchronously after parsing the glTF properties
  82401. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82402. */
  82403. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82404. /**
  82405. * Define this method to modify the default behavior when loading cameras.
  82406. * @param context The context when loading the asset
  82407. * @param camera The glTF camera property
  82408. * @param assign A function called synchronously after parsing the glTF properties
  82409. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82410. */
  82411. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82412. /**
  82413. * @hidden
  82414. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82415. * @param context The context when loading the asset
  82416. * @param primitive The glTF mesh primitive property
  82417. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82418. */
  82419. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82420. /**
  82421. * @hidden
  82422. * Define this method to modify the default behavior when loading data for mesh primitives.
  82423. * @param context The context when loading the asset
  82424. * @param name The mesh name when loading the asset
  82425. * @param node The glTF node when loading the asset
  82426. * @param mesh The glTF mesh when loading the asset
  82427. * @param primitive The glTF mesh primitive property
  82428. * @param assign A function called synchronously after parsing the glTF properties
  82429. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82430. */
  82431. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82432. /**
  82433. * @hidden
  82434. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82435. * @param context The context when loading the asset
  82436. * @param material The glTF material property
  82437. * @param assign A function called synchronously after parsing the glTF properties
  82438. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82439. */
  82440. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82441. /**
  82442. * Define this method to modify the default behavior when creating materials.
  82443. * @param context The context when loading the asset
  82444. * @param material The glTF material property
  82445. * @param babylonDrawMode The draw mode for the Babylon material
  82446. * @returns The Babylon material or null if not handled
  82447. */
  82448. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82449. /**
  82450. * Define this method to modify the default behavior when loading material properties.
  82451. * @param context The context when loading the asset
  82452. * @param material The glTF material property
  82453. * @param babylonMaterial The Babylon material
  82454. * @returns A promise that resolves when the load is complete or null if not handled
  82455. */
  82456. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82457. /**
  82458. * Define this method to modify the default behavior when loading texture infos.
  82459. * @param context The context when loading the asset
  82460. * @param textureInfo The glTF texture info property
  82461. * @param assign A function called synchronously after parsing the glTF properties
  82462. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82463. */
  82464. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82465. /**
  82466. * @hidden
  82467. * Define this method to modify the default behavior when loading textures.
  82468. * @param context The context when loading the asset
  82469. * @param texture The glTF texture property
  82470. * @param assign A function called synchronously after parsing the glTF properties
  82471. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82472. */
  82473. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82474. /**
  82475. * Define this method to modify the default behavior when loading animations.
  82476. * @param context The context when loading the asset
  82477. * @param animation The glTF animation property
  82478. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82479. */
  82480. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82481. /**
  82482. * @hidden
  82483. * Define this method to modify the default behavior when loading skins.
  82484. * @param context The context when loading the asset
  82485. * @param node The glTF node property
  82486. * @param skin The glTF skin property
  82487. * @returns A promise that resolves when the load is complete or null if not handled
  82488. */
  82489. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82490. /**
  82491. * @hidden
  82492. * Define this method to modify the default behavior when loading uris.
  82493. * @param context The context when loading the asset
  82494. * @param property The glTF property associated with the uri
  82495. * @param uri The uri to load
  82496. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82497. */
  82498. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82499. /**
  82500. * Define this method to modify the default behavior when loading buffer views.
  82501. * @param context The context when loading the asset
  82502. * @param bufferView The glTF buffer view property
  82503. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82504. */
  82505. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82506. /**
  82507. * Define this method to modify the default behavior when loading buffers.
  82508. * @param context The context when loading the asset
  82509. * @param buffer The glTF buffer property
  82510. * @param byteOffset The byte offset to load
  82511. * @param byteLength The byte length to load
  82512. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82513. */
  82514. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82515. }
  82516. }
  82517. declare module BABYLON.GLTF2 {
  82518. /**
  82519. * Helper class for working with arrays when loading the glTF asset
  82520. */
  82521. export class ArrayItem {
  82522. /**
  82523. * Gets an item from the given array.
  82524. * @param context The context when loading the asset
  82525. * @param array The array to get the item from
  82526. * @param index The index to the array
  82527. * @returns The array item
  82528. */
  82529. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82530. /**
  82531. * Assign an `index` field to each item of the given array.
  82532. * @param array The array of items
  82533. */
  82534. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82535. }
  82536. /**
  82537. * The glTF 2.0 loader
  82538. */
  82539. export class GLTFLoader implements IGLTFLoader {
  82540. /** @hidden */
  82541. _completePromises: Promise<any>[];
  82542. /** @hidden */
  82543. _forAssetContainer: boolean;
  82544. /** Storage */
  82545. _babylonLights: Light[];
  82546. /** @hidden */
  82547. _disableInstancedMesh: number;
  82548. private _disposed;
  82549. private _parent;
  82550. private _state;
  82551. private _extensions;
  82552. private _rootUrl;
  82553. private _fileName;
  82554. private _uniqueRootUrl;
  82555. private _gltf;
  82556. private _bin;
  82557. private _babylonScene;
  82558. private _rootBabylonMesh;
  82559. private _defaultBabylonMaterialData;
  82560. private static _RegisteredExtensions;
  82561. /**
  82562. * The default glTF sampler.
  82563. */
  82564. static readonly DefaultSampler: ISampler;
  82565. /**
  82566. * Registers a loader extension.
  82567. * @param name The name of the loader extension.
  82568. * @param factory The factory function that creates the loader extension.
  82569. */
  82570. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82571. /**
  82572. * Unregisters a loader extension.
  82573. * @param name The name of the loader extension.
  82574. * @returns A boolean indicating whether the extension has been unregistered
  82575. */
  82576. static UnregisterExtension(name: string): boolean;
  82577. /**
  82578. * The loader state.
  82579. */
  82580. get state(): Nullable<GLTFLoaderState>;
  82581. /**
  82582. * The object that represents the glTF JSON.
  82583. */
  82584. get gltf(): IGLTF;
  82585. /**
  82586. * The BIN chunk of a binary glTF.
  82587. */
  82588. get bin(): Nullable<IDataBuffer>;
  82589. /**
  82590. * The parent file loader.
  82591. */
  82592. get parent(): GLTFFileLoader;
  82593. /**
  82594. * The Babylon scene when loading the asset.
  82595. */
  82596. get babylonScene(): Scene;
  82597. /**
  82598. * The root Babylon mesh when loading the asset.
  82599. */
  82600. get rootBabylonMesh(): Mesh;
  82601. /** @hidden */
  82602. constructor(parent: GLTFFileLoader);
  82603. /** @hidden */
  82604. dispose(): void;
  82605. /** @hidden */
  82606. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82607. /** @hidden */
  82608. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82609. private _loadAsync;
  82610. private _loadData;
  82611. private _setupData;
  82612. private _loadExtensions;
  82613. private _checkExtensions;
  82614. private _setState;
  82615. private _createRootNode;
  82616. /**
  82617. * Loads a glTF scene.
  82618. * @param context The context when loading the asset
  82619. * @param scene The glTF scene property
  82620. * @returns A promise that resolves when the load is complete
  82621. */
  82622. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82623. private _forEachPrimitive;
  82624. private _getMeshes;
  82625. private _getTransformNodes;
  82626. private _getSkeletons;
  82627. private _getAnimationGroups;
  82628. private _startAnimations;
  82629. /**
  82630. * Loads a glTF node.
  82631. * @param context The context when loading the asset
  82632. * @param node The glTF node property
  82633. * @param assign A function called synchronously after parsing the glTF properties
  82634. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82635. */
  82636. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82637. private _loadMeshAsync;
  82638. /**
  82639. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82640. * @param context The context when loading the asset
  82641. * @param name The mesh name when loading the asset
  82642. * @param node The glTF node when loading the asset
  82643. * @param mesh The glTF mesh when loading the asset
  82644. * @param primitive The glTF mesh primitive property
  82645. * @param assign A function called synchronously after parsing the glTF properties
  82646. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82647. */
  82648. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82649. private _loadVertexDataAsync;
  82650. private _createMorphTargets;
  82651. private _loadMorphTargetsAsync;
  82652. private _loadMorphTargetVertexDataAsync;
  82653. private static _LoadTransform;
  82654. private _loadSkinAsync;
  82655. private _loadBones;
  82656. private _loadBone;
  82657. private _loadSkinInverseBindMatricesDataAsync;
  82658. private _updateBoneMatrices;
  82659. private _getNodeMatrix;
  82660. /**
  82661. * Loads a glTF camera.
  82662. * @param context The context when loading the asset
  82663. * @param camera The glTF camera property
  82664. * @param assign A function called synchronously after parsing the glTF properties
  82665. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82666. */
  82667. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82668. private _loadAnimationsAsync;
  82669. /**
  82670. * Loads a glTF animation.
  82671. * @param context The context when loading the asset
  82672. * @param animation The glTF animation property
  82673. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82674. */
  82675. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82676. /**
  82677. * @hidden Loads a glTF animation channel.
  82678. * @param context The context when loading the asset
  82679. * @param animationContext The context of the animation when loading the asset
  82680. * @param animation The glTF animation property
  82681. * @param channel The glTF animation channel property
  82682. * @param babylonAnimationGroup The babylon animation group property
  82683. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82684. * @returns A void promise when the channel load is complete
  82685. */
  82686. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82687. private _loadAnimationSamplerAsync;
  82688. private _loadBufferAsync;
  82689. /**
  82690. * Loads a glTF buffer view.
  82691. * @param context The context when loading the asset
  82692. * @param bufferView The glTF buffer view property
  82693. * @returns A promise that resolves with the loaded data when the load is complete
  82694. */
  82695. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82696. private _loadAccessorAsync;
  82697. /** @hidden */
  82698. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82699. private _loadIndicesAccessorAsync;
  82700. private _loadVertexBufferViewAsync;
  82701. private _loadVertexAccessorAsync;
  82702. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82703. /** @hidden */
  82704. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82705. private _createDefaultMaterial;
  82706. /**
  82707. * Creates a Babylon material from a glTF material.
  82708. * @param context The context when loading the asset
  82709. * @param material The glTF material property
  82710. * @param babylonDrawMode The draw mode for the Babylon material
  82711. * @returns The Babylon material
  82712. */
  82713. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82714. /**
  82715. * Loads properties from a glTF material into a Babylon material.
  82716. * @param context The context when loading the asset
  82717. * @param material The glTF material property
  82718. * @param babylonMaterial The Babylon material
  82719. * @returns A promise that resolves when the load is complete
  82720. */
  82721. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82722. /**
  82723. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82724. * @param context The context when loading the asset
  82725. * @param material The glTF material property
  82726. * @param babylonMaterial The Babylon material
  82727. * @returns A promise that resolves when the load is complete
  82728. */
  82729. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82730. /**
  82731. * Loads the alpha properties from a glTF material into a Babylon material.
  82732. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82733. * @param context The context when loading the asset
  82734. * @param material The glTF material property
  82735. * @param babylonMaterial The Babylon material
  82736. */
  82737. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82738. /**
  82739. * Loads a glTF texture info.
  82740. * @param context The context when loading the asset
  82741. * @param textureInfo The glTF texture info property
  82742. * @param assign A function called synchronously after parsing the glTF properties
  82743. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82744. */
  82745. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82746. /** @hidden */
  82747. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82748. /** @hidden */
  82749. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82750. private _loadSampler;
  82751. /**
  82752. * Loads a glTF image.
  82753. * @param context The context when loading the asset
  82754. * @param image The glTF image property
  82755. * @returns A promise that resolves with the loaded data when the load is complete
  82756. */
  82757. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82758. /**
  82759. * Loads a glTF uri.
  82760. * @param context The context when loading the asset
  82761. * @param property The glTF property associated with the uri
  82762. * @param uri The base64 or relative uri
  82763. * @returns A promise that resolves with the loaded data when the load is complete
  82764. */
  82765. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82766. /**
  82767. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82768. * @param babylonObject the Babylon object with metadata
  82769. * @param pointer the JSON pointer
  82770. */
  82771. static AddPointerMetadata(babylonObject: {
  82772. metadata: any;
  82773. }, pointer: string): void;
  82774. private static _GetTextureWrapMode;
  82775. private static _GetTextureSamplingMode;
  82776. private static _GetTypedArrayConstructor;
  82777. private static _GetTypedArray;
  82778. private static _GetNumComponents;
  82779. private static _ValidateUri;
  82780. /** @hidden */
  82781. static _GetDrawMode(context: string, mode: number | undefined): number;
  82782. private _compileMaterialsAsync;
  82783. private _compileShadowGeneratorsAsync;
  82784. private _forEachExtensions;
  82785. private _applyExtensions;
  82786. private _extensionsOnLoading;
  82787. private _extensionsOnReady;
  82788. private _extensionsLoadSceneAsync;
  82789. private _extensionsLoadNodeAsync;
  82790. private _extensionsLoadCameraAsync;
  82791. private _extensionsLoadVertexDataAsync;
  82792. private _extensionsLoadMeshPrimitiveAsync;
  82793. private _extensionsLoadMaterialAsync;
  82794. private _extensionsCreateMaterial;
  82795. private _extensionsLoadMaterialPropertiesAsync;
  82796. private _extensionsLoadTextureInfoAsync;
  82797. private _extensionsLoadTextureAsync;
  82798. private _extensionsLoadAnimationAsync;
  82799. private _extensionsLoadSkinAsync;
  82800. private _extensionsLoadUriAsync;
  82801. private _extensionsLoadBufferViewAsync;
  82802. private _extensionsLoadBufferAsync;
  82803. /**
  82804. * Helper method called by a loader extension to load an glTF extension.
  82805. * @param context The context when loading the asset
  82806. * @param property The glTF property to load the extension from
  82807. * @param extensionName The name of the extension to load
  82808. * @param actionAsync The action to run
  82809. * @returns The promise returned by actionAsync or null if the extension does not exist
  82810. */
  82811. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82812. /**
  82813. * Helper method called by a loader extension to load a glTF extra.
  82814. * @param context The context when loading the asset
  82815. * @param property The glTF property to load the extra from
  82816. * @param extensionName The name of the extension to load
  82817. * @param actionAsync The action to run
  82818. * @returns The promise returned by actionAsync or null if the extra does not exist
  82819. */
  82820. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82821. /**
  82822. * Checks for presence of an extension.
  82823. * @param name The name of the extension to check
  82824. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82825. */
  82826. isExtensionUsed(name: string): boolean;
  82827. /**
  82828. * Increments the indentation level and logs a message.
  82829. * @param message The message to log
  82830. */
  82831. logOpen(message: string): void;
  82832. /**
  82833. * Decrements the indentation level.
  82834. */
  82835. logClose(): void;
  82836. /**
  82837. * Logs a message
  82838. * @param message The message to log
  82839. */
  82840. log(message: string): void;
  82841. /**
  82842. * Starts a performance counter.
  82843. * @param counterName The name of the performance counter
  82844. */
  82845. startPerformanceCounter(counterName: string): void;
  82846. /**
  82847. * Ends a performance counter.
  82848. * @param counterName The name of the performance counter
  82849. */
  82850. endPerformanceCounter(counterName: string): void;
  82851. }
  82852. }
  82853. declare module BABYLON.GLTF2.Loader.Extensions {
  82854. /** @hidden */
  82855. interface IEXTLightsImageBased_LightImageBased {
  82856. _babylonTexture?: BaseTexture;
  82857. _loaded?: Promise<void>;
  82858. }
  82859. /**
  82860. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82861. */
  82862. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82863. /**
  82864. * The name of this extension.
  82865. */
  82866. readonly name: string;
  82867. /**
  82868. * Defines whether this extension is enabled.
  82869. */
  82870. enabled: boolean;
  82871. private _loader;
  82872. private _lights?;
  82873. /** @hidden */
  82874. constructor(loader: GLTFLoader);
  82875. /** @hidden */
  82876. dispose(): void;
  82877. /** @hidden */
  82878. onLoading(): void;
  82879. /** @hidden */
  82880. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82881. private _loadLightAsync;
  82882. }
  82883. }
  82884. declare module BABYLON.GLTF2.Loader.Extensions {
  82885. /**
  82886. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82887. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82888. * !!! Experimental Extension Subject to Changes !!!
  82889. */
  82890. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82891. /**
  82892. * The name of this extension.
  82893. */
  82894. readonly name: string;
  82895. /**
  82896. * Defines whether this extension is enabled.
  82897. */
  82898. enabled: boolean;
  82899. private _loader;
  82900. /** @hidden */
  82901. constructor(loader: GLTFLoader);
  82902. /** @hidden */
  82903. dispose(): void;
  82904. /** @hidden */
  82905. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82906. }
  82907. }
  82908. declare module BABYLON.GLTF2.Loader.Extensions {
  82909. /**
  82910. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82911. */
  82912. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82913. /** The name of this extension. */
  82914. readonly name: string;
  82915. /** Defines whether this extension is enabled. */
  82916. enabled: boolean;
  82917. private _loader;
  82918. /** @hidden */
  82919. constructor(loader: GLTFLoader);
  82920. /** @hidden */
  82921. dispose(): void;
  82922. /** @hidden */
  82923. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82924. }
  82925. }
  82926. declare module BABYLON.GLTF2.Loader.Extensions {
  82927. /**
  82928. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82929. */
  82930. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82931. /**
  82932. * The name of this extension.
  82933. */
  82934. readonly name: string;
  82935. /**
  82936. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82937. */
  82938. dracoCompression?: DracoCompression;
  82939. /**
  82940. * Defines whether this extension is enabled.
  82941. */
  82942. enabled: boolean;
  82943. private _loader;
  82944. /** @hidden */
  82945. constructor(loader: GLTFLoader);
  82946. /** @hidden */
  82947. dispose(): void;
  82948. /** @hidden */
  82949. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82950. }
  82951. }
  82952. declare module BABYLON.GLTF2.Loader.Extensions {
  82953. /**
  82954. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82955. */
  82956. export class KHR_lights implements IGLTFLoaderExtension {
  82957. /**
  82958. * The name of this extension.
  82959. */
  82960. readonly name: string;
  82961. /**
  82962. * Defines whether this extension is enabled.
  82963. */
  82964. enabled: boolean;
  82965. private _loader;
  82966. private _lights?;
  82967. /** @hidden */
  82968. constructor(loader: GLTFLoader);
  82969. /** @hidden */
  82970. dispose(): void;
  82971. /** @hidden */
  82972. onLoading(): void;
  82973. /** @hidden */
  82974. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82975. }
  82976. }
  82977. declare module BABYLON.GLTF2.Loader.Extensions {
  82978. /**
  82979. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82980. */
  82981. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82982. /**
  82983. * The name of this extension.
  82984. */
  82985. readonly name: string;
  82986. /**
  82987. * Defines whether this extension is enabled.
  82988. */
  82989. enabled: boolean;
  82990. /**
  82991. * Defines a number that determines the order the extensions are applied.
  82992. */
  82993. order: number;
  82994. private _loader;
  82995. /** @hidden */
  82996. constructor(loader: GLTFLoader);
  82997. /** @hidden */
  82998. dispose(): void;
  82999. /** @hidden */
  83000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83001. private _loadSpecularGlossinessPropertiesAsync;
  83002. }
  83003. }
  83004. declare module BABYLON.GLTF2.Loader.Extensions {
  83005. /**
  83006. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83007. */
  83008. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83009. /**
  83010. * The name of this extension.
  83011. */
  83012. readonly name: string;
  83013. /**
  83014. * Defines whether this extension is enabled.
  83015. */
  83016. enabled: boolean;
  83017. /**
  83018. * Defines a number that determines the order the extensions are applied.
  83019. */
  83020. order: number;
  83021. private _loader;
  83022. /** @hidden */
  83023. constructor(loader: GLTFLoader);
  83024. /** @hidden */
  83025. dispose(): void;
  83026. /** @hidden */
  83027. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83028. private _loadUnlitPropertiesAsync;
  83029. }
  83030. }
  83031. declare module BABYLON.GLTF2.Loader.Extensions {
  83032. /**
  83033. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  83034. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83035. * !!! Experimental Extension Subject to Changes !!!
  83036. */
  83037. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83038. /**
  83039. * The name of this extension.
  83040. */
  83041. readonly name: string;
  83042. /**
  83043. * Defines whether this extension is enabled.
  83044. */
  83045. enabled: boolean;
  83046. /**
  83047. * Defines a number that determines the order the extensions are applied.
  83048. */
  83049. order: number;
  83050. private _loader;
  83051. /** @hidden */
  83052. constructor(loader: GLTFLoader);
  83053. /** @hidden */
  83054. dispose(): void;
  83055. /** @hidden */
  83056. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83057. private _loadClearCoatPropertiesAsync;
  83058. }
  83059. }
  83060. declare module BABYLON.GLTF2.Loader.Extensions {
  83061. /**
  83062. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83063. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83064. * !!! Experimental Extension Subject to Changes !!!
  83065. */
  83066. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83067. /**
  83068. * The name of this extension.
  83069. */
  83070. readonly name: string;
  83071. /**
  83072. * Defines whether this extension is enabled.
  83073. */
  83074. enabled: boolean;
  83075. /**
  83076. * Defines a number that determines the order the extensions are applied.
  83077. */
  83078. order: number;
  83079. private _loader;
  83080. /** @hidden */
  83081. constructor(loader: GLTFLoader);
  83082. /** @hidden */
  83083. dispose(): void;
  83084. /** @hidden */
  83085. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83086. private _loadSheenPropertiesAsync;
  83087. }
  83088. }
  83089. declare module BABYLON.GLTF2.Loader.Extensions {
  83090. /**
  83091. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83092. * !!! Experimental Extension Subject to Changes !!!
  83093. */
  83094. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83095. /**
  83096. * The name of this extension.
  83097. */
  83098. readonly name: string;
  83099. /**
  83100. * Defines whether this extension is enabled.
  83101. */
  83102. enabled: boolean;
  83103. /**
  83104. * Defines a number that determines the order the extensions are applied.
  83105. */
  83106. order: number;
  83107. private _loader;
  83108. /** @hidden */
  83109. constructor(loader: GLTFLoader);
  83110. /** @hidden */
  83111. dispose(): void;
  83112. /** @hidden */
  83113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83114. private _loadSpecularPropertiesAsync;
  83115. }
  83116. }
  83117. declare module BABYLON.GLTF2.Loader.Extensions {
  83118. /**
  83119. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83120. * !!! Experimental Extension Subject to Changes !!!
  83121. */
  83122. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83123. /**
  83124. * Default ior Value from the spec.
  83125. */
  83126. private static readonly _DEFAULT_IOR;
  83127. /**
  83128. * The name of this extension.
  83129. */
  83130. readonly name: string;
  83131. /**
  83132. * Defines whether this extension is enabled.
  83133. */
  83134. enabled: boolean;
  83135. /**
  83136. * Defines a number that determines the order the extensions are applied.
  83137. */
  83138. order: number;
  83139. private _loader;
  83140. /** @hidden */
  83141. constructor(loader: GLTFLoader);
  83142. /** @hidden */
  83143. dispose(): void;
  83144. /** @hidden */
  83145. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83146. private _loadIorPropertiesAsync;
  83147. }
  83148. }
  83149. declare module BABYLON.GLTF2.Loader.Extensions {
  83150. /**
  83151. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83152. * !!! Experimental Extension Subject to Changes !!!
  83153. */
  83154. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83155. /**
  83156. * The name of this extension.
  83157. */
  83158. readonly name: string;
  83159. /**
  83160. * Defines whether this extension is enabled.
  83161. */
  83162. enabled: boolean;
  83163. private _loader;
  83164. private _variants?;
  83165. /** @hidden */
  83166. constructor(loader: GLTFLoader);
  83167. /** @hidden */
  83168. dispose(): void;
  83169. /**
  83170. * Gets the list of available variant names for this asset.
  83171. * @param rootMesh The glTF root mesh
  83172. * @returns the list of all the variant names for this model
  83173. */
  83174. static GetAvailableVariants(rootMesh: Mesh): string[];
  83175. /**
  83176. * Gets the list of available variant names for this asset.
  83177. * @param rootMesh The glTF root mesh
  83178. * @returns the list of all the variant names for this model
  83179. */
  83180. getAvailableVariants(rootMesh: Mesh): string[];
  83181. /**
  83182. * Select a variant given a variant name or a list of variant names.
  83183. * @param rootMesh The glTF root mesh
  83184. * @param variantName The variant name(s) to select.
  83185. */
  83186. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83187. /**
  83188. * Select a variant given a variant name or a list of variant names.
  83189. * @param rootMesh The glTF root mesh
  83190. * @param variantName The variant name(s) to select.
  83191. */
  83192. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83193. /**
  83194. * Reset back to the original before selecting a variant.
  83195. * @param rootMesh The glTF root mesh
  83196. */
  83197. static Reset(rootMesh: Mesh): void;
  83198. /**
  83199. * Reset back to the original before selecting a variant.
  83200. * @param rootMesh The glTF root mesh
  83201. */
  83202. reset(rootMesh: Mesh): void;
  83203. /**
  83204. * Gets the last selected variant name(s) or null if original.
  83205. * @param rootMesh The glTF root mesh
  83206. * @returns The selected variant name(s).
  83207. */
  83208. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83209. /**
  83210. * Gets the last selected variant name(s) or null if original.
  83211. * @param rootMesh The glTF root mesh
  83212. * @returns The selected variant name(s).
  83213. */
  83214. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83215. private static _GetExtensionMetadata;
  83216. /** @hidden */
  83217. onLoading(): void;
  83218. /** @hidden */
  83219. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83220. }
  83221. }
  83222. declare module BABYLON.GLTF2.Loader.Extensions {
  83223. /**
  83224. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83225. * !!! Experimental Extension Subject to Changes !!!
  83226. */
  83227. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83228. /**
  83229. * The name of this extension.
  83230. */
  83231. readonly name: string;
  83232. /**
  83233. * Defines whether this extension is enabled.
  83234. */
  83235. enabled: boolean;
  83236. /**
  83237. * Defines a number that determines the order the extensions are applied.
  83238. */
  83239. order: number;
  83240. private _loader;
  83241. /** @hidden */
  83242. constructor(loader: GLTFLoader);
  83243. /** @hidden */
  83244. dispose(): void;
  83245. /** @hidden */
  83246. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83247. private _loadTransparentPropertiesAsync;
  83248. }
  83249. }
  83250. declare module BABYLON.GLTF2.Loader.Extensions {
  83251. /**
  83252. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83253. */
  83254. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83255. /**
  83256. * The name of this extension.
  83257. */
  83258. readonly name: string;
  83259. /**
  83260. * Defines whether this extension is enabled.
  83261. */
  83262. enabled: boolean;
  83263. /** @hidden */
  83264. constructor(loader: GLTFLoader);
  83265. /** @hidden */
  83266. dispose(): void;
  83267. }
  83268. }
  83269. declare module BABYLON.GLTF2.Loader.Extensions {
  83270. /**
  83271. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83272. * !!! Experimental Extension Subject to Changes !!!
  83273. */
  83274. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83275. /** The name of this extension. */
  83276. readonly name: string;
  83277. /** Defines whether this extension is enabled. */
  83278. enabled: boolean;
  83279. private _loader;
  83280. /** @hidden */
  83281. constructor(loader: GLTFLoader);
  83282. /** @hidden */
  83283. dispose(): void;
  83284. /** @hidden */
  83285. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83286. }
  83287. }
  83288. declare module BABYLON.GLTF2.Loader.Extensions {
  83289. /**
  83290. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83291. */
  83292. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83293. /**
  83294. * The name of this extension.
  83295. */
  83296. readonly name: string;
  83297. /**
  83298. * Defines whether this extension is enabled.
  83299. */
  83300. enabled: boolean;
  83301. private _loader;
  83302. /** @hidden */
  83303. constructor(loader: GLTFLoader);
  83304. /** @hidden */
  83305. dispose(): void;
  83306. /** @hidden */
  83307. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83308. }
  83309. }
  83310. declare module BABYLON.GLTF2.Loader.Extensions {
  83311. /**
  83312. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83313. * !!! Experimental Extension Subject to Changes !!!
  83314. */
  83315. export class KHR_xmp implements IGLTFLoaderExtension {
  83316. /**
  83317. * The name of this extension.
  83318. */
  83319. readonly name: string;
  83320. /**
  83321. * Defines whether this extension is enabled.
  83322. */
  83323. enabled: boolean;
  83324. /**
  83325. * Defines a number that determines the order the extensions are applied.
  83326. */
  83327. order: number;
  83328. private _loader;
  83329. /** @hidden */
  83330. constructor(loader: GLTFLoader);
  83331. /** @hidden */
  83332. dispose(): void;
  83333. /**
  83334. * Called after the loader state changes to LOADING.
  83335. */
  83336. onLoading(): void;
  83337. }
  83338. }
  83339. declare module BABYLON.GLTF2.Loader.Extensions {
  83340. /**
  83341. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83342. */
  83343. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83344. /**
  83345. * The name of this extension.
  83346. */
  83347. readonly name: string;
  83348. /**
  83349. * Defines whether this extension is enabled.
  83350. */
  83351. enabled: boolean;
  83352. private _loader;
  83353. private _clips;
  83354. private _emitters;
  83355. /** @hidden */
  83356. constructor(loader: GLTFLoader);
  83357. /** @hidden */
  83358. dispose(): void;
  83359. /** @hidden */
  83360. onLoading(): void;
  83361. /** @hidden */
  83362. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83363. /** @hidden */
  83364. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83365. /** @hidden */
  83366. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83367. private _loadClipAsync;
  83368. private _loadEmitterAsync;
  83369. private _getEventAction;
  83370. private _loadAnimationEventAsync;
  83371. }
  83372. }
  83373. declare module BABYLON.GLTF2.Loader.Extensions {
  83374. /**
  83375. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83376. */
  83377. export class MSFT_lod implements IGLTFLoaderExtension {
  83378. /**
  83379. * The name of this extension.
  83380. */
  83381. readonly name: string;
  83382. /**
  83383. * Defines whether this extension is enabled.
  83384. */
  83385. enabled: boolean;
  83386. /**
  83387. * Defines a number that determines the order the extensions are applied.
  83388. */
  83389. order: number;
  83390. /**
  83391. * Maximum number of LODs to load, starting from the lowest LOD.
  83392. */
  83393. maxLODsToLoad: number;
  83394. /**
  83395. * Observable raised when all node LODs of one level are loaded.
  83396. * The event data is the index of the loaded LOD starting from zero.
  83397. * Dispose the loader to cancel the loading of the next level of LODs.
  83398. */
  83399. onNodeLODsLoadedObservable: Observable<number>;
  83400. /**
  83401. * Observable raised when all material LODs of one level are loaded.
  83402. * The event data is the index of the loaded LOD starting from zero.
  83403. * Dispose the loader to cancel the loading of the next level of LODs.
  83404. */
  83405. onMaterialLODsLoadedObservable: Observable<number>;
  83406. private _loader;
  83407. private _bufferLODs;
  83408. private _nodeIndexLOD;
  83409. private _nodeSignalLODs;
  83410. private _nodePromiseLODs;
  83411. private _nodeBufferLODs;
  83412. private _materialIndexLOD;
  83413. private _materialSignalLODs;
  83414. private _materialPromiseLODs;
  83415. private _materialBufferLODs;
  83416. /** @hidden */
  83417. constructor(loader: GLTFLoader);
  83418. /** @hidden */
  83419. dispose(): void;
  83420. /** @hidden */
  83421. onReady(): void;
  83422. /** @hidden */
  83423. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83424. /** @hidden */
  83425. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83426. /** @hidden */
  83427. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83428. /** @hidden */
  83429. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83430. /** @hidden */
  83431. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83432. private _loadBufferLOD;
  83433. /**
  83434. * Gets an array of LOD properties from lowest to highest.
  83435. */
  83436. private _getLODs;
  83437. private _disposeTransformNode;
  83438. private _disposeMaterials;
  83439. }
  83440. }
  83441. declare module BABYLON.GLTF2.Loader.Extensions {
  83442. /** @hidden */
  83443. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83444. readonly name: string;
  83445. enabled: boolean;
  83446. private _loader;
  83447. constructor(loader: GLTFLoader);
  83448. dispose(): void;
  83449. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83450. }
  83451. }
  83452. declare module BABYLON.GLTF2.Loader.Extensions {
  83453. /** @hidden */
  83454. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83455. readonly name: string;
  83456. enabled: boolean;
  83457. private _loader;
  83458. constructor(loader: GLTFLoader);
  83459. dispose(): void;
  83460. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83461. }
  83462. }
  83463. declare module BABYLON.GLTF2.Loader.Extensions {
  83464. /**
  83465. * Store glTF extras (if present) in BJS objects' metadata
  83466. */
  83467. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83468. /**
  83469. * The name of this extension.
  83470. */
  83471. readonly name: string;
  83472. /**
  83473. * Defines whether this extension is enabled.
  83474. */
  83475. enabled: boolean;
  83476. private _loader;
  83477. private _assignExtras;
  83478. /** @hidden */
  83479. constructor(loader: GLTFLoader);
  83480. /** @hidden */
  83481. dispose(): void;
  83482. /** @hidden */
  83483. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83484. /** @hidden */
  83485. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83486. /** @hidden */
  83487. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83488. }
  83489. }
  83490. declare module BABYLON {
  83491. /**
  83492. * Class reading and parsing the MTL file bundled with the obj file.
  83493. */
  83494. export class MTLFileLoader {
  83495. /**
  83496. * Invert Y-Axis of referenced textures on load
  83497. */
  83498. static INVERT_TEXTURE_Y: boolean;
  83499. /**
  83500. * All material loaded from the mtl will be set here
  83501. */
  83502. materials: StandardMaterial[];
  83503. /**
  83504. * This function will read the mtl file and create each material described inside
  83505. * This function could be improve by adding :
  83506. * -some component missing (Ni, Tf...)
  83507. * -including the specific options available
  83508. *
  83509. * @param scene defines the scene the material will be created in
  83510. * @param data defines the mtl data to parse
  83511. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83512. * @param forAssetContainer defines if the material should be registered in the scene
  83513. */
  83514. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83515. /**
  83516. * Gets the texture for the material.
  83517. *
  83518. * If the material is imported from input file,
  83519. * We sanitize the url to ensure it takes the textre from aside the material.
  83520. *
  83521. * @param rootUrl The root url to load from
  83522. * @param value The value stored in the mtl
  83523. * @return The Texture
  83524. */
  83525. private static _getTexture;
  83526. }
  83527. }
  83528. declare module BABYLON {
  83529. /**
  83530. * Options for loading OBJ/MTL files
  83531. */
  83532. type MeshLoadOptions = {
  83533. /**
  83534. * Defines if UVs are optimized by default during load.
  83535. */
  83536. OptimizeWithUV: boolean;
  83537. /**
  83538. * Defines custom scaling of UV coordinates of loaded meshes.
  83539. */
  83540. UVScaling: Vector2;
  83541. /**
  83542. * Invert model on y-axis (does a model scaling inversion)
  83543. */
  83544. InvertY: boolean;
  83545. /**
  83546. * Invert Y-Axis of referenced textures on load
  83547. */
  83548. InvertTextureY: boolean;
  83549. /**
  83550. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83551. */
  83552. ImportVertexColors: boolean;
  83553. /**
  83554. * Compute the normals for the model, even if normals are present in the file.
  83555. */
  83556. ComputeNormals: boolean;
  83557. /**
  83558. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83559. */
  83560. SkipMaterials: boolean;
  83561. /**
  83562. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83563. */
  83564. MaterialLoadingFailsSilently: boolean;
  83565. };
  83566. /**
  83567. * OBJ file type loader.
  83568. * This is a babylon scene loader plugin.
  83569. */
  83570. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83571. /**
  83572. * Defines if UVs are optimized by default during load.
  83573. */
  83574. static OPTIMIZE_WITH_UV: boolean;
  83575. /**
  83576. * Invert model on y-axis (does a model scaling inversion)
  83577. */
  83578. static INVERT_Y: boolean;
  83579. /**
  83580. * Invert Y-Axis of referenced textures on load
  83581. */
  83582. static get INVERT_TEXTURE_Y(): boolean;
  83583. static set INVERT_TEXTURE_Y(value: boolean);
  83584. /**
  83585. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83586. */
  83587. static IMPORT_VERTEX_COLORS: boolean;
  83588. /**
  83589. * Compute the normals for the model, even if normals are present in the file.
  83590. */
  83591. static COMPUTE_NORMALS: boolean;
  83592. /**
  83593. * Defines custom scaling of UV coordinates of loaded meshes.
  83594. */
  83595. static UV_SCALING: Vector2;
  83596. /**
  83597. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83598. */
  83599. static SKIP_MATERIALS: boolean;
  83600. /**
  83601. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83602. *
  83603. * Defaults to true for backwards compatibility.
  83604. */
  83605. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83606. /**
  83607. * Defines the name of the plugin.
  83608. */
  83609. name: string;
  83610. /**
  83611. * Defines the extension the plugin is able to load.
  83612. */
  83613. extensions: string;
  83614. /** @hidden */
  83615. obj: RegExp;
  83616. /** @hidden */
  83617. group: RegExp;
  83618. /** @hidden */
  83619. mtllib: RegExp;
  83620. /** @hidden */
  83621. usemtl: RegExp;
  83622. /** @hidden */
  83623. smooth: RegExp;
  83624. /** @hidden */
  83625. vertexPattern: RegExp;
  83626. /** @hidden */
  83627. normalPattern: RegExp;
  83628. /** @hidden */
  83629. uvPattern: RegExp;
  83630. /** @hidden */
  83631. facePattern1: RegExp;
  83632. /** @hidden */
  83633. facePattern2: RegExp;
  83634. /** @hidden */
  83635. facePattern3: RegExp;
  83636. /** @hidden */
  83637. facePattern4: RegExp;
  83638. /** @hidden */
  83639. facePattern5: RegExp;
  83640. private _forAssetContainer;
  83641. private _meshLoadOptions;
  83642. /**
  83643. * Creates loader for .OBJ files
  83644. *
  83645. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83646. */
  83647. constructor(meshLoadOptions?: MeshLoadOptions);
  83648. private static get currentMeshLoadOptions();
  83649. /**
  83650. * Calls synchronously the MTL file attached to this obj.
  83651. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83652. * Without this function materials are not displayed in the first frame (but displayed after).
  83653. * In consequence it is impossible to get material information in your HTML file
  83654. *
  83655. * @param url The URL of the MTL file
  83656. * @param rootUrl
  83657. * @param onSuccess Callback function to be called when the MTL file is loaded
  83658. * @private
  83659. */
  83660. private _loadMTL;
  83661. /**
  83662. * Instantiates a OBJ file loader plugin.
  83663. * @returns the created plugin
  83664. */
  83665. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83666. /**
  83667. * If the data string can be loaded directly.
  83668. *
  83669. * @param data string containing the file data
  83670. * @returns if the data can be loaded directly
  83671. */
  83672. canDirectLoad(data: string): boolean;
  83673. /**
  83674. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83675. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83676. * @param scene the scene the meshes should be added to
  83677. * @param data the OBJ data to load
  83678. * @param rootUrl root url to load from
  83679. * @param onProgress event that fires when loading progress has occured
  83680. * @param fileName Defines the name of the file to load
  83681. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83682. */
  83683. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83684. meshes: AbstractMesh[];
  83685. particleSystems: IParticleSystem[];
  83686. skeletons: Skeleton[];
  83687. animationGroups: AnimationGroup[];
  83688. }>;
  83689. /**
  83690. * Imports all objects from the loaded OBJ data and adds them to the scene
  83691. * @param scene the scene the objects should be added to
  83692. * @param data the OBJ data to load
  83693. * @param rootUrl root url to load from
  83694. * @param onProgress event that fires when loading progress has occured
  83695. * @param fileName Defines the name of the file to load
  83696. * @returns a promise which completes when objects have been loaded to the scene
  83697. */
  83698. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83699. /**
  83700. * Load into an asset container.
  83701. * @param scene The scene to load into
  83702. * @param data The data to import
  83703. * @param rootUrl The root url for scene and resources
  83704. * @param onProgress The callback when the load progresses
  83705. * @param fileName Defines the name of the file to load
  83706. * @returns The loaded asset container
  83707. */
  83708. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83709. /**
  83710. * Read the OBJ file and create an Array of meshes.
  83711. * Each mesh contains all information given by the OBJ and the MTL file.
  83712. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83713. *
  83714. * @param meshesNames
  83715. * @param scene Scene The scene where are displayed the data
  83716. * @param data String The content of the obj file
  83717. * @param rootUrl String The path to the folder
  83718. * @returns Array<AbstractMesh>
  83719. * @private
  83720. */
  83721. private _parseSolid;
  83722. }
  83723. }
  83724. declare module BABYLON {
  83725. /**
  83726. * STL file type loader.
  83727. * This is a babylon scene loader plugin.
  83728. */
  83729. export class STLFileLoader implements ISceneLoaderPlugin {
  83730. /** @hidden */
  83731. solidPattern: RegExp;
  83732. /** @hidden */
  83733. facetsPattern: RegExp;
  83734. /** @hidden */
  83735. normalPattern: RegExp;
  83736. /** @hidden */
  83737. vertexPattern: RegExp;
  83738. /**
  83739. * Defines the name of the plugin.
  83740. */
  83741. name: string;
  83742. /**
  83743. * Defines the extensions the stl loader is able to load.
  83744. * force data to come in as an ArrayBuffer
  83745. * we'll convert to string if it looks like it's an ASCII .stl
  83746. */
  83747. extensions: ISceneLoaderPluginExtensions;
  83748. /**
  83749. * Import meshes into a scene.
  83750. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83751. * @param scene The scene to import into
  83752. * @param data The data to import
  83753. * @param rootUrl The root url for scene and resources
  83754. * @param meshes The meshes array to import into
  83755. * @param particleSystems The particle systems array to import into
  83756. * @param skeletons The skeletons array to import into
  83757. * @param onError The callback when import fails
  83758. * @returns True if successful or false otherwise
  83759. */
  83760. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83761. /**
  83762. * Load into a scene.
  83763. * @param scene The scene to load into
  83764. * @param data The data to import
  83765. * @param rootUrl The root url for scene and resources
  83766. * @param onError The callback when import fails
  83767. * @returns true if successful or false otherwise
  83768. */
  83769. load(scene: Scene, data: any, rootUrl: string): boolean;
  83770. /**
  83771. * Load into an asset container.
  83772. * @param scene The scene to load into
  83773. * @param data The data to import
  83774. * @param rootUrl The root url for scene and resources
  83775. * @param onError The callback when import fails
  83776. * @returns The loaded asset container
  83777. */
  83778. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83779. private _isBinary;
  83780. private _parseBinary;
  83781. private _parseASCII;
  83782. }
  83783. }
  83784. declare module BABYLON {
  83785. /**
  83786. * Class for generating OBJ data from a Babylon scene.
  83787. */
  83788. export class OBJExport {
  83789. /**
  83790. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83791. * @param mesh defines the list of meshes to serialize
  83792. * @param materials defines if materials should be exported
  83793. * @param matlibname defines the name of the associated mtl file
  83794. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83795. * @returns the OBJ content
  83796. */
  83797. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83798. /**
  83799. * Exports the material(s) of a mesh in .MTL file format (text)
  83800. * @param mesh defines the mesh to extract the material from
  83801. * @returns the mtl content
  83802. */
  83803. static MTL(mesh: Mesh): string;
  83804. }
  83805. }
  83806. declare module BABYLON {
  83807. /** @hidden */
  83808. export var __IGLTFExporterExtension: number;
  83809. /**
  83810. * Interface for extending the exporter
  83811. * @hidden
  83812. */
  83813. export interface IGLTFExporterExtension {
  83814. /**
  83815. * The name of this extension
  83816. */
  83817. readonly name: string;
  83818. /**
  83819. * Defines whether this extension is enabled
  83820. */
  83821. enabled: boolean;
  83822. /**
  83823. * Defines whether this extension is required
  83824. */
  83825. required: boolean;
  83826. }
  83827. }
  83828. declare module BABYLON.GLTF2.Exporter {
  83829. /** @hidden */
  83830. export var __IGLTFExporterExtensionV2: number;
  83831. /**
  83832. * Interface for a glTF exporter extension
  83833. * @hidden
  83834. */
  83835. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83836. /**
  83837. * Define this method to modify the default behavior before exporting a texture
  83838. * @param context The context when loading the asset
  83839. * @param babylonTexture The Babylon.js texture
  83840. * @param mimeType The mime-type of the generated image
  83841. * @returns A promise that resolves with the exported texture
  83842. */
  83843. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83844. /**
  83845. * Define this method to get notified when a texture info is created
  83846. * @param context The context when loading the asset
  83847. * @param textureInfo The glTF texture info
  83848. * @param babylonTexture The Babylon.js texture
  83849. */
  83850. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83851. /**
  83852. * Define this method to modify the default behavior when exporting texture info
  83853. * @param context The context when loading the asset
  83854. * @param meshPrimitive glTF mesh primitive
  83855. * @param babylonSubMesh Babylon submesh
  83856. * @param binaryWriter glTF serializer binary writer instance
  83857. * @returns nullable IMeshPrimitive promise
  83858. */
  83859. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83860. /**
  83861. * Define this method to modify the default behavior when exporting a node
  83862. * @param context The context when exporting the node
  83863. * @param node glTF node
  83864. * @param babylonNode BabylonJS node
  83865. * @returns nullable INode promise
  83866. */
  83867. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83868. [key: number]: number;
  83869. }): Promise<Nullable<INode>>;
  83870. /**
  83871. * Define this method to modify the default behavior when exporting a material
  83872. * @param material glTF material
  83873. * @param babylonMaterial BabylonJS material
  83874. * @returns nullable IMaterial promise
  83875. */
  83876. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83877. /**
  83878. * Define this method to return additional textures to export from a material
  83879. * @param material glTF material
  83880. * @param babylonMaterial BabylonJS material
  83881. * @returns List of textures
  83882. */
  83883. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83884. /** Gets a boolean indicating that this extension was used */
  83885. wasUsed: boolean;
  83886. /** Gets a boolean indicating that this extension is required for the file to work */
  83887. required: boolean;
  83888. /**
  83889. * Called after the exporter state changes to EXPORTING
  83890. */
  83891. onExporting?(): void;
  83892. }
  83893. }
  83894. declare module BABYLON.GLTF2.Exporter {
  83895. /**
  83896. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83897. * @hidden
  83898. */
  83899. export class _GLTFMaterialExporter {
  83900. /**
  83901. * Represents the dielectric specular values for R, G and B
  83902. */
  83903. private static readonly _DielectricSpecular;
  83904. /**
  83905. * Allows the maximum specular power to be defined for material calculations
  83906. */
  83907. private static readonly _MaxSpecularPower;
  83908. /**
  83909. * Mapping to store textures
  83910. */
  83911. private _textureMap;
  83912. /**
  83913. * Numeric tolerance value
  83914. */
  83915. private static readonly _Epsilon;
  83916. /**
  83917. * Reference to the glTF Exporter
  83918. */
  83919. private _exporter;
  83920. constructor(exporter: _Exporter);
  83921. /**
  83922. * Specifies if two colors are approximately equal in value
  83923. * @param color1 first color to compare to
  83924. * @param color2 second color to compare to
  83925. * @param epsilon threshold value
  83926. */
  83927. private static FuzzyEquals;
  83928. /**
  83929. * Gets the materials from a Babylon scene and converts them to glTF materials
  83930. * @param scene babylonjs scene
  83931. * @param mimeType texture mime type
  83932. * @param images array of images
  83933. * @param textures array of textures
  83934. * @param materials array of materials
  83935. * @param imageData mapping of texture names to base64 textures
  83936. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83937. */
  83938. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83939. /**
  83940. * Makes a copy of the glTF material without the texture parameters
  83941. * @param originalMaterial original glTF material
  83942. * @returns glTF material without texture parameters
  83943. */
  83944. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83945. /**
  83946. * Specifies if the material has any texture parameters present
  83947. * @param material glTF Material
  83948. * @returns boolean specifying if texture parameters are present
  83949. */
  83950. _hasTexturesPresent(material: IMaterial): boolean;
  83951. /**
  83952. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83953. * @param babylonStandardMaterial
  83954. * @returns glTF Metallic Roughness Material representation
  83955. */
  83956. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83957. /**
  83958. * Computes the metallic factor
  83959. * @param diffuse diffused value
  83960. * @param specular specular value
  83961. * @param oneMinusSpecularStrength one minus the specular strength
  83962. * @returns metallic value
  83963. */
  83964. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83965. /**
  83966. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83967. * @param glTFMaterial glTF material
  83968. * @param babylonMaterial Babylon material
  83969. */
  83970. private static _SetAlphaMode;
  83971. /**
  83972. * Converts a Babylon Standard Material to a glTF Material
  83973. * @param babylonStandardMaterial BJS Standard Material
  83974. * @param mimeType mime type to use for the textures
  83975. * @param images array of glTF image interfaces
  83976. * @param textures array of glTF texture interfaces
  83977. * @param materials array of glTF material interfaces
  83978. * @param imageData map of image file name to data
  83979. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83980. */
  83981. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83982. private _finishMaterial;
  83983. /**
  83984. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83985. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83986. * @param mimeType mime type to use for the textures
  83987. * @param images array of glTF image interfaces
  83988. * @param textures array of glTF texture interfaces
  83989. * @param materials array of glTF material interfaces
  83990. * @param imageData map of image file name to data
  83991. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83992. */
  83993. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83994. /**
  83995. * Converts an image typed array buffer to a base64 image
  83996. * @param buffer typed array buffer
  83997. * @param width width of the image
  83998. * @param height height of the image
  83999. * @param mimeType mimetype of the image
  84000. * @returns base64 image string
  84001. */
  84002. private _createBase64FromCanvasAsync;
  84003. /**
  84004. * Generates a white texture based on the specified width and height
  84005. * @param width width of the texture in pixels
  84006. * @param height height of the texture in pixels
  84007. * @param scene babylonjs scene
  84008. * @returns white texture
  84009. */
  84010. private _createWhiteTexture;
  84011. /**
  84012. * 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
  84013. * @param texture1 first texture to resize
  84014. * @param texture2 second texture to resize
  84015. * @param scene babylonjs scene
  84016. * @returns resized textures or null
  84017. */
  84018. private _resizeTexturesToSameDimensions;
  84019. /**
  84020. * Converts an array of pixels to a Float32Array
  84021. * Throws an error if the pixel format is not supported
  84022. * @param pixels - array buffer containing pixel values
  84023. * @returns Float32 of pixels
  84024. */
  84025. private _convertPixelArrayToFloat32;
  84026. /**
  84027. * Convert Specular Glossiness Textures to Metallic Roughness
  84028. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84029. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84030. * @param diffuseTexture texture used to store diffuse information
  84031. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84032. * @param factors specular glossiness material factors
  84033. * @param mimeType the mime type to use for the texture
  84034. * @returns pbr metallic roughness interface or null
  84035. */
  84036. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84037. /**
  84038. * Converts specular glossiness material properties to metallic roughness
  84039. * @param specularGlossiness interface with specular glossiness material properties
  84040. * @returns interface with metallic roughness material properties
  84041. */
  84042. private _convertSpecularGlossinessToMetallicRoughness;
  84043. /**
  84044. * Calculates the surface reflectance, independent of lighting conditions
  84045. * @param color Color source to calculate brightness from
  84046. * @returns number representing the perceived brightness, or zero if color is undefined
  84047. */
  84048. private _getPerceivedBrightness;
  84049. /**
  84050. * Returns the maximum color component value
  84051. * @param color
  84052. * @returns maximum color component value, or zero if color is null or undefined
  84053. */
  84054. private _getMaxComponent;
  84055. /**
  84056. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84057. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84058. * @param mimeType mime type to use for the textures
  84059. * @param images array of glTF image interfaces
  84060. * @param textures array of glTF texture interfaces
  84061. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84062. * @param imageData map of image file name to data
  84063. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84064. * @returns glTF PBR Metallic Roughness factors
  84065. */
  84066. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84067. private _getGLTFTextureSampler;
  84068. private _getGLTFTextureWrapMode;
  84069. private _getGLTFTextureWrapModesSampler;
  84070. /**
  84071. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84072. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84073. * @param mimeType mime type to use for the textures
  84074. * @param images array of glTF image interfaces
  84075. * @param textures array of glTF texture interfaces
  84076. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84077. * @param imageData map of image file name to data
  84078. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84079. * @returns glTF PBR Metallic Roughness factors
  84080. */
  84081. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84082. /**
  84083. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84084. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84085. * @param mimeType mime type to use for the textures
  84086. * @param images array of glTF image interfaces
  84087. * @param textures array of glTF texture interfaces
  84088. * @param materials array of glTF material interfaces
  84089. * @param imageData map of image file name to data
  84090. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84091. */
  84092. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84093. private setMetallicRoughnessPbrMaterial;
  84094. private getPixelsFromTexture;
  84095. /**
  84096. * Extracts a texture from a Babylon texture into file data and glTF data
  84097. * @param babylonTexture Babylon texture to extract
  84098. * @param mimeType Mime Type of the babylonTexture
  84099. * @return glTF texture info, or null if the texture format is not supported
  84100. */
  84101. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84102. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84103. /**
  84104. * Builds a texture from base64 string
  84105. * @param base64Texture base64 texture string
  84106. * @param baseTextureName Name to use for the texture
  84107. * @param mimeType image mime type for the texture
  84108. * @param images array of images
  84109. * @param textures array of textures
  84110. * @param imageData map of image data
  84111. * @returns glTF texture info, or null if the texture format is not supported
  84112. */
  84113. private _getTextureInfoFromBase64;
  84114. }
  84115. }
  84116. declare module BABYLON {
  84117. /**
  84118. * Class for holding and downloading glTF file data
  84119. */
  84120. export class GLTFData {
  84121. /**
  84122. * Object which contains the file name as the key and its data as the value
  84123. */
  84124. glTFFiles: {
  84125. [fileName: string]: string | Blob;
  84126. };
  84127. /**
  84128. * Initializes the glTF file object
  84129. */
  84130. constructor();
  84131. /**
  84132. * Downloads the glTF data as files based on their names and data
  84133. */
  84134. downloadFiles(): void;
  84135. }
  84136. }
  84137. declare module BABYLON {
  84138. /**
  84139. * Holds a collection of exporter options and parameters
  84140. */
  84141. export interface IExportOptions {
  84142. /**
  84143. * Function which indicates whether a babylon node should be exported or not
  84144. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84145. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84146. */
  84147. shouldExportNode?(node: Node): boolean;
  84148. /**
  84149. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84150. * @param metadata source metadata to read from
  84151. * @returns the data to store to glTF node extras
  84152. */
  84153. metadataSelector?(metadata: any): any;
  84154. /**
  84155. * The sample rate to bake animation curves
  84156. */
  84157. animationSampleRate?: number;
  84158. /**
  84159. * Begin serialization without waiting for the scene to be ready
  84160. */
  84161. exportWithoutWaitingForScene?: boolean;
  84162. /**
  84163. * Indicates if coordinate system swapping root nodes should be included in export
  84164. */
  84165. includeCoordinateSystemConversionNodes?: boolean;
  84166. }
  84167. /**
  84168. * Class for generating glTF data from a Babylon scene.
  84169. */
  84170. export class GLTF2Export {
  84171. /**
  84172. * Exports the geometry of the scene to .gltf file format asynchronously
  84173. * @param scene Babylon scene with scene hierarchy information
  84174. * @param filePrefix File prefix to use when generating the glTF file
  84175. * @param options Exporter options
  84176. * @returns Returns an object with a .gltf file and associates texture names
  84177. * as keys and their data and paths as values
  84178. */
  84179. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84180. private static _PreExportAsync;
  84181. private static _PostExportAsync;
  84182. /**
  84183. * Exports the geometry of the scene to .glb file format asychronously
  84184. * @param scene Babylon scene with scene hierarchy information
  84185. * @param filePrefix File prefix to use when generating glb file
  84186. * @param options Exporter options
  84187. * @returns Returns an object with a .glb filename as key and data as value
  84188. */
  84189. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84190. }
  84191. }
  84192. declare module BABYLON.GLTF2.Exporter {
  84193. /**
  84194. * @hidden
  84195. */
  84196. export class _GLTFUtilities {
  84197. /**
  84198. * Creates a buffer view based on the supplied arguments
  84199. * @param bufferIndex index value of the specified buffer
  84200. * @param byteOffset byte offset value
  84201. * @param byteLength byte length of the bufferView
  84202. * @param byteStride byte distance between conequential elements
  84203. * @param name name of the buffer view
  84204. * @returns bufferView for glTF
  84205. */
  84206. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84207. /**
  84208. * Creates an accessor based on the supplied arguments
  84209. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84210. * @param name The name of the accessor
  84211. * @param type The type of the accessor
  84212. * @param componentType The datatype of components in the attribute
  84213. * @param count The number of attributes referenced by this accessor
  84214. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84215. * @param min Minimum value of each component in this attribute
  84216. * @param max Maximum value of each component in this attribute
  84217. * @returns accessor for glTF
  84218. */
  84219. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84220. /**
  84221. * Calculates the minimum and maximum values of an array of position floats
  84222. * @param positions Positions array of a mesh
  84223. * @param vertexStart Starting vertex offset to calculate min and max values
  84224. * @param vertexCount Number of vertices to check for min and max values
  84225. * @returns min number array and max number array
  84226. */
  84227. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84228. min: number[];
  84229. max: number[];
  84230. };
  84231. /**
  84232. * Converts a new right-handed Vector3
  84233. * @param vector vector3 array
  84234. * @returns right-handed Vector3
  84235. */
  84236. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84237. /**
  84238. * Converts a Vector3 to right-handed
  84239. * @param vector Vector3 to convert to right-handed
  84240. */
  84241. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84242. /**
  84243. * Converts a three element number array to right-handed
  84244. * @param vector number array to convert to right-handed
  84245. */
  84246. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84247. /**
  84248. * Converts a new right-handed Vector3
  84249. * @param vector vector3 array
  84250. * @returns right-handed Vector3
  84251. */
  84252. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84253. /**
  84254. * Converts a Vector3 to right-handed
  84255. * @param vector Vector3 to convert to right-handed
  84256. */
  84257. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84258. /**
  84259. * Converts a three element number array to right-handed
  84260. * @param vector number array to convert to right-handed
  84261. */
  84262. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84263. /**
  84264. * Converts a Vector4 to right-handed
  84265. * @param vector Vector4 to convert to right-handed
  84266. */
  84267. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84268. /**
  84269. * Converts a Vector4 to right-handed
  84270. * @param vector Vector4 to convert to right-handed
  84271. */
  84272. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84273. /**
  84274. * Converts a Quaternion to right-handed
  84275. * @param quaternion Source quaternion to convert to right-handed
  84276. */
  84277. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84278. /**
  84279. * Converts a Quaternion to right-handed
  84280. * @param quaternion Source quaternion to convert to right-handed
  84281. */
  84282. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84283. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84284. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84285. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84286. }
  84287. }
  84288. declare module BABYLON.GLTF2.Exporter {
  84289. /**
  84290. * Converts Babylon Scene into glTF 2.0.
  84291. * @hidden
  84292. */
  84293. export class _Exporter {
  84294. /**
  84295. * Stores the glTF to export
  84296. */
  84297. _glTF: IGLTF;
  84298. /**
  84299. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84300. */
  84301. _bufferViews: IBufferView[];
  84302. /**
  84303. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84304. */
  84305. _accessors: IAccessor[];
  84306. /**
  84307. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84308. */
  84309. _nodes: INode[];
  84310. /**
  84311. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84312. */
  84313. private _scenes;
  84314. /**
  84315. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84316. */
  84317. private _meshes;
  84318. /**
  84319. * Stores all the generated material information, which represents the appearance of each primitive
  84320. */
  84321. _materials: IMaterial[];
  84322. _materialMap: {
  84323. [materialID: number]: number;
  84324. };
  84325. /**
  84326. * Stores all the generated texture information, which is referenced by glTF materials
  84327. */
  84328. _textures: ITexture[];
  84329. /**
  84330. * Stores all the generated image information, which is referenced by glTF textures
  84331. */
  84332. _images: IImage[];
  84333. /**
  84334. * Stores all the texture samplers
  84335. */
  84336. _samplers: ISampler[];
  84337. /**
  84338. * Stores all the generated glTF skins
  84339. */
  84340. _skins: ISkin[];
  84341. /**
  84342. * Stores all the generated animation samplers, which is referenced by glTF animations
  84343. */
  84344. /**
  84345. * Stores the animations for glTF models
  84346. */
  84347. private _animations;
  84348. /**
  84349. * Stores the total amount of bytes stored in the glTF buffer
  84350. */
  84351. private _totalByteLength;
  84352. /**
  84353. * Stores a reference to the Babylon scene containing the source geometry and material information
  84354. */
  84355. _babylonScene: Scene;
  84356. /**
  84357. * Stores a map of the image data, where the key is the file name and the value
  84358. * is the image data
  84359. */
  84360. _imageData: {
  84361. [fileName: string]: {
  84362. data: Uint8Array;
  84363. mimeType: ImageMimeType;
  84364. };
  84365. };
  84366. protected _orderedImageData: Array<{
  84367. data: Uint8Array;
  84368. mimeType: ImageMimeType;
  84369. }>;
  84370. /**
  84371. * Stores a map of the unique id of a node to its index in the node array
  84372. */
  84373. _nodeMap: {
  84374. [key: number]: number;
  84375. };
  84376. /**
  84377. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84378. */
  84379. _convertToRightHandedSystem: boolean;
  84380. /**
  84381. * Specifies if a Babylon node should be converted to right-handed on export
  84382. */
  84383. _convertToRightHandedSystemMap: {
  84384. [nodeId: number]: boolean;
  84385. };
  84386. _includeCoordinateSystemConversionNodes: boolean;
  84387. /**
  84388. * Baked animation sample rate
  84389. */
  84390. private _animationSampleRate;
  84391. private _options;
  84392. private _localEngine;
  84393. _glTFMaterialExporter: _GLTFMaterialExporter;
  84394. private _extensions;
  84395. private static _ExtensionNames;
  84396. private static _ExtensionFactories;
  84397. private _applyExtension;
  84398. private _applyExtensions;
  84399. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84400. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84401. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84402. [key: number]: number;
  84403. }): Promise<Nullable<INode>>;
  84404. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84405. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84406. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84407. private _forEachExtensions;
  84408. private _extensionsOnExporting;
  84409. /**
  84410. * Load glTF serializer extensions
  84411. */
  84412. private _loadExtensions;
  84413. /**
  84414. * Creates a glTF Exporter instance, which can accept optional exporter options
  84415. * @param babylonScene Babylon scene object
  84416. * @param options Options to modify the behavior of the exporter
  84417. */
  84418. constructor(babylonScene: Scene, options?: IExportOptions);
  84419. dispose(): void;
  84420. /**
  84421. * Registers a glTF exporter extension
  84422. * @param name Name of the extension to export
  84423. * @param factory The factory function that creates the exporter extension
  84424. */
  84425. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84426. /**
  84427. * Un-registers an exporter extension
  84428. * @param name The name fo the exporter extension
  84429. * @returns A boolean indicating whether the extension has been un-registered
  84430. */
  84431. static UnregisterExtension(name: string): boolean;
  84432. /**
  84433. * Lazy load a local engine
  84434. */
  84435. _getLocalEngine(): Engine;
  84436. private reorderIndicesBasedOnPrimitiveMode;
  84437. /**
  84438. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84439. * clock-wise during export to glTF
  84440. * @param submesh BabylonJS submesh
  84441. * @param primitiveMode Primitive mode of the mesh
  84442. * @param sideOrientation the winding order of the submesh
  84443. * @param vertexBufferKind The type of vertex attribute
  84444. * @param meshAttributeArray The vertex attribute data
  84445. * @param byteOffset The offset to the binary data
  84446. * @param binaryWriter The binary data for the glTF file
  84447. * @param convertToRightHandedSystem Converts the values to right-handed
  84448. */
  84449. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84450. /**
  84451. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84452. * clock-wise during export to glTF
  84453. * @param submesh BabylonJS submesh
  84454. * @param primitiveMode Primitive mode of the mesh
  84455. * @param sideOrientation the winding order of the submesh
  84456. * @param vertexBufferKind The type of vertex attribute
  84457. * @param meshAttributeArray The vertex attribute data
  84458. * @param byteOffset The offset to the binary data
  84459. * @param binaryWriter The binary data for the glTF file
  84460. * @param convertToRightHandedSystem Converts the values to right-handed
  84461. */
  84462. private reorderTriangleFillMode;
  84463. /**
  84464. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84465. * clock-wise during export to glTF
  84466. * @param submesh BabylonJS submesh
  84467. * @param primitiveMode Primitive mode of the mesh
  84468. * @param sideOrientation the winding order of the submesh
  84469. * @param vertexBufferKind The type of vertex attribute
  84470. * @param meshAttributeArray The vertex attribute data
  84471. * @param byteOffset The offset to the binary data
  84472. * @param binaryWriter The binary data for the glTF file
  84473. * @param convertToRightHandedSystem Converts the values to right-handed
  84474. */
  84475. private reorderTriangleStripDrawMode;
  84476. /**
  84477. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84478. * clock-wise during export to glTF
  84479. * @param submesh BabylonJS submesh
  84480. * @param primitiveMode Primitive mode of the mesh
  84481. * @param sideOrientation the winding order of the submesh
  84482. * @param vertexBufferKind The type of vertex attribute
  84483. * @param meshAttributeArray The vertex attribute data
  84484. * @param byteOffset The offset to the binary data
  84485. * @param binaryWriter The binary data for the glTF file
  84486. * @param convertToRightHandedSystem Converts the values to right-handed
  84487. */
  84488. private reorderTriangleFanMode;
  84489. /**
  84490. * Writes the vertex attribute data to binary
  84491. * @param vertices The vertices to write to the binary writer
  84492. * @param byteOffset The offset into the binary writer to overwrite binary data
  84493. * @param vertexAttributeKind The vertex attribute type
  84494. * @param meshAttributeArray The vertex attribute data
  84495. * @param binaryWriter The writer containing the binary data
  84496. * @param convertToRightHandedSystem Converts the values to right-handed
  84497. */
  84498. private writeVertexAttributeData;
  84499. /**
  84500. * Writes mesh attribute data to a data buffer
  84501. * Returns the bytelength of the data
  84502. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84503. * @param meshAttributeArray Array containing the attribute data
  84504. * @param byteStride Specifies the space between data
  84505. * @param binaryWriter The buffer to write the binary data to
  84506. * @param convertToRightHandedSystem Converts the values to right-handed
  84507. */
  84508. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84509. /**
  84510. * Writes mesh attribute data to a data buffer
  84511. * Returns the bytelength of the data
  84512. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84513. * @param meshAttributeArray Array containing the attribute data
  84514. * @param byteStride Specifies the space between data
  84515. * @param binaryWriter The buffer to write the binary data to
  84516. * @param convertToRightHandedSystem Converts the values to right-handed
  84517. */
  84518. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84519. /**
  84520. * Generates glTF json data
  84521. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84522. * @param glTFPrefix Text to use when prefixing a glTF file
  84523. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84524. * @returns json data as string
  84525. */
  84526. private generateJSON;
  84527. /**
  84528. * Generates data for .gltf and .bin files based on the glTF prefix string
  84529. * @param glTFPrefix Text to use when prefixing a glTF file
  84530. * @param dispose Dispose the exporter
  84531. * @returns GLTFData with glTF file data
  84532. */
  84533. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84534. /**
  84535. * Creates a binary buffer for glTF
  84536. * @returns array buffer for binary data
  84537. */
  84538. private _generateBinaryAsync;
  84539. /**
  84540. * Pads the number to a multiple of 4
  84541. * @param num number to pad
  84542. * @returns padded number
  84543. */
  84544. private _getPadding;
  84545. /**
  84546. * @hidden
  84547. */
  84548. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84549. /**
  84550. * Sets the TRS for each node
  84551. * @param node glTF Node for storing the transformation data
  84552. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84553. * @param convertToRightHandedSystem Converts the values to right-handed
  84554. */
  84555. private setNodeTransformation;
  84556. private getVertexBufferFromMesh;
  84557. /**
  84558. * Creates a bufferview based on the vertices type for the Babylon mesh
  84559. * @param kind Indicates the type of vertices data
  84560. * @param componentType Indicates the numerical type used to store the data
  84561. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84562. * @param binaryWriter The buffer to write the bufferview data to
  84563. * @param convertToRightHandedSystem Converts the values to right-handed
  84564. */
  84565. private createBufferViewKind;
  84566. /**
  84567. * Creates a bufferview based on the vertices type for the Babylon mesh
  84568. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84569. * @param babylonMorphTarget the morph target to be exported
  84570. * @param binaryWriter The buffer to write the bufferview data to
  84571. * @param convertToRightHandedSystem Converts the values to right-handed
  84572. */
  84573. private setMorphTargetAttributes;
  84574. /**
  84575. * The primitive mode of the Babylon mesh
  84576. * @param babylonMesh The BabylonJS mesh
  84577. */
  84578. private getMeshPrimitiveMode;
  84579. /**
  84580. * Sets the primitive mode of the glTF mesh primitive
  84581. * @param meshPrimitive glTF mesh primitive
  84582. * @param primitiveMode The primitive mode
  84583. */
  84584. private setPrimitiveMode;
  84585. /**
  84586. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84587. * @param meshPrimitive glTF mesh primitive
  84588. * @param attributeKind vertex attribute
  84589. * @returns boolean specifying if uv coordinates are present
  84590. */
  84591. private setAttributeKind;
  84592. /**
  84593. * Sets data for the primitive attributes of each submesh
  84594. * @param mesh glTF Mesh object to store the primitive attribute information
  84595. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84596. * @param binaryWriter Buffer to write the attribute data to
  84597. * @param convertToRightHandedSystem Converts the values to right-handed
  84598. */
  84599. private setPrimitiveAttributesAsync;
  84600. /**
  84601. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84602. * @param node The node to check
  84603. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84604. */
  84605. private isBabylonCoordinateSystemConvertingNode;
  84606. /**
  84607. * Creates a glTF scene based on the array of meshes
  84608. * Returns the the total byte offset
  84609. * @param babylonScene Babylon scene to get the mesh data from
  84610. * @param binaryWriter Buffer to write binary data to
  84611. */
  84612. private createSceneAsync;
  84613. /**
  84614. * Creates a mapping of Node unique id to node index and handles animations
  84615. * @param babylonScene Babylon Scene
  84616. * @param nodes Babylon transform nodes
  84617. * @param binaryWriter Buffer to write binary data to
  84618. * @returns Node mapping of unique id to index
  84619. */
  84620. private createNodeMapAndAnimationsAsync;
  84621. /**
  84622. * Creates a glTF node from a Babylon mesh
  84623. * @param babylonMesh Source Babylon mesh
  84624. * @param binaryWriter Buffer for storing geometry data
  84625. * @param convertToRightHandedSystem Converts the values to right-handed
  84626. * @param nodeMap Node mapping of unique id to glTF node index
  84627. * @returns glTF node
  84628. */
  84629. private createNodeAsync;
  84630. /**
  84631. * Creates a glTF skin from a Babylon skeleton
  84632. * @param babylonScene Babylon Scene
  84633. * @param nodes Babylon transform nodes
  84634. * @param binaryWriter Buffer to write binary data to
  84635. * @returns Node mapping of unique id to index
  84636. */
  84637. private createSkinsAsync;
  84638. }
  84639. /**
  84640. * @hidden
  84641. *
  84642. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84643. */
  84644. export class _BinaryWriter {
  84645. /**
  84646. * Array buffer which stores all binary data
  84647. */
  84648. private _arrayBuffer;
  84649. /**
  84650. * View of the array buffer
  84651. */
  84652. private _dataView;
  84653. /**
  84654. * byte offset of data in array buffer
  84655. */
  84656. private _byteOffset;
  84657. /**
  84658. * Initialize binary writer with an initial byte length
  84659. * @param byteLength Initial byte length of the array buffer
  84660. */
  84661. constructor(byteLength: number);
  84662. /**
  84663. * Resize the array buffer to the specified byte length
  84664. * @param byteLength
  84665. */
  84666. private resizeBuffer;
  84667. /**
  84668. * Get an array buffer with the length of the byte offset
  84669. * @returns ArrayBuffer resized to the byte offset
  84670. */
  84671. getArrayBuffer(): ArrayBuffer;
  84672. /**
  84673. * Get the byte offset of the array buffer
  84674. * @returns byte offset
  84675. */
  84676. getByteOffset(): number;
  84677. /**
  84678. * Stores an UInt8 in the array buffer
  84679. * @param entry
  84680. * @param byteOffset If defined, specifies where to set the value as an offset.
  84681. */
  84682. setUInt8(entry: number, byteOffset?: number): void;
  84683. /**
  84684. * Stores an UInt16 in the array buffer
  84685. * @param entry
  84686. * @param byteOffset If defined, specifies where to set the value as an offset.
  84687. */
  84688. setUInt16(entry: number, byteOffset?: number): void;
  84689. /**
  84690. * Gets an UInt32 in the array buffer
  84691. * @param entry
  84692. * @param byteOffset If defined, specifies where to set the value as an offset.
  84693. */
  84694. getUInt32(byteOffset: number): number;
  84695. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84696. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84697. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84698. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84699. /**
  84700. * Stores a Float32 in the array buffer
  84701. * @param entry
  84702. */
  84703. setFloat32(entry: number, byteOffset?: number): void;
  84704. /**
  84705. * Stores an UInt32 in the array buffer
  84706. * @param entry
  84707. * @param byteOffset If defined, specifies where to set the value as an offset.
  84708. */
  84709. setUInt32(entry: number, byteOffset?: number): void;
  84710. }
  84711. }
  84712. declare module BABYLON.GLTF2.Exporter {
  84713. /**
  84714. * @hidden
  84715. * Interface to store animation data.
  84716. */
  84717. export interface _IAnimationData {
  84718. /**
  84719. * Keyframe data.
  84720. */
  84721. inputs: number[];
  84722. /**
  84723. * Value data.
  84724. */
  84725. outputs: number[][];
  84726. /**
  84727. * Animation interpolation data.
  84728. */
  84729. samplerInterpolation: AnimationSamplerInterpolation;
  84730. /**
  84731. * Minimum keyframe value.
  84732. */
  84733. inputsMin: number;
  84734. /**
  84735. * Maximum keyframe value.
  84736. */
  84737. inputsMax: number;
  84738. }
  84739. /**
  84740. * @hidden
  84741. */
  84742. export interface _IAnimationInfo {
  84743. /**
  84744. * The target channel for the animation
  84745. */
  84746. animationChannelTargetPath: AnimationChannelTargetPath;
  84747. /**
  84748. * The glTF accessor type for the data.
  84749. */
  84750. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84751. /**
  84752. * Specifies if quaternions should be used.
  84753. */
  84754. useQuaternion: boolean;
  84755. }
  84756. /**
  84757. * @hidden
  84758. * Utility class for generating glTF animation data from BabylonJS.
  84759. */
  84760. export class _GLTFAnimation {
  84761. /**
  84762. * @ignore
  84763. *
  84764. * Creates glTF channel animation from BabylonJS animation.
  84765. * @param babylonTransformNode - BabylonJS mesh.
  84766. * @param animation - animation.
  84767. * @param animationChannelTargetPath - The target animation channel.
  84768. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84769. * @param useQuaternion - Specifies if quaternions are used.
  84770. * @returns nullable IAnimationData
  84771. */
  84772. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84773. private static _DeduceAnimationInfo;
  84774. /**
  84775. * @ignore
  84776. * Create node animations from the transform node animations
  84777. * @param babylonNode
  84778. * @param runtimeGLTFAnimation
  84779. * @param idleGLTFAnimations
  84780. * @param nodeMap
  84781. * @param nodes
  84782. * @param binaryWriter
  84783. * @param bufferViews
  84784. * @param accessors
  84785. * @param convertToRightHandedSystem
  84786. * @param animationSampleRate
  84787. */
  84788. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84789. [key: number]: number;
  84790. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84791. /**
  84792. * @ignore
  84793. * Create individual morph animations from the mesh's morph target animation tracks
  84794. * @param babylonNode
  84795. * @param runtimeGLTFAnimation
  84796. * @param idleGLTFAnimations
  84797. * @param nodeMap
  84798. * @param nodes
  84799. * @param binaryWriter
  84800. * @param bufferViews
  84801. * @param accessors
  84802. * @param convertToRightHandedSystem
  84803. * @param animationSampleRate
  84804. */
  84805. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84806. [key: number]: number;
  84807. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84808. /**
  84809. * @ignore
  84810. * Create node and morph animations from the animation groups
  84811. * @param babylonScene
  84812. * @param glTFAnimations
  84813. * @param nodeMap
  84814. * @param nodes
  84815. * @param binaryWriter
  84816. * @param bufferViews
  84817. * @param accessors
  84818. * @param convertToRightHandedSystemMap
  84819. * @param animationSampleRate
  84820. */
  84821. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84822. [key: number]: number;
  84823. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84824. [nodeId: number]: boolean;
  84825. }, animationSampleRate: number): void;
  84826. private static AddAnimation;
  84827. /**
  84828. * Create a baked animation
  84829. * @param babylonTransformNode BabylonJS mesh
  84830. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84831. * @param animationChannelTargetPath animation target channel
  84832. * @param minFrame minimum animation frame
  84833. * @param maxFrame maximum animation frame
  84834. * @param fps frames per second of the animation
  84835. * @param inputs input key frames of the animation
  84836. * @param outputs output key frame data of the animation
  84837. * @param convertToRightHandedSystem converts the values to right-handed
  84838. * @param useQuaternion specifies if quaternions should be used
  84839. */
  84840. private static _CreateBakedAnimation;
  84841. private static _ConvertFactorToVector3OrQuaternion;
  84842. private static _SetInterpolatedValue;
  84843. /**
  84844. * Creates linear animation from the animation key frames
  84845. * @param babylonTransformNode BabylonJS mesh
  84846. * @param animation BabylonJS animation
  84847. * @param animationChannelTargetPath The target animation channel
  84848. * @param frameDelta The difference between the last and first frame of the animation
  84849. * @param inputs Array to store the key frame times
  84850. * @param outputs Array to store the key frame data
  84851. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84852. * @param useQuaternion Specifies if quaternions are used in the animation
  84853. */
  84854. private static _CreateLinearOrStepAnimation;
  84855. /**
  84856. * Creates cubic spline animation from the animation key frames
  84857. * @param babylonTransformNode BabylonJS mesh
  84858. * @param animation BabylonJS animation
  84859. * @param animationChannelTargetPath The target animation channel
  84860. * @param frameDelta The difference between the last and first frame of the animation
  84861. * @param inputs Array to store the key frame times
  84862. * @param outputs Array to store the key frame data
  84863. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84864. * @param useQuaternion Specifies if quaternions are used in the animation
  84865. */
  84866. private static _CreateCubicSplineAnimation;
  84867. private static _GetBasePositionRotationOrScale;
  84868. /**
  84869. * Adds a key frame value
  84870. * @param keyFrame
  84871. * @param animation
  84872. * @param outputs
  84873. * @param animationChannelTargetPath
  84874. * @param basePositionRotationOrScale
  84875. * @param convertToRightHandedSystem
  84876. * @param useQuaternion
  84877. */
  84878. private static _AddKeyframeValue;
  84879. /**
  84880. * Determine the interpolation based on the key frames
  84881. * @param keyFrames
  84882. * @param animationChannelTargetPath
  84883. * @param useQuaternion
  84884. */
  84885. private static _DeduceInterpolation;
  84886. /**
  84887. * Adds an input tangent or output tangent to the output data
  84888. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84889. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84890. * @param outputs The animation data by keyframe
  84891. * @param animationChannelTargetPath The target animation channel
  84892. * @param interpolation The interpolation type
  84893. * @param keyFrame The key frame with the animation data
  84894. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84895. * @param useQuaternion Specifies if quaternions are used
  84896. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84897. */
  84898. private static AddSplineTangent;
  84899. /**
  84900. * Get the minimum and maximum key frames' frame values
  84901. * @param keyFrames animation key frames
  84902. * @returns the minimum and maximum key frame value
  84903. */
  84904. private static calculateMinMaxKeyFrames;
  84905. }
  84906. }
  84907. declare module BABYLON.GLTF2.Exporter {
  84908. /** @hidden */
  84909. export var textureTransformPixelShader: {
  84910. name: string;
  84911. shader: string;
  84912. };
  84913. }
  84914. declare module BABYLON.GLTF2.Exporter.Extensions {
  84915. /**
  84916. * @hidden
  84917. */
  84918. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84919. private _recordedTextures;
  84920. /** Name of this extension */
  84921. readonly name: string;
  84922. /** Defines whether this extension is enabled */
  84923. enabled: boolean;
  84924. /** Defines whether this extension is required */
  84925. required: boolean;
  84926. /** Reference to the glTF exporter */
  84927. private _wasUsed;
  84928. constructor(exporter: _Exporter);
  84929. dispose(): void;
  84930. /** @hidden */
  84931. get wasUsed(): boolean;
  84932. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84933. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84934. /**
  84935. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84936. * @param babylonTexture
  84937. * @param offset
  84938. * @param rotation
  84939. * @param scale
  84940. * @param scene
  84941. */
  84942. private _textureTransformTextureAsync;
  84943. }
  84944. }
  84945. declare module BABYLON.GLTF2.Exporter.Extensions {
  84946. /**
  84947. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84948. */
  84949. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84950. /** The name of this extension. */
  84951. readonly name: string;
  84952. /** Defines whether this extension is enabled. */
  84953. enabled: boolean;
  84954. /** Defines whether this extension is required */
  84955. required: boolean;
  84956. /** Reference to the glTF exporter */
  84957. private _exporter;
  84958. private _lights;
  84959. /** @hidden */
  84960. constructor(exporter: _Exporter);
  84961. /** @hidden */
  84962. dispose(): void;
  84963. /** @hidden */
  84964. get wasUsed(): boolean;
  84965. /** @hidden */
  84966. onExporting(): void;
  84967. /**
  84968. * Define this method to modify the default behavior when exporting a node
  84969. * @param context The context when exporting the node
  84970. * @param node glTF node
  84971. * @param babylonNode BabylonJS node
  84972. * @param nodeMap Node mapping of unique id to glTF node index
  84973. * @returns nullable INode promise
  84974. */
  84975. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84976. [key: number]: number;
  84977. }): Promise<Nullable<INode>>;
  84978. }
  84979. }
  84980. declare module BABYLON.GLTF2.Exporter.Extensions {
  84981. /**
  84982. * @hidden
  84983. */
  84984. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84985. /** Name of this extension */
  84986. readonly name: string;
  84987. /** Defines whether this extension is enabled */
  84988. enabled: boolean;
  84989. /** Defines whether this extension is required */
  84990. required: boolean;
  84991. /** Reference to the glTF exporter */
  84992. private _textureInfos;
  84993. private _exportedTextures;
  84994. private _wasUsed;
  84995. constructor(exporter: _Exporter);
  84996. dispose(): void;
  84997. /** @hidden */
  84998. get wasUsed(): boolean;
  84999. private _getTextureIndex;
  85000. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85001. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85002. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85003. }
  85004. }
  85005. declare module BABYLON.GLTF2.Exporter.Extensions {
  85006. /**
  85007. * @hidden
  85008. */
  85009. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85010. /** Name of this extension */
  85011. readonly name: string;
  85012. /** Defines whether this extension is enabled */
  85013. enabled: boolean;
  85014. /** Defines whether this extension is required */
  85015. required: boolean;
  85016. private _wasUsed;
  85017. constructor(exporter: _Exporter);
  85018. /** @hidden */
  85019. get wasUsed(): boolean;
  85020. dispose(): void;
  85021. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85022. }
  85023. }
  85024. declare module BABYLON {
  85025. /**
  85026. * Class for generating STL data from a Babylon scene.
  85027. */
  85028. export class STLExport {
  85029. /**
  85030. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85031. * @param meshes list defines the mesh to serialize
  85032. * @param download triggers the automatic download of the file.
  85033. * @param fileName changes the downloads fileName.
  85034. * @param binary changes the STL to a binary type.
  85035. * @param isLittleEndian toggle for binary type exporter.
  85036. * @returns the STL as UTF8 string
  85037. */
  85038. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85039. }
  85040. }
  85041. declare module "babylonjs-gltf2interface" {
  85042. export = BABYLON.GLTF2;
  85043. }
  85044. /**
  85045. * Module for glTF 2.0 Interface
  85046. */
  85047. declare module BABYLON.GLTF2 {
  85048. /**
  85049. * The datatype of the components in the attribute
  85050. */
  85051. const enum AccessorComponentType {
  85052. /**
  85053. * Byte
  85054. */
  85055. BYTE = 5120,
  85056. /**
  85057. * Unsigned Byte
  85058. */
  85059. UNSIGNED_BYTE = 5121,
  85060. /**
  85061. * Short
  85062. */
  85063. SHORT = 5122,
  85064. /**
  85065. * Unsigned Short
  85066. */
  85067. UNSIGNED_SHORT = 5123,
  85068. /**
  85069. * Unsigned Int
  85070. */
  85071. UNSIGNED_INT = 5125,
  85072. /**
  85073. * Float
  85074. */
  85075. FLOAT = 5126,
  85076. }
  85077. /**
  85078. * Specifies if the attirbute is a scalar, vector, or matrix
  85079. */
  85080. const enum AccessorType {
  85081. /**
  85082. * Scalar
  85083. */
  85084. SCALAR = "SCALAR",
  85085. /**
  85086. * Vector2
  85087. */
  85088. VEC2 = "VEC2",
  85089. /**
  85090. * Vector3
  85091. */
  85092. VEC3 = "VEC3",
  85093. /**
  85094. * Vector4
  85095. */
  85096. VEC4 = "VEC4",
  85097. /**
  85098. * Matrix2x2
  85099. */
  85100. MAT2 = "MAT2",
  85101. /**
  85102. * Matrix3x3
  85103. */
  85104. MAT3 = "MAT3",
  85105. /**
  85106. * Matrix4x4
  85107. */
  85108. MAT4 = "MAT4",
  85109. }
  85110. /**
  85111. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85112. */
  85113. const enum AnimationChannelTargetPath {
  85114. /**
  85115. * Translation
  85116. */
  85117. TRANSLATION = "translation",
  85118. /**
  85119. * Rotation
  85120. */
  85121. ROTATION = "rotation",
  85122. /**
  85123. * Scale
  85124. */
  85125. SCALE = "scale",
  85126. /**
  85127. * Weights
  85128. */
  85129. WEIGHTS = "weights",
  85130. }
  85131. /**
  85132. * Interpolation algorithm
  85133. */
  85134. const enum AnimationSamplerInterpolation {
  85135. /**
  85136. * The animated values are linearly interpolated between keyframes
  85137. */
  85138. LINEAR = "LINEAR",
  85139. /**
  85140. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85141. */
  85142. STEP = "STEP",
  85143. /**
  85144. * The animation's interpolation is computed using a cubic spline with specified tangents
  85145. */
  85146. CUBICSPLINE = "CUBICSPLINE",
  85147. }
  85148. /**
  85149. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85150. */
  85151. const enum CameraType {
  85152. /**
  85153. * A perspective camera containing properties to create a perspective projection matrix
  85154. */
  85155. PERSPECTIVE = "perspective",
  85156. /**
  85157. * An orthographic camera containing properties to create an orthographic projection matrix
  85158. */
  85159. ORTHOGRAPHIC = "orthographic",
  85160. }
  85161. /**
  85162. * The mime-type of the image
  85163. */
  85164. const enum ImageMimeType {
  85165. /**
  85166. * JPEG Mime-type
  85167. */
  85168. JPEG = "image/jpeg",
  85169. /**
  85170. * PNG Mime-type
  85171. */
  85172. PNG = "image/png",
  85173. }
  85174. /**
  85175. * The alpha rendering mode of the material
  85176. */
  85177. const enum MaterialAlphaMode {
  85178. /**
  85179. * The alpha value is ignored and the rendered output is fully opaque
  85180. */
  85181. OPAQUE = "OPAQUE",
  85182. /**
  85183. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85184. */
  85185. MASK = "MASK",
  85186. /**
  85187. * 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)
  85188. */
  85189. BLEND = "BLEND",
  85190. }
  85191. /**
  85192. * The type of the primitives to render
  85193. */
  85194. const enum MeshPrimitiveMode {
  85195. /**
  85196. * Points
  85197. */
  85198. POINTS = 0,
  85199. /**
  85200. * Lines
  85201. */
  85202. LINES = 1,
  85203. /**
  85204. * Line Loop
  85205. */
  85206. LINE_LOOP = 2,
  85207. /**
  85208. * Line Strip
  85209. */
  85210. LINE_STRIP = 3,
  85211. /**
  85212. * Triangles
  85213. */
  85214. TRIANGLES = 4,
  85215. /**
  85216. * Triangle Strip
  85217. */
  85218. TRIANGLE_STRIP = 5,
  85219. /**
  85220. * Triangle Fan
  85221. */
  85222. TRIANGLE_FAN = 6,
  85223. }
  85224. /**
  85225. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85226. */
  85227. const enum TextureMagFilter {
  85228. /**
  85229. * Nearest
  85230. */
  85231. NEAREST = 9728,
  85232. /**
  85233. * Linear
  85234. */
  85235. LINEAR = 9729,
  85236. }
  85237. /**
  85238. * Minification filter. All valid values correspond to WebGL enums
  85239. */
  85240. const enum TextureMinFilter {
  85241. /**
  85242. * Nearest
  85243. */
  85244. NEAREST = 9728,
  85245. /**
  85246. * Linear
  85247. */
  85248. LINEAR = 9729,
  85249. /**
  85250. * Nearest Mip-Map Nearest
  85251. */
  85252. NEAREST_MIPMAP_NEAREST = 9984,
  85253. /**
  85254. * Linear Mipmap Nearest
  85255. */
  85256. LINEAR_MIPMAP_NEAREST = 9985,
  85257. /**
  85258. * Nearest Mipmap Linear
  85259. */
  85260. NEAREST_MIPMAP_LINEAR = 9986,
  85261. /**
  85262. * Linear Mipmap Linear
  85263. */
  85264. LINEAR_MIPMAP_LINEAR = 9987,
  85265. }
  85266. /**
  85267. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85268. */
  85269. const enum TextureWrapMode {
  85270. /**
  85271. * Clamp to Edge
  85272. */
  85273. CLAMP_TO_EDGE = 33071,
  85274. /**
  85275. * Mirrored Repeat
  85276. */
  85277. MIRRORED_REPEAT = 33648,
  85278. /**
  85279. * Repeat
  85280. */
  85281. REPEAT = 10497,
  85282. }
  85283. /**
  85284. * glTF Property
  85285. */
  85286. interface IProperty {
  85287. /**
  85288. * Dictionary object with extension-specific objects
  85289. */
  85290. extensions?: {
  85291. [key: string]: any;
  85292. };
  85293. /**
  85294. * Application-Specific data
  85295. */
  85296. extras?: any;
  85297. }
  85298. /**
  85299. * glTF Child of Root Property
  85300. */
  85301. interface IChildRootProperty extends IProperty {
  85302. /**
  85303. * The user-defined name of this object
  85304. */
  85305. name?: string;
  85306. }
  85307. /**
  85308. * Indices of those attributes that deviate from their initialization value
  85309. */
  85310. interface IAccessorSparseIndices extends IProperty {
  85311. /**
  85312. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85313. */
  85314. bufferView: number;
  85315. /**
  85316. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85317. */
  85318. byteOffset?: number;
  85319. /**
  85320. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85321. */
  85322. componentType: AccessorComponentType;
  85323. }
  85324. /**
  85325. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85326. */
  85327. interface IAccessorSparseValues extends IProperty {
  85328. /**
  85329. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85330. */
  85331. bufferView: number;
  85332. /**
  85333. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85334. */
  85335. byteOffset?: number;
  85336. }
  85337. /**
  85338. * Sparse storage of attributes that deviate from their initialization value
  85339. */
  85340. interface IAccessorSparse extends IProperty {
  85341. /**
  85342. * The number of attributes encoded in this sparse accessor
  85343. */
  85344. count: number;
  85345. /**
  85346. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85347. */
  85348. indices: IAccessorSparseIndices;
  85349. /**
  85350. * 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
  85351. */
  85352. values: IAccessorSparseValues;
  85353. }
  85354. /**
  85355. * 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
  85356. */
  85357. interface IAccessor extends IChildRootProperty {
  85358. /**
  85359. * The index of the bufferview
  85360. */
  85361. bufferView?: number;
  85362. /**
  85363. * The offset relative to the start of the bufferView in bytes
  85364. */
  85365. byteOffset?: number;
  85366. /**
  85367. * The datatype of components in the attribute
  85368. */
  85369. componentType: AccessorComponentType;
  85370. /**
  85371. * Specifies whether integer data values should be normalized
  85372. */
  85373. normalized?: boolean;
  85374. /**
  85375. * The number of attributes referenced by this accessor
  85376. */
  85377. count: number;
  85378. /**
  85379. * Specifies if the attribute is a scalar, vector, or matrix
  85380. */
  85381. type: AccessorType;
  85382. /**
  85383. * Maximum value of each component in this attribute
  85384. */
  85385. max?: number[];
  85386. /**
  85387. * Minimum value of each component in this attribute
  85388. */
  85389. min?: number[];
  85390. /**
  85391. * Sparse storage of attributes that deviate from their initialization value
  85392. */
  85393. sparse?: IAccessorSparse;
  85394. }
  85395. /**
  85396. * Targets an animation's sampler at a node's property
  85397. */
  85398. interface IAnimationChannel extends IProperty {
  85399. /**
  85400. * The index of a sampler in this animation used to compute the value for the target
  85401. */
  85402. sampler: number;
  85403. /**
  85404. * The index of the node and TRS property to target
  85405. */
  85406. target: IAnimationChannelTarget;
  85407. }
  85408. /**
  85409. * The index of the node and TRS property that an animation channel targets
  85410. */
  85411. interface IAnimationChannelTarget extends IProperty {
  85412. /**
  85413. * The index of the node to target
  85414. */
  85415. node: number;
  85416. /**
  85417. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85418. */
  85419. path: AnimationChannelTargetPath;
  85420. }
  85421. /**
  85422. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85423. */
  85424. interface IAnimationSampler extends IProperty {
  85425. /**
  85426. * The index of an accessor containing keyframe input values, e.g., time
  85427. */
  85428. input: number;
  85429. /**
  85430. * Interpolation algorithm
  85431. */
  85432. interpolation?: AnimationSamplerInterpolation;
  85433. /**
  85434. * The index of an accessor, containing keyframe output values
  85435. */
  85436. output: number;
  85437. }
  85438. /**
  85439. * A keyframe animation
  85440. */
  85441. interface IAnimation extends IChildRootProperty {
  85442. /**
  85443. * An array of channels, each of which targets an animation's sampler at a node's property
  85444. */
  85445. channels: IAnimationChannel[];
  85446. /**
  85447. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85448. */
  85449. samplers: IAnimationSampler[];
  85450. }
  85451. /**
  85452. * Metadata about the glTF asset
  85453. */
  85454. interface IAsset extends IChildRootProperty {
  85455. /**
  85456. * A copyright message suitable for display to credit the content creator
  85457. */
  85458. copyright?: string;
  85459. /**
  85460. * Tool that generated this glTF model. Useful for debugging
  85461. */
  85462. generator?: string;
  85463. /**
  85464. * The glTF version that this asset targets
  85465. */
  85466. version: string;
  85467. /**
  85468. * The minimum glTF version that this asset targets
  85469. */
  85470. minVersion?: string;
  85471. }
  85472. /**
  85473. * A buffer points to binary geometry, animation, or skins
  85474. */
  85475. interface IBuffer extends IChildRootProperty {
  85476. /**
  85477. * 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
  85478. */
  85479. uri?: string;
  85480. /**
  85481. * The length of the buffer in bytes
  85482. */
  85483. byteLength: number;
  85484. }
  85485. /**
  85486. * A view into a buffer generally representing a subset of the buffer
  85487. */
  85488. interface IBufferView extends IChildRootProperty {
  85489. /**
  85490. * The index of the buffer
  85491. */
  85492. buffer: number;
  85493. /**
  85494. * The offset into the buffer in bytes
  85495. */
  85496. byteOffset?: number;
  85497. /**
  85498. * The lenth of the bufferView in bytes
  85499. */
  85500. byteLength: number;
  85501. /**
  85502. * The stride, in bytes
  85503. */
  85504. byteStride?: number;
  85505. }
  85506. /**
  85507. * An orthographic camera containing properties to create an orthographic projection matrix
  85508. */
  85509. interface ICameraOrthographic extends IProperty {
  85510. /**
  85511. * The floating-point horizontal magnification of the view. Must not be zero
  85512. */
  85513. xmag: number;
  85514. /**
  85515. * The floating-point vertical magnification of the view. Must not be zero
  85516. */
  85517. ymag: number;
  85518. /**
  85519. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85520. */
  85521. zfar: number;
  85522. /**
  85523. * The floating-point distance to the near clipping plane
  85524. */
  85525. znear: number;
  85526. }
  85527. /**
  85528. * A perspective camera containing properties to create a perspective projection matrix
  85529. */
  85530. interface ICameraPerspective extends IProperty {
  85531. /**
  85532. * The floating-point aspect ratio of the field of view
  85533. */
  85534. aspectRatio?: number;
  85535. /**
  85536. * The floating-point vertical field of view in radians
  85537. */
  85538. yfov: number;
  85539. /**
  85540. * The floating-point distance to the far clipping plane
  85541. */
  85542. zfar?: number;
  85543. /**
  85544. * The floating-point distance to the near clipping plane
  85545. */
  85546. znear: number;
  85547. }
  85548. /**
  85549. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85550. */
  85551. interface ICamera extends IChildRootProperty {
  85552. /**
  85553. * An orthographic camera containing properties to create an orthographic projection matrix
  85554. */
  85555. orthographic?: ICameraOrthographic;
  85556. /**
  85557. * A perspective camera containing properties to create a perspective projection matrix
  85558. */
  85559. perspective?: ICameraPerspective;
  85560. /**
  85561. * Specifies if the camera uses a perspective or orthographic projection
  85562. */
  85563. type: CameraType;
  85564. }
  85565. /**
  85566. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85567. */
  85568. interface IImage extends IChildRootProperty {
  85569. /**
  85570. * 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
  85571. */
  85572. uri?: string;
  85573. /**
  85574. * The image's MIME type
  85575. */
  85576. mimeType?: ImageMimeType;
  85577. /**
  85578. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85579. */
  85580. bufferView?: number;
  85581. }
  85582. /**
  85583. * Material Normal Texture Info
  85584. */
  85585. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85586. /**
  85587. * The scalar multiplier applied to each normal vector of the normal texture
  85588. */
  85589. scale?: number;
  85590. }
  85591. /**
  85592. * Material Occlusion Texture Info
  85593. */
  85594. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85595. /**
  85596. * A scalar multiplier controlling the amount of occlusion applied
  85597. */
  85598. strength?: number;
  85599. }
  85600. /**
  85601. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85602. */
  85603. interface IMaterialPbrMetallicRoughness {
  85604. /**
  85605. * The material's base color factor
  85606. */
  85607. baseColorFactor?: number[];
  85608. /**
  85609. * The base color texture
  85610. */
  85611. baseColorTexture?: ITextureInfo;
  85612. /**
  85613. * The metalness of the material
  85614. */
  85615. metallicFactor?: number;
  85616. /**
  85617. * The roughness of the material
  85618. */
  85619. roughnessFactor?: number;
  85620. /**
  85621. * The metallic-roughness texture
  85622. */
  85623. metallicRoughnessTexture?: ITextureInfo;
  85624. }
  85625. /**
  85626. * The material appearance of a primitive
  85627. */
  85628. interface IMaterial extends IChildRootProperty {
  85629. /**
  85630. * 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
  85631. */
  85632. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85633. /**
  85634. * The normal map texture
  85635. */
  85636. normalTexture?: IMaterialNormalTextureInfo;
  85637. /**
  85638. * The occlusion map texture
  85639. */
  85640. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85641. /**
  85642. * The emissive map texture
  85643. */
  85644. emissiveTexture?: ITextureInfo;
  85645. /**
  85646. * 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
  85647. */
  85648. emissiveFactor?: number[];
  85649. /**
  85650. * The alpha rendering mode of the material
  85651. */
  85652. alphaMode?: MaterialAlphaMode;
  85653. /**
  85654. * The alpha cutoff value of the material
  85655. */
  85656. alphaCutoff?: number;
  85657. /**
  85658. * Specifies whether the material is double sided
  85659. */
  85660. doubleSided?: boolean;
  85661. }
  85662. /**
  85663. * Geometry to be rendered with the given material
  85664. */
  85665. interface IMeshPrimitive extends IProperty {
  85666. /**
  85667. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85668. */
  85669. attributes: {
  85670. [name: string]: number;
  85671. };
  85672. /**
  85673. * The index of the accessor that contains the indices
  85674. */
  85675. indices?: number;
  85676. /**
  85677. * The index of the material to apply to this primitive when rendering
  85678. */
  85679. material?: number;
  85680. /**
  85681. * The type of primitives to render. All valid values correspond to WebGL enums
  85682. */
  85683. mode?: MeshPrimitiveMode;
  85684. /**
  85685. * 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
  85686. */
  85687. targets?: {
  85688. [name: string]: number;
  85689. }[];
  85690. }
  85691. /**
  85692. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85693. */
  85694. interface IMesh extends IChildRootProperty {
  85695. /**
  85696. * An array of primitives, each defining geometry to be rendered with a material
  85697. */
  85698. primitives: IMeshPrimitive[];
  85699. /**
  85700. * Array of weights to be applied to the Morph Targets
  85701. */
  85702. weights?: number[];
  85703. }
  85704. /**
  85705. * A node in the node hierarchy
  85706. */
  85707. interface INode extends IChildRootProperty {
  85708. /**
  85709. * The index of the camera referenced by this node
  85710. */
  85711. camera?: number;
  85712. /**
  85713. * The indices of this node's children
  85714. */
  85715. children?: number[];
  85716. /**
  85717. * The index of the skin referenced by this node
  85718. */
  85719. skin?: number;
  85720. /**
  85721. * A floating-point 4x4 transformation matrix stored in column-major order
  85722. */
  85723. matrix?: number[];
  85724. /**
  85725. * The index of the mesh in this node
  85726. */
  85727. mesh?: number;
  85728. /**
  85729. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85730. */
  85731. rotation?: number[];
  85732. /**
  85733. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85734. */
  85735. scale?: number[];
  85736. /**
  85737. * The node's translation along the x, y, and z axes
  85738. */
  85739. translation?: number[];
  85740. /**
  85741. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85742. */
  85743. weights?: number[];
  85744. }
  85745. /**
  85746. * Texture sampler properties for filtering and wrapping modes
  85747. */
  85748. interface ISampler extends IChildRootProperty {
  85749. /**
  85750. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85751. */
  85752. magFilter?: TextureMagFilter;
  85753. /**
  85754. * Minification filter. All valid values correspond to WebGL enums
  85755. */
  85756. minFilter?: TextureMinFilter;
  85757. /**
  85758. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85759. */
  85760. wrapS?: TextureWrapMode;
  85761. /**
  85762. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85763. */
  85764. wrapT?: TextureWrapMode;
  85765. }
  85766. /**
  85767. * The root nodes of a scene
  85768. */
  85769. interface IScene extends IChildRootProperty {
  85770. /**
  85771. * The indices of each root node
  85772. */
  85773. nodes: number[];
  85774. }
  85775. /**
  85776. * Joints and matrices defining a skin
  85777. */
  85778. interface ISkin extends IChildRootProperty {
  85779. /**
  85780. * 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
  85781. */
  85782. inverseBindMatrices?: number;
  85783. /**
  85784. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85785. */
  85786. skeleton?: number;
  85787. /**
  85788. * 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)
  85789. */
  85790. joints: number[];
  85791. }
  85792. /**
  85793. * A texture and its sampler
  85794. */
  85795. interface ITexture extends IChildRootProperty {
  85796. /**
  85797. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85798. */
  85799. sampler?: number;
  85800. /**
  85801. * The index of the image used by this texture
  85802. */
  85803. source: number;
  85804. }
  85805. /**
  85806. * Reference to a texture
  85807. */
  85808. interface ITextureInfo extends IProperty {
  85809. /**
  85810. * The index of the texture
  85811. */
  85812. index: number;
  85813. /**
  85814. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85815. */
  85816. texCoord?: number;
  85817. }
  85818. /**
  85819. * The root object for a glTF asset
  85820. */
  85821. interface IGLTF extends IProperty {
  85822. /**
  85823. * An array of accessors. An accessor is a typed view into a bufferView
  85824. */
  85825. accessors?: IAccessor[];
  85826. /**
  85827. * An array of keyframe animations
  85828. */
  85829. animations?: IAnimation[];
  85830. /**
  85831. * Metadata about the glTF asset
  85832. */
  85833. asset: IAsset;
  85834. /**
  85835. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85836. */
  85837. buffers?: IBuffer[];
  85838. /**
  85839. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85840. */
  85841. bufferViews?: IBufferView[];
  85842. /**
  85843. * An array of cameras
  85844. */
  85845. cameras?: ICamera[];
  85846. /**
  85847. * Names of glTF extensions used somewhere in this asset
  85848. */
  85849. extensionsUsed?: string[];
  85850. /**
  85851. * Names of glTF extensions required to properly load this asset
  85852. */
  85853. extensionsRequired?: string[];
  85854. /**
  85855. * An array of images. An image defines data used to create a texture
  85856. */
  85857. images?: IImage[];
  85858. /**
  85859. * An array of materials. A material defines the appearance of a primitive
  85860. */
  85861. materials?: IMaterial[];
  85862. /**
  85863. * An array of meshes. A mesh is a set of primitives to be rendered
  85864. */
  85865. meshes?: IMesh[];
  85866. /**
  85867. * An array of nodes
  85868. */
  85869. nodes?: INode[];
  85870. /**
  85871. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85872. */
  85873. samplers?: ISampler[];
  85874. /**
  85875. * The index of the default scene
  85876. */
  85877. scene?: number;
  85878. /**
  85879. * An array of scenes
  85880. */
  85881. scenes?: IScene[];
  85882. /**
  85883. * An array of skins. A skin is defined by joints and matrices
  85884. */
  85885. skins?: ISkin[];
  85886. /**
  85887. * An array of textures
  85888. */
  85889. textures?: ITexture[];
  85890. }
  85891. /**
  85892. * The glTF validation results
  85893. * @ignore
  85894. */
  85895. interface IGLTFValidationResults {
  85896. info: {
  85897. generator: string;
  85898. hasAnimations: boolean;
  85899. hasDefaultScene: boolean;
  85900. hasMaterials: boolean;
  85901. hasMorphTargets: boolean;
  85902. hasSkins: boolean;
  85903. hasTextures: boolean;
  85904. maxAttributesUsed: number;
  85905. primitivesCount: number
  85906. };
  85907. issues: {
  85908. messages: Array<string>;
  85909. numErrors: number;
  85910. numHints: number;
  85911. numInfos: number;
  85912. numWarnings: number;
  85913. truncated: boolean
  85914. };
  85915. mimeType: string;
  85916. uri: string;
  85917. validatedAt: string;
  85918. validatorVersion: string;
  85919. }
  85920. /**
  85921. * The glTF validation options
  85922. */
  85923. interface IGLTFValidationOptions {
  85924. /** Uri to use */
  85925. uri?: string;
  85926. /** Function used to load external resources */
  85927. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85928. /** Boolean indicating that we need to validate accessor data */
  85929. validateAccessorData?: boolean;
  85930. /** max number of issues allowed */
  85931. maxIssues?: number;
  85932. /** Ignored issues */
  85933. ignoredIssues?: Array<string>;
  85934. /** Value to override severy settings */
  85935. severityOverrides?: Object;
  85936. }
  85937. /**
  85938. * The glTF validator object
  85939. * @ignore
  85940. */
  85941. interface IGLTFValidator {
  85942. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85943. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85944. }
  85945. /**
  85946. * Interfaces from the EXT_lights_image_based extension
  85947. */
  85948. /** @hidden */
  85949. interface IEXTLightsImageBased_LightReferenceImageBased {
  85950. light: number;
  85951. }
  85952. /** @hidden */
  85953. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85954. intensity: number;
  85955. rotation: number[];
  85956. specularImageSize: number;
  85957. specularImages: number[][];
  85958. irradianceCoefficients: number[][];
  85959. }
  85960. /** @hidden */
  85961. interface IEXTLightsImageBased {
  85962. lights: IEXTLightsImageBased_LightImageBased[];
  85963. }
  85964. /**
  85965. * Interfaces from the EXT_mesh_gpu_instancing extension
  85966. * !!! Experimental Extension Subject to Changes !!!
  85967. */
  85968. /** @hidden */
  85969. interface IEXTMeshGpuInstancing {
  85970. mesh?: number;
  85971. attributes: { [name: string]: number };
  85972. }
  85973. /**
  85974. * Interfaces from the KHR_draco_mesh_compression extension
  85975. */
  85976. /** @hidden */
  85977. interface IKHRDracoMeshCompression {
  85978. bufferView: number;
  85979. attributes: { [name: string]: number };
  85980. }
  85981. /**
  85982. * Interfaces from the KHR_lights_punctual extension
  85983. */
  85984. /** @hidden */
  85985. const enum IKHRLightsPunctual_LightType {
  85986. DIRECTIONAL = "directional",
  85987. POINT = "point",
  85988. SPOT = "spot"
  85989. }
  85990. /** @hidden */
  85991. interface IKHRLightsPunctual_LightReference {
  85992. light: number;
  85993. }
  85994. /** @hidden */
  85995. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85996. type: IKHRLightsPunctual_LightType;
  85997. color?: number[];
  85998. intensity?: number;
  85999. range?: number;
  86000. spot?: {
  86001. innerConeAngle?: number;
  86002. outerConeAngle?: number;
  86003. };
  86004. }
  86005. /** @hidden */
  86006. interface IKHRLightsPunctual {
  86007. lights: IKHRLightsPunctual_Light[];
  86008. }
  86009. /**
  86010. * Interfaces from the KHR_materials_clearcoat extension
  86011. * !!! Experimental Extension Subject to Changes !!!
  86012. */
  86013. /** @hidden */
  86014. interface IKHRMaterialsClearcoat {
  86015. clearcoatFactor: number;
  86016. clearcoatTexture: ITextureInfo;
  86017. clearcoatRoughnessFactor: number;
  86018. clearcoatRoughnessTexture: ITextureInfo;
  86019. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86020. }
  86021. /**
  86022. * Interfaces from the KHR_materials_ior extension
  86023. * !!! Experimental Extension Subject to Changes !!!
  86024. */
  86025. /** @hidden */
  86026. interface IKHRMaterialsIor {
  86027. ior: number;
  86028. }
  86029. /**
  86030. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86031. */
  86032. /** @hidden */
  86033. interface IKHRMaterialsPbrSpecularGlossiness {
  86034. diffuseFactor: number[];
  86035. diffuseTexture: ITextureInfo;
  86036. specularFactor: number[];
  86037. glossinessFactor: number;
  86038. specularGlossinessTexture: ITextureInfo;
  86039. }
  86040. /**
  86041. * Interfaces from the KHR_materials_sheen extension
  86042. * !!! Experimental Extension Subject to Changes !!!
  86043. */
  86044. /** @hidden */
  86045. interface IKHRMaterialsSheen {
  86046. sheenColorFactor?: number[];
  86047. sheenColorTexture?: ITextureInfo;
  86048. sheenRoughnessFactor?: number;
  86049. sheenRoughnessTexture?: ITextureInfo;
  86050. }
  86051. /**
  86052. * Interfaces from the KHR_materials_specular extension
  86053. * !!! Experimental Extension Subject to Changes !!!
  86054. */
  86055. /** @hidden */
  86056. interface IKHRMaterialsSpecular {
  86057. specularFactor: number;
  86058. specularColorFactor: number[];
  86059. specularTexture: ITextureInfo;
  86060. }
  86061. /**
  86062. * Interfaces from the KHR_materials_transmission extension
  86063. * !!! Experimental Extension Subject to Changes !!!
  86064. */
  86065. /** @hidden */
  86066. interface IKHRMaterialsTransmission {
  86067. transmissionFactor?: number;
  86068. transmissionTexture?: ITextureInfo;
  86069. }
  86070. /**
  86071. * Interfaces from the KHR_materials_variants extension
  86072. * !!! Experimental Extension Subject to Changes !!!
  86073. */
  86074. /** @hidden */
  86075. interface IKHRMaterialVariants_Mapping extends IProperty {
  86076. mappings: Array<{
  86077. variants: number[];
  86078. material: number;
  86079. }>;
  86080. }
  86081. /** @hidden */
  86082. interface IKHRMaterialVariants_Variant extends IProperty {
  86083. name: string;
  86084. }
  86085. /** @hidden */
  86086. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86087. variants: Array<IKHRMaterialVariants_Variant>;
  86088. }
  86089. /**
  86090. * Interfaces from the KHR_texture_basisu extension
  86091. * !!! Experimental Extension Subject to Changes !!!
  86092. */
  86093. /** @hidden */
  86094. interface IKHRTextureBasisU {
  86095. source: number;
  86096. }
  86097. /**
  86098. * Interfaces from the EXT_texture_webp extension
  86099. */
  86100. /** @hidden */
  86101. interface IEXTTextureWebP {
  86102. source: number;
  86103. }
  86104. /**
  86105. * Interfaces from the KHR_texture_transform extension
  86106. */
  86107. /** @hidden */
  86108. interface IKHRTextureTransform {
  86109. offset?: number[];
  86110. rotation?: number;
  86111. scale?: number[];
  86112. texCoord?: number;
  86113. }
  86114. /**
  86115. * Interfaces from the KHR_xmp extension
  86116. * !!! Experimental Extension Subject to Changes !!!
  86117. */
  86118. /** @hidden */
  86119. interface IKHRXmp_Data {
  86120. [key: string]: unknown;
  86121. }
  86122. /** @hidden */
  86123. interface IKHRXmp_Gltf {
  86124. packets: IKHRXmp_Data[];
  86125. }
  86126. /** @hidden */
  86127. interface IKHRXmp_Node {
  86128. packet: number;
  86129. }
  86130. /**
  86131. * Interfaces from the MSFT_audio_emitter extension
  86132. */
  86133. /** @hidden */
  86134. interface IMSFTAudioEmitter_ClipReference {
  86135. clip: number;
  86136. weight?: number;
  86137. }
  86138. /** @hidden */
  86139. interface IMSFTAudioEmitter_EmittersReference {
  86140. emitters: number[];
  86141. }
  86142. /** @hidden */
  86143. const enum IMSFTAudioEmitter_DistanceModel {
  86144. linear = "linear",
  86145. inverse = "inverse",
  86146. exponential = "exponential",
  86147. }
  86148. /** @hidden */
  86149. interface IMSFTAudioEmitter_Emitter {
  86150. name?: string;
  86151. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86152. refDistance?: number;
  86153. maxDistance?: number;
  86154. rolloffFactor?: number;
  86155. innerAngle?: number;
  86156. outerAngle?: number;
  86157. loop?: boolean;
  86158. volume?: number;
  86159. clips: IMSFTAudioEmitter_ClipReference[];
  86160. }
  86161. /** @hidden */
  86162. const enum IMSFTAudioEmitter_AudioMimeType {
  86163. WAV = "audio/wav",
  86164. }
  86165. /** @hidden */
  86166. interface IMSFTAudioEmitter_Clip extends IProperty {
  86167. uri?: string;
  86168. bufferView?: number;
  86169. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86170. }
  86171. /** @hidden */
  86172. const enum IMSFTAudioEmitter_AnimationEventAction {
  86173. play = "play",
  86174. pause = "pause",
  86175. stop = "stop",
  86176. }
  86177. /** @hidden */
  86178. interface IMSFTAudioEmitter_AnimationEvent {
  86179. action: IMSFTAudioEmitter_AnimationEventAction;
  86180. emitter: number;
  86181. time: number;
  86182. startOffset?: number;
  86183. }
  86184. /**
  86185. * Interfaces from the MSFT_lod extension
  86186. */
  86187. /** @hidden */
  86188. interface IMSFTLOD {
  86189. ids: number[];
  86190. }
  86191. }
  86192. declare module BABYLON {
  86193. /** @hidden */
  86194. export var cellPixelShader: {
  86195. name: string;
  86196. shader: string;
  86197. };
  86198. }
  86199. declare module BABYLON {
  86200. /** @hidden */
  86201. export var cellVertexShader: {
  86202. name: string;
  86203. shader: string;
  86204. };
  86205. }
  86206. declare module BABYLON {
  86207. export class CellMaterial extends BABYLON.PushMaterial {
  86208. private _diffuseTexture;
  86209. diffuseTexture: BABYLON.BaseTexture;
  86210. diffuseColor: BABYLON.Color3;
  86211. _computeHighLevel: boolean;
  86212. computeHighLevel: boolean;
  86213. private _disableLighting;
  86214. disableLighting: boolean;
  86215. private _maxSimultaneousLights;
  86216. maxSimultaneousLights: number;
  86217. constructor(name: string, scene: BABYLON.Scene);
  86218. needAlphaBlending(): boolean;
  86219. needAlphaTesting(): boolean;
  86220. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86221. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86222. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86223. getAnimatables(): BABYLON.IAnimatable[];
  86224. getActiveTextures(): BABYLON.BaseTexture[];
  86225. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86226. dispose(forceDisposeEffect?: boolean): void;
  86227. getClassName(): string;
  86228. clone(name: string): CellMaterial;
  86229. serialize(): any;
  86230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86231. }
  86232. }
  86233. declare module BABYLON {
  86234. export class CustomShaderStructure {
  86235. FragmentStore: string;
  86236. VertexStore: string;
  86237. constructor();
  86238. }
  86239. export class ShaderSpecialParts {
  86240. constructor();
  86241. Fragment_Begin: string;
  86242. Fragment_Definitions: string;
  86243. Fragment_MainBegin: string;
  86244. Fragment_Custom_Diffuse: string;
  86245. Fragment_Before_Lights: string;
  86246. Fragment_Before_Fog: string;
  86247. Fragment_Custom_Alpha: string;
  86248. Fragment_Before_FragColor: string;
  86249. Vertex_Begin: string;
  86250. Vertex_Definitions: string;
  86251. Vertex_MainBegin: string;
  86252. Vertex_Before_PositionUpdated: string;
  86253. Vertex_Before_NormalUpdated: string;
  86254. Vertex_After_WorldPosComputed: string;
  86255. Vertex_MainEnd: string;
  86256. }
  86257. export class CustomMaterial extends BABYLON.StandardMaterial {
  86258. static ShaderIndexer: number;
  86259. CustomParts: ShaderSpecialParts;
  86260. _isCreatedShader: boolean;
  86261. _createdShaderName: string;
  86262. _customUniform: string[];
  86263. _newUniforms: string[];
  86264. _newUniformInstances: {
  86265. [name: string]: any;
  86266. };
  86267. _newSamplerInstances: {
  86268. [name: string]: BABYLON.Texture;
  86269. };
  86270. _customAttributes: string[];
  86271. FragmentShader: string;
  86272. VertexShader: string;
  86273. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86274. ReviewUniform(name: string, arr: string[]): string[];
  86275. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86276. constructor(name: string, scene: BABYLON.Scene);
  86277. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86278. AddAttribute(name: string): CustomMaterial;
  86279. Fragment_Begin(shaderPart: string): CustomMaterial;
  86280. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86281. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86282. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86283. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86284. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86285. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86286. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86287. Vertex_Begin(shaderPart: string): CustomMaterial;
  86288. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86289. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86290. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86291. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86292. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86293. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86294. }
  86295. }
  86296. declare module BABYLON {
  86297. export class ShaderAlebdoParts {
  86298. constructor();
  86299. Fragment_Begin: string;
  86300. Fragment_Definitions: string;
  86301. Fragment_MainBegin: string;
  86302. Fragment_Custom_Albedo: string;
  86303. Fragment_Before_Lights: string;
  86304. Fragment_Custom_MetallicRoughness: string;
  86305. Fragment_Custom_MicroSurface: string;
  86306. Fragment_Before_Fog: string;
  86307. Fragment_Custom_Alpha: string;
  86308. Fragment_Before_FragColor: string;
  86309. Vertex_Begin: string;
  86310. Vertex_Definitions: string;
  86311. Vertex_MainBegin: string;
  86312. Vertex_Before_PositionUpdated: string;
  86313. Vertex_Before_NormalUpdated: string;
  86314. Vertex_After_WorldPosComputed: string;
  86315. Vertex_MainEnd: string;
  86316. }
  86317. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86318. static ShaderIndexer: number;
  86319. CustomParts: ShaderAlebdoParts;
  86320. _isCreatedShader: boolean;
  86321. _createdShaderName: string;
  86322. _customUniform: string[];
  86323. _newUniforms: string[];
  86324. _newUniformInstances: {
  86325. [name: string]: any;
  86326. };
  86327. _newSamplerInstances: {
  86328. [name: string]: BABYLON.Texture;
  86329. };
  86330. _customAttributes: string[];
  86331. FragmentShader: string;
  86332. VertexShader: string;
  86333. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86334. ReviewUniform(name: string, arr: string[]): string[];
  86335. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86336. constructor(name: string, scene: BABYLON.Scene);
  86337. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86338. AddAttribute(name: string): PBRCustomMaterial;
  86339. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86340. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86341. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86342. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86343. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86344. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86345. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86346. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86347. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86348. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86349. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86350. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86351. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86352. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86353. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86354. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86355. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86356. }
  86357. }
  86358. declare module BABYLON {
  86359. /** @hidden */
  86360. export var firePixelShader: {
  86361. name: string;
  86362. shader: string;
  86363. };
  86364. }
  86365. declare module BABYLON {
  86366. /** @hidden */
  86367. export var fireVertexShader: {
  86368. name: string;
  86369. shader: string;
  86370. };
  86371. }
  86372. declare module BABYLON {
  86373. export class FireMaterial extends BABYLON.PushMaterial {
  86374. private _diffuseTexture;
  86375. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86376. private _distortionTexture;
  86377. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86378. private _opacityTexture;
  86379. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86380. diffuseColor: BABYLON.Color3;
  86381. speed: number;
  86382. private _scaledDiffuse;
  86383. private _lastTime;
  86384. constructor(name: string, scene: BABYLON.Scene);
  86385. needAlphaBlending(): boolean;
  86386. needAlphaTesting(): boolean;
  86387. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86388. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86389. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86390. getAnimatables(): BABYLON.IAnimatable[];
  86391. getActiveTextures(): BABYLON.BaseTexture[];
  86392. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86393. getClassName(): string;
  86394. dispose(forceDisposeEffect?: boolean): void;
  86395. clone(name: string): FireMaterial;
  86396. serialize(): any;
  86397. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86398. }
  86399. }
  86400. declare module BABYLON {
  86401. /** @hidden */
  86402. export var furPixelShader: {
  86403. name: string;
  86404. shader: string;
  86405. };
  86406. }
  86407. declare module BABYLON {
  86408. /** @hidden */
  86409. export var furVertexShader: {
  86410. name: string;
  86411. shader: string;
  86412. };
  86413. }
  86414. declare module BABYLON {
  86415. export class FurMaterial extends BABYLON.PushMaterial {
  86416. private _diffuseTexture;
  86417. diffuseTexture: BABYLON.BaseTexture;
  86418. private _heightTexture;
  86419. heightTexture: BABYLON.BaseTexture;
  86420. diffuseColor: BABYLON.Color3;
  86421. furLength: number;
  86422. furAngle: number;
  86423. furColor: BABYLON.Color3;
  86424. furOffset: number;
  86425. furSpacing: number;
  86426. furGravity: BABYLON.Vector3;
  86427. furSpeed: number;
  86428. furDensity: number;
  86429. furOcclusion: number;
  86430. furTexture: BABYLON.DynamicTexture;
  86431. private _disableLighting;
  86432. disableLighting: boolean;
  86433. private _maxSimultaneousLights;
  86434. maxSimultaneousLights: number;
  86435. highLevelFur: boolean;
  86436. _meshes: BABYLON.AbstractMesh[];
  86437. private _furTime;
  86438. constructor(name: string, scene: BABYLON.Scene);
  86439. get furTime(): number;
  86440. set furTime(furTime: number);
  86441. needAlphaBlending(): boolean;
  86442. needAlphaTesting(): boolean;
  86443. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86444. updateFur(): void;
  86445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86446. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86447. getAnimatables(): BABYLON.IAnimatable[];
  86448. getActiveTextures(): BABYLON.BaseTexture[];
  86449. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86450. dispose(forceDisposeEffect?: boolean): void;
  86451. clone(name: string): FurMaterial;
  86452. serialize(): any;
  86453. getClassName(): string;
  86454. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86455. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86456. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /** @hidden */
  86461. export var gradientPixelShader: {
  86462. name: string;
  86463. shader: string;
  86464. };
  86465. }
  86466. declare module BABYLON {
  86467. /** @hidden */
  86468. export var gradientVertexShader: {
  86469. name: string;
  86470. shader: string;
  86471. };
  86472. }
  86473. declare module BABYLON {
  86474. export class GradientMaterial extends BABYLON.PushMaterial {
  86475. private _maxSimultaneousLights;
  86476. maxSimultaneousLights: number;
  86477. topColor: BABYLON.Color3;
  86478. topColorAlpha: number;
  86479. bottomColor: BABYLON.Color3;
  86480. bottomColorAlpha: number;
  86481. offset: number;
  86482. scale: number;
  86483. smoothness: number;
  86484. private _disableLighting;
  86485. disableLighting: boolean;
  86486. constructor(name: string, scene: BABYLON.Scene);
  86487. needAlphaBlending(): boolean;
  86488. needAlphaTesting(): boolean;
  86489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86492. getAnimatables(): BABYLON.IAnimatable[];
  86493. dispose(forceDisposeEffect?: boolean): void;
  86494. clone(name: string): GradientMaterial;
  86495. serialize(): any;
  86496. getClassName(): string;
  86497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86498. }
  86499. }
  86500. declare module BABYLON {
  86501. /** @hidden */
  86502. export var gridPixelShader: {
  86503. name: string;
  86504. shader: string;
  86505. };
  86506. }
  86507. declare module BABYLON {
  86508. /** @hidden */
  86509. export var gridVertexShader: {
  86510. name: string;
  86511. shader: string;
  86512. };
  86513. }
  86514. declare module BABYLON {
  86515. /**
  86516. * The grid materials allows you to wrap any shape with a grid.
  86517. * Colors are customizable.
  86518. */
  86519. export class GridMaterial extends BABYLON.PushMaterial {
  86520. /**
  86521. * Main color of the grid (e.g. between lines)
  86522. */
  86523. mainColor: BABYLON.Color3;
  86524. /**
  86525. * Color of the grid lines.
  86526. */
  86527. lineColor: BABYLON.Color3;
  86528. /**
  86529. * The scale of the grid compared to unit.
  86530. */
  86531. gridRatio: number;
  86532. /**
  86533. * Allows setting an offset for the grid lines.
  86534. */
  86535. gridOffset: BABYLON.Vector3;
  86536. /**
  86537. * The frequency of thicker lines.
  86538. */
  86539. majorUnitFrequency: number;
  86540. /**
  86541. * The visibility of minor units in the grid.
  86542. */
  86543. minorUnitVisibility: number;
  86544. /**
  86545. * The grid opacity outside of the lines.
  86546. */
  86547. opacity: number;
  86548. /**
  86549. * Determine RBG output is premultiplied by alpha value.
  86550. */
  86551. preMultiplyAlpha: boolean;
  86552. private _opacityTexture;
  86553. opacityTexture: BABYLON.BaseTexture;
  86554. private _gridControl;
  86555. /**
  86556. * constructor
  86557. * @param name The name given to the material in order to identify it afterwards.
  86558. * @param scene The scene the material is used in.
  86559. */
  86560. constructor(name: string, scene: BABYLON.Scene);
  86561. /**
  86562. * Returns wehter or not the grid requires alpha blending.
  86563. */
  86564. needAlphaBlending(): boolean;
  86565. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86566. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86567. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86568. /**
  86569. * Dispose the material and its associated resources.
  86570. * @param forceDisposeEffect will also dispose the used effect when true
  86571. */
  86572. dispose(forceDisposeEffect?: boolean): void;
  86573. clone(name: string): GridMaterial;
  86574. serialize(): any;
  86575. getClassName(): string;
  86576. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86577. }
  86578. }
  86579. declare module BABYLON {
  86580. /** @hidden */
  86581. export var lavaPixelShader: {
  86582. name: string;
  86583. shader: string;
  86584. };
  86585. }
  86586. declare module BABYLON {
  86587. /** @hidden */
  86588. export var lavaVertexShader: {
  86589. name: string;
  86590. shader: string;
  86591. };
  86592. }
  86593. declare module BABYLON {
  86594. export class LavaMaterial extends BABYLON.PushMaterial {
  86595. private _diffuseTexture;
  86596. diffuseTexture: BABYLON.BaseTexture;
  86597. noiseTexture: BABYLON.BaseTexture;
  86598. fogColor: BABYLON.Color3;
  86599. speed: number;
  86600. movingSpeed: number;
  86601. lowFrequencySpeed: number;
  86602. fogDensity: number;
  86603. private _lastTime;
  86604. diffuseColor: BABYLON.Color3;
  86605. private _disableLighting;
  86606. disableLighting: boolean;
  86607. private _unlit;
  86608. unlit: boolean;
  86609. private _maxSimultaneousLights;
  86610. maxSimultaneousLights: number;
  86611. private _scaledDiffuse;
  86612. constructor(name: string, scene: BABYLON.Scene);
  86613. needAlphaBlending(): boolean;
  86614. needAlphaTesting(): boolean;
  86615. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86616. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86617. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86618. getAnimatables(): BABYLON.IAnimatable[];
  86619. getActiveTextures(): BABYLON.BaseTexture[];
  86620. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86621. dispose(forceDisposeEffect?: boolean): void;
  86622. clone(name: string): LavaMaterial;
  86623. serialize(): any;
  86624. getClassName(): string;
  86625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86626. }
  86627. }
  86628. declare module BABYLON {
  86629. /** @hidden */
  86630. export var mixPixelShader: {
  86631. name: string;
  86632. shader: string;
  86633. };
  86634. }
  86635. declare module BABYLON {
  86636. /** @hidden */
  86637. export var mixVertexShader: {
  86638. name: string;
  86639. shader: string;
  86640. };
  86641. }
  86642. declare module BABYLON {
  86643. export class MixMaterial extends BABYLON.PushMaterial {
  86644. /**
  86645. * Mix textures
  86646. */
  86647. private _mixTexture1;
  86648. mixTexture1: BABYLON.BaseTexture;
  86649. private _mixTexture2;
  86650. mixTexture2: BABYLON.BaseTexture;
  86651. /**
  86652. * Diffuse textures
  86653. */
  86654. private _diffuseTexture1;
  86655. diffuseTexture1: BABYLON.Texture;
  86656. private _diffuseTexture2;
  86657. diffuseTexture2: BABYLON.Texture;
  86658. private _diffuseTexture3;
  86659. diffuseTexture3: BABYLON.Texture;
  86660. private _diffuseTexture4;
  86661. diffuseTexture4: BABYLON.Texture;
  86662. private _diffuseTexture5;
  86663. diffuseTexture5: BABYLON.Texture;
  86664. private _diffuseTexture6;
  86665. diffuseTexture6: BABYLON.Texture;
  86666. private _diffuseTexture7;
  86667. diffuseTexture7: BABYLON.Texture;
  86668. private _diffuseTexture8;
  86669. diffuseTexture8: BABYLON.Texture;
  86670. /**
  86671. * Uniforms
  86672. */
  86673. diffuseColor: BABYLON.Color3;
  86674. specularColor: BABYLON.Color3;
  86675. specularPower: number;
  86676. private _disableLighting;
  86677. disableLighting: boolean;
  86678. private _maxSimultaneousLights;
  86679. maxSimultaneousLights: number;
  86680. constructor(name: string, scene: BABYLON.Scene);
  86681. needAlphaBlending(): boolean;
  86682. needAlphaTesting(): boolean;
  86683. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86684. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86685. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86686. getAnimatables(): BABYLON.IAnimatable[];
  86687. getActiveTextures(): BABYLON.BaseTexture[];
  86688. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86689. dispose(forceDisposeEffect?: boolean): void;
  86690. clone(name: string): MixMaterial;
  86691. serialize(): any;
  86692. getClassName(): string;
  86693. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86694. }
  86695. }
  86696. declare module BABYLON {
  86697. /** @hidden */
  86698. export var normalPixelShader: {
  86699. name: string;
  86700. shader: string;
  86701. };
  86702. }
  86703. declare module BABYLON {
  86704. /** @hidden */
  86705. export var normalVertexShader: {
  86706. name: string;
  86707. shader: string;
  86708. };
  86709. }
  86710. declare module BABYLON {
  86711. export class NormalMaterial extends BABYLON.PushMaterial {
  86712. private _diffuseTexture;
  86713. diffuseTexture: BABYLON.BaseTexture;
  86714. diffuseColor: BABYLON.Color3;
  86715. private _disableLighting;
  86716. disableLighting: boolean;
  86717. private _maxSimultaneousLights;
  86718. maxSimultaneousLights: number;
  86719. constructor(name: string, scene: BABYLON.Scene);
  86720. needAlphaBlending(): boolean;
  86721. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86722. needAlphaTesting(): boolean;
  86723. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86724. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86725. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86726. getAnimatables(): BABYLON.IAnimatable[];
  86727. getActiveTextures(): BABYLON.BaseTexture[];
  86728. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86729. dispose(forceDisposeEffect?: boolean): void;
  86730. clone(name: string): NormalMaterial;
  86731. serialize(): any;
  86732. getClassName(): string;
  86733. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86734. }
  86735. }
  86736. declare module BABYLON {
  86737. /** @hidden */
  86738. export var shadowOnlyPixelShader: {
  86739. name: string;
  86740. shader: string;
  86741. };
  86742. }
  86743. declare module BABYLON {
  86744. /** @hidden */
  86745. export var shadowOnlyVertexShader: {
  86746. name: string;
  86747. shader: string;
  86748. };
  86749. }
  86750. declare module BABYLON {
  86751. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86752. private _activeLight;
  86753. private _needAlphaBlending;
  86754. constructor(name: string, scene: BABYLON.Scene);
  86755. shadowColor: BABYLON.Color3;
  86756. needAlphaBlending(): boolean;
  86757. needAlphaTesting(): boolean;
  86758. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86759. get activeLight(): BABYLON.IShadowLight;
  86760. set activeLight(light: BABYLON.IShadowLight);
  86761. private _getFirstShadowLightForMesh;
  86762. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86763. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86764. clone(name: string): ShadowOnlyMaterial;
  86765. serialize(): any;
  86766. getClassName(): string;
  86767. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86768. }
  86769. }
  86770. declare module BABYLON {
  86771. /** @hidden */
  86772. export var simplePixelShader: {
  86773. name: string;
  86774. shader: string;
  86775. };
  86776. }
  86777. declare module BABYLON {
  86778. /** @hidden */
  86779. export var simpleVertexShader: {
  86780. name: string;
  86781. shader: string;
  86782. };
  86783. }
  86784. declare module BABYLON {
  86785. export class SimpleMaterial extends BABYLON.PushMaterial {
  86786. private _diffuseTexture;
  86787. diffuseTexture: BABYLON.BaseTexture;
  86788. diffuseColor: BABYLON.Color3;
  86789. private _disableLighting;
  86790. disableLighting: boolean;
  86791. private _maxSimultaneousLights;
  86792. maxSimultaneousLights: number;
  86793. constructor(name: string, scene: BABYLON.Scene);
  86794. needAlphaBlending(): boolean;
  86795. needAlphaTesting(): boolean;
  86796. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86799. getAnimatables(): BABYLON.IAnimatable[];
  86800. getActiveTextures(): BABYLON.BaseTexture[];
  86801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86802. dispose(forceDisposeEffect?: boolean): void;
  86803. clone(name: string): SimpleMaterial;
  86804. serialize(): any;
  86805. getClassName(): string;
  86806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86807. }
  86808. }
  86809. declare module BABYLON {
  86810. /** @hidden */
  86811. export var skyPixelShader: {
  86812. name: string;
  86813. shader: string;
  86814. };
  86815. }
  86816. declare module BABYLON {
  86817. /** @hidden */
  86818. export var skyVertexShader: {
  86819. name: string;
  86820. shader: string;
  86821. };
  86822. }
  86823. declare module BABYLON {
  86824. /**
  86825. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86826. * @see https://doc.babylonjs.com/extensions/sky
  86827. */
  86828. export class SkyMaterial extends BABYLON.PushMaterial {
  86829. /**
  86830. * Defines the overall luminance of sky in interval ]0, 1[.
  86831. */
  86832. luminance: number;
  86833. /**
  86834. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86835. */
  86836. turbidity: number;
  86837. /**
  86838. * Defines the sky appearance (light intensity).
  86839. */
  86840. rayleigh: number;
  86841. /**
  86842. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86843. */
  86844. mieCoefficient: number;
  86845. /**
  86846. * Defines the amount of haze particles following the Mie scattering theory.
  86847. */
  86848. mieDirectionalG: number;
  86849. /**
  86850. * Defines the distance of the sun according to the active scene camera.
  86851. */
  86852. distance: number;
  86853. /**
  86854. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86855. * "inclined".
  86856. */
  86857. inclination: number;
  86858. /**
  86859. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86860. * an object direction and a reference direction.
  86861. */
  86862. azimuth: number;
  86863. /**
  86864. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86865. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86866. */
  86867. sunPosition: BABYLON.Vector3;
  86868. /**
  86869. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86870. * .sunPosition property.
  86871. */
  86872. useSunPosition: boolean;
  86873. /**
  86874. * Defines an offset vector used to get a horizon offset.
  86875. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86876. */
  86877. cameraOffset: BABYLON.Vector3;
  86878. private _cameraPosition;
  86879. /**
  86880. * Instantiates a new sky material.
  86881. * This material allows to create dynamic and texture free
  86882. * effects for skyboxes by taking care of the atmosphere state.
  86883. * @see https://doc.babylonjs.com/extensions/sky
  86884. * @param name Define the name of the material in the scene
  86885. * @param scene Define the scene the material belong to
  86886. */
  86887. constructor(name: string, scene: BABYLON.Scene);
  86888. /**
  86889. * Specifies if the material will require alpha blending
  86890. * @returns a boolean specifying if alpha blending is needed
  86891. */
  86892. needAlphaBlending(): boolean;
  86893. /**
  86894. * Specifies if this material should be rendered in alpha test mode
  86895. * @returns false as the sky material doesn't need alpha testing.
  86896. */
  86897. needAlphaTesting(): boolean;
  86898. /**
  86899. * Get the texture used for alpha test purpose.
  86900. * @returns null as the sky material has no texture.
  86901. */
  86902. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86903. /**
  86904. * Get if the submesh is ready to be used and all its information available.
  86905. * Child classes can use it to update shaders
  86906. * @param mesh defines the mesh to check
  86907. * @param subMesh defines which submesh to check
  86908. * @param useInstances specifies that instances should be used
  86909. * @returns a boolean indicating that the submesh is ready or not
  86910. */
  86911. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86912. /**
  86913. * Binds the submesh to this material by preparing the effect and shader to draw
  86914. * @param world defines the world transformation matrix
  86915. * @param mesh defines the mesh containing the submesh
  86916. * @param subMesh defines the submesh to bind the material to
  86917. */
  86918. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86919. /**
  86920. * Get the list of animatables in the material.
  86921. * @returns the list of animatables object used in the material
  86922. */
  86923. getAnimatables(): BABYLON.IAnimatable[];
  86924. /**
  86925. * Disposes the material
  86926. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86927. */
  86928. dispose(forceDisposeEffect?: boolean): void;
  86929. /**
  86930. * Makes a duplicate of the material, and gives it a new name
  86931. * @param name defines the new name for the duplicated material
  86932. * @returns the cloned material
  86933. */
  86934. clone(name: string): SkyMaterial;
  86935. /**
  86936. * Serializes this material in a JSON representation
  86937. * @returns the serialized material object
  86938. */
  86939. serialize(): any;
  86940. /**
  86941. * Gets the current class name of the material e.g. "SkyMaterial"
  86942. * Mainly use in serialization.
  86943. * @returns the class name
  86944. */
  86945. getClassName(): string;
  86946. /**
  86947. * Creates a sky material from parsed material data
  86948. * @param source defines the JSON representation of the material
  86949. * @param scene defines the hosting scene
  86950. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86951. * @returns a new sky material
  86952. */
  86953. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86954. }
  86955. }
  86956. declare module BABYLON {
  86957. /** @hidden */
  86958. export var terrainPixelShader: {
  86959. name: string;
  86960. shader: string;
  86961. };
  86962. }
  86963. declare module BABYLON {
  86964. /** @hidden */
  86965. export var terrainVertexShader: {
  86966. name: string;
  86967. shader: string;
  86968. };
  86969. }
  86970. declare module BABYLON {
  86971. export class TerrainMaterial extends BABYLON.PushMaterial {
  86972. private _mixTexture;
  86973. mixTexture: BABYLON.BaseTexture;
  86974. private _diffuseTexture1;
  86975. diffuseTexture1: BABYLON.Texture;
  86976. private _diffuseTexture2;
  86977. diffuseTexture2: BABYLON.Texture;
  86978. private _diffuseTexture3;
  86979. diffuseTexture3: BABYLON.Texture;
  86980. private _bumpTexture1;
  86981. bumpTexture1: BABYLON.Texture;
  86982. private _bumpTexture2;
  86983. bumpTexture2: BABYLON.Texture;
  86984. private _bumpTexture3;
  86985. bumpTexture3: BABYLON.Texture;
  86986. diffuseColor: BABYLON.Color3;
  86987. specularColor: BABYLON.Color3;
  86988. specularPower: number;
  86989. private _disableLighting;
  86990. disableLighting: boolean;
  86991. private _maxSimultaneousLights;
  86992. maxSimultaneousLights: number;
  86993. constructor(name: string, scene: BABYLON.Scene);
  86994. needAlphaBlending(): boolean;
  86995. needAlphaTesting(): boolean;
  86996. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86997. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86998. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86999. getAnimatables(): BABYLON.IAnimatable[];
  87000. getActiveTextures(): BABYLON.BaseTexture[];
  87001. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87002. dispose(forceDisposeEffect?: boolean): void;
  87003. clone(name: string): TerrainMaterial;
  87004. serialize(): any;
  87005. getClassName(): string;
  87006. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87007. }
  87008. }
  87009. declare module BABYLON {
  87010. /** @hidden */
  87011. export var triplanarPixelShader: {
  87012. name: string;
  87013. shader: string;
  87014. };
  87015. }
  87016. declare module BABYLON {
  87017. /** @hidden */
  87018. export var triplanarVertexShader: {
  87019. name: string;
  87020. shader: string;
  87021. };
  87022. }
  87023. declare module BABYLON {
  87024. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87025. mixTexture: BABYLON.BaseTexture;
  87026. private _diffuseTextureX;
  87027. diffuseTextureX: BABYLON.BaseTexture;
  87028. private _diffuseTextureY;
  87029. diffuseTextureY: BABYLON.BaseTexture;
  87030. private _diffuseTextureZ;
  87031. diffuseTextureZ: BABYLON.BaseTexture;
  87032. private _normalTextureX;
  87033. normalTextureX: BABYLON.BaseTexture;
  87034. private _normalTextureY;
  87035. normalTextureY: BABYLON.BaseTexture;
  87036. private _normalTextureZ;
  87037. normalTextureZ: BABYLON.BaseTexture;
  87038. tileSize: number;
  87039. diffuseColor: BABYLON.Color3;
  87040. specularColor: BABYLON.Color3;
  87041. specularPower: number;
  87042. private _disableLighting;
  87043. disableLighting: boolean;
  87044. private _maxSimultaneousLights;
  87045. maxSimultaneousLights: number;
  87046. constructor(name: string, scene: BABYLON.Scene);
  87047. needAlphaBlending(): boolean;
  87048. needAlphaTesting(): boolean;
  87049. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87050. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87051. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87052. getAnimatables(): BABYLON.IAnimatable[];
  87053. getActiveTextures(): BABYLON.BaseTexture[];
  87054. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87055. dispose(forceDisposeEffect?: boolean): void;
  87056. clone(name: string): TriPlanarMaterial;
  87057. serialize(): any;
  87058. getClassName(): string;
  87059. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87060. }
  87061. }
  87062. declare module BABYLON {
  87063. /** @hidden */
  87064. export var waterPixelShader: {
  87065. name: string;
  87066. shader: string;
  87067. };
  87068. }
  87069. declare module BABYLON {
  87070. /** @hidden */
  87071. export var waterVertexShader: {
  87072. name: string;
  87073. shader: string;
  87074. };
  87075. }
  87076. declare module BABYLON {
  87077. export class WaterMaterial extends BABYLON.PushMaterial {
  87078. renderTargetSize: BABYLON.Vector2;
  87079. private _bumpTexture;
  87080. bumpTexture: BABYLON.BaseTexture;
  87081. diffuseColor: BABYLON.Color3;
  87082. specularColor: BABYLON.Color3;
  87083. specularPower: number;
  87084. private _disableLighting;
  87085. disableLighting: boolean;
  87086. private _maxSimultaneousLights;
  87087. maxSimultaneousLights: number;
  87088. /**
  87089. * Defines the wind force.
  87090. */
  87091. windForce: number;
  87092. /**
  87093. * Defines the direction of the wind in the plane (X, Z).
  87094. */
  87095. windDirection: BABYLON.Vector2;
  87096. /**
  87097. * Defines the height of the waves.
  87098. */
  87099. waveHeight: number;
  87100. /**
  87101. * Defines the bump height related to the bump map.
  87102. */
  87103. bumpHeight: number;
  87104. /**
  87105. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87106. */
  87107. private _bumpSuperimpose;
  87108. bumpSuperimpose: boolean;
  87109. /**
  87110. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87111. */
  87112. private _fresnelSeparate;
  87113. fresnelSeparate: boolean;
  87114. /**
  87115. * Defines wether or not bump Wwves modify the reflection.
  87116. */
  87117. private _bumpAffectsReflection;
  87118. bumpAffectsReflection: boolean;
  87119. /**
  87120. * Defines the water color blended with the refraction (near).
  87121. */
  87122. waterColor: BABYLON.Color3;
  87123. /**
  87124. * Defines the blend factor related to the water color.
  87125. */
  87126. colorBlendFactor: number;
  87127. /**
  87128. * Defines the water color blended with the reflection (far).
  87129. */
  87130. waterColor2: BABYLON.Color3;
  87131. /**
  87132. * Defines the blend factor related to the water color (reflection, far).
  87133. */
  87134. colorBlendFactor2: number;
  87135. /**
  87136. * Defines the maximum length of a wave.
  87137. */
  87138. waveLength: number;
  87139. /**
  87140. * Defines the waves speed.
  87141. */
  87142. waveSpeed: number;
  87143. /**
  87144. * 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.
  87145. */
  87146. waveCount: number;
  87147. /**
  87148. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87149. * will avoid calculating useless pixels in the pixel shader of the water material.
  87150. */
  87151. disableClipPlane: boolean;
  87152. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87153. private _mesh;
  87154. private _refractionRTT;
  87155. private _reflectionRTT;
  87156. private _reflectionTransform;
  87157. private _lastTime;
  87158. private _lastDeltaTime;
  87159. private _useLogarithmicDepth;
  87160. private _waitingRenderList;
  87161. private _imageProcessingConfiguration;
  87162. private _imageProcessingObserver;
  87163. /**
  87164. * Gets a boolean indicating that current material needs to register RTT
  87165. */
  87166. get hasRenderTargetTextures(): boolean;
  87167. /**
  87168. * Constructor
  87169. */
  87170. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87171. get useLogarithmicDepth(): boolean;
  87172. set useLogarithmicDepth(value: boolean);
  87173. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87174. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87175. addToRenderList(node: any): void;
  87176. enableRenderTargets(enable: boolean): void;
  87177. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87178. get renderTargetsEnabled(): boolean;
  87179. needAlphaBlending(): boolean;
  87180. needAlphaTesting(): boolean;
  87181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87184. private _createRenderTargets;
  87185. getAnimatables(): BABYLON.IAnimatable[];
  87186. getActiveTextures(): BABYLON.BaseTexture[];
  87187. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87188. dispose(forceDisposeEffect?: boolean): void;
  87189. clone(name: string): WaterMaterial;
  87190. serialize(): any;
  87191. getClassName(): string;
  87192. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87193. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87194. }
  87195. }
  87196. declare module BABYLON {
  87197. /** @hidden */
  87198. export var asciiartPixelShader: {
  87199. name: string;
  87200. shader: string;
  87201. };
  87202. }
  87203. declare module BABYLON {
  87204. /**
  87205. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87206. *
  87207. * It basically takes care rendering the font front the given font size to a texture.
  87208. * This is used later on in the postprocess.
  87209. */
  87210. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87211. private _font;
  87212. private _text;
  87213. private _charSize;
  87214. /**
  87215. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87216. */
  87217. get charSize(): number;
  87218. /**
  87219. * Create a new instance of the Ascii Art FontTexture class
  87220. * @param name the name of the texture
  87221. * @param font the font to use, use the W3C CSS notation
  87222. * @param text the caracter set to use in the rendering.
  87223. * @param scene the scene that owns the texture
  87224. */
  87225. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87226. /**
  87227. * Gets the max char width of a font.
  87228. * @param font the font to use, use the W3C CSS notation
  87229. * @return the max char width
  87230. */
  87231. private getFontWidth;
  87232. /**
  87233. * Gets the max char height of a font.
  87234. * @param font the font to use, use the W3C CSS notation
  87235. * @return the max char height
  87236. */
  87237. private getFontHeight;
  87238. /**
  87239. * Clones the current AsciiArtTexture.
  87240. * @return the clone of the texture.
  87241. */
  87242. clone(): AsciiArtFontTexture;
  87243. /**
  87244. * Parses a json object representing the texture and returns an instance of it.
  87245. * @param source the source JSON representation
  87246. * @param scene the scene to create the texture for
  87247. * @return the parsed texture
  87248. */
  87249. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87250. }
  87251. /**
  87252. * Option available in the Ascii Art Post Process.
  87253. */
  87254. export interface IAsciiArtPostProcessOptions {
  87255. /**
  87256. * The font to use following the w3c font definition.
  87257. */
  87258. font?: string;
  87259. /**
  87260. * The character set to use in the postprocess.
  87261. */
  87262. characterSet?: string;
  87263. /**
  87264. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87265. * This number is defined between 0 and 1;
  87266. */
  87267. mixToTile?: number;
  87268. /**
  87269. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87270. * This number is defined between 0 and 1;
  87271. */
  87272. mixToNormal?: number;
  87273. }
  87274. /**
  87275. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87276. *
  87277. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87278. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87279. */
  87280. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87281. /**
  87282. * The font texture used to render the char in the post process.
  87283. */
  87284. private _asciiArtFontTexture;
  87285. /**
  87286. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87287. * This number is defined between 0 and 1;
  87288. */
  87289. mixToTile: number;
  87290. /**
  87291. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87292. * This number is defined between 0 and 1;
  87293. */
  87294. mixToNormal: number;
  87295. /**
  87296. * Instantiates a new Ascii Art Post Process.
  87297. * @param name the name to give to the postprocess
  87298. * @camera the camera to apply the post process to.
  87299. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87300. */
  87301. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87302. }
  87303. }
  87304. declare module BABYLON {
  87305. /** @hidden */
  87306. export var digitalrainPixelShader: {
  87307. name: string;
  87308. shader: string;
  87309. };
  87310. }
  87311. declare module BABYLON {
  87312. /**
  87313. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87314. *
  87315. * It basically takes care rendering the font front the given font size to a texture.
  87316. * This is used later on in the postprocess.
  87317. */
  87318. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87319. private _font;
  87320. private _text;
  87321. private _charSize;
  87322. /**
  87323. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87324. */
  87325. get charSize(): number;
  87326. /**
  87327. * Create a new instance of the Digital Rain FontTexture class
  87328. * @param name the name of the texture
  87329. * @param font the font to use, use the W3C CSS notation
  87330. * @param text the caracter set to use in the rendering.
  87331. * @param scene the scene that owns the texture
  87332. */
  87333. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87334. /**
  87335. * Gets the max char width of a font.
  87336. * @param font the font to use, use the W3C CSS notation
  87337. * @return the max char width
  87338. */
  87339. private getFontWidth;
  87340. /**
  87341. * Gets the max char height of a font.
  87342. * @param font the font to use, use the W3C CSS notation
  87343. * @return the max char height
  87344. */
  87345. private getFontHeight;
  87346. /**
  87347. * Clones the current DigitalRainFontTexture.
  87348. * @return the clone of the texture.
  87349. */
  87350. clone(): DigitalRainFontTexture;
  87351. /**
  87352. * Parses a json object representing the texture and returns an instance of it.
  87353. * @param source the source JSON representation
  87354. * @param scene the scene to create the texture for
  87355. * @return the parsed texture
  87356. */
  87357. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87358. }
  87359. /**
  87360. * Option available in the Digital Rain Post Process.
  87361. */
  87362. export interface IDigitalRainPostProcessOptions {
  87363. /**
  87364. * The font to use following the w3c font definition.
  87365. */
  87366. font?: string;
  87367. /**
  87368. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87369. * This number is defined between 0 and 1;
  87370. */
  87371. mixToTile?: number;
  87372. /**
  87373. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87374. * This number is defined between 0 and 1;
  87375. */
  87376. mixToNormal?: number;
  87377. }
  87378. /**
  87379. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87380. *
  87381. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87382. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87383. */
  87384. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87385. /**
  87386. * The font texture used to render the char in the post process.
  87387. */
  87388. private _digitalRainFontTexture;
  87389. /**
  87390. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87391. * This number is defined between 0 and 1;
  87392. */
  87393. mixToTile: number;
  87394. /**
  87395. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87396. * This number is defined between 0 and 1;
  87397. */
  87398. mixToNormal: number;
  87399. /**
  87400. * Instantiates a new Digital Rain Post Process.
  87401. * @param name the name to give to the postprocess
  87402. * @camera the camera to apply the post process to.
  87403. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87404. */
  87405. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87406. }
  87407. }
  87408. declare module BABYLON {
  87409. /** @hidden */
  87410. export var brickProceduralTexturePixelShader: {
  87411. name: string;
  87412. shader: string;
  87413. };
  87414. }
  87415. declare module BABYLON {
  87416. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87417. private _numberOfBricksHeight;
  87418. private _numberOfBricksWidth;
  87419. private _jointColor;
  87420. private _brickColor;
  87421. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87422. updateShaderUniforms(): void;
  87423. get numberOfBricksHeight(): number;
  87424. set numberOfBricksHeight(value: number);
  87425. get numberOfBricksWidth(): number;
  87426. set numberOfBricksWidth(value: number);
  87427. get jointColor(): BABYLON.Color3;
  87428. set jointColor(value: BABYLON.Color3);
  87429. get brickColor(): BABYLON.Color3;
  87430. set brickColor(value: BABYLON.Color3);
  87431. /**
  87432. * Serializes this brick procedural texture
  87433. * @returns a serialized brick procedural texture object
  87434. */
  87435. serialize(): any;
  87436. /**
  87437. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87438. * @param parsedTexture defines parsed texture data
  87439. * @param scene defines the current scene
  87440. * @param rootUrl defines the root URL containing brick procedural texture information
  87441. * @returns a parsed Brick Procedural BABYLON.Texture
  87442. */
  87443. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87444. }
  87445. }
  87446. declare module BABYLON {
  87447. /** @hidden */
  87448. export var cloudProceduralTexturePixelShader: {
  87449. name: string;
  87450. shader: string;
  87451. };
  87452. }
  87453. declare module BABYLON {
  87454. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87455. private _skyColor;
  87456. private _cloudColor;
  87457. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87458. updateShaderUniforms(): void;
  87459. get skyColor(): BABYLON.Color4;
  87460. set skyColor(value: BABYLON.Color4);
  87461. get cloudColor(): BABYLON.Color4;
  87462. set cloudColor(value: BABYLON.Color4);
  87463. /**
  87464. * Serializes this cloud procedural texture
  87465. * @returns a serialized cloud procedural texture object
  87466. */
  87467. serialize(): any;
  87468. /**
  87469. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87470. * @param parsedTexture defines parsed texture data
  87471. * @param scene defines the current scene
  87472. * @param rootUrl defines the root URL containing cloud procedural texture information
  87473. * @returns a parsed Cloud Procedural BABYLON.Texture
  87474. */
  87475. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87476. }
  87477. }
  87478. declare module BABYLON {
  87479. /** @hidden */
  87480. export var fireProceduralTexturePixelShader: {
  87481. name: string;
  87482. shader: string;
  87483. };
  87484. }
  87485. declare module BABYLON {
  87486. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87487. private _time;
  87488. private _speed;
  87489. private _autoGenerateTime;
  87490. private _fireColors;
  87491. private _alphaThreshold;
  87492. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87493. updateShaderUniforms(): void;
  87494. render(useCameraPostProcess?: boolean): void;
  87495. static get PurpleFireColors(): BABYLON.Color3[];
  87496. static get GreenFireColors(): BABYLON.Color3[];
  87497. static get RedFireColors(): BABYLON.Color3[];
  87498. static get BlueFireColors(): BABYLON.Color3[];
  87499. get autoGenerateTime(): boolean;
  87500. set autoGenerateTime(value: boolean);
  87501. get fireColors(): BABYLON.Color3[];
  87502. set fireColors(value: BABYLON.Color3[]);
  87503. get time(): number;
  87504. set time(value: number);
  87505. get speed(): BABYLON.Vector2;
  87506. set speed(value: BABYLON.Vector2);
  87507. get alphaThreshold(): number;
  87508. set alphaThreshold(value: number);
  87509. /**
  87510. * Serializes this fire procedural texture
  87511. * @returns a serialized fire procedural texture object
  87512. */
  87513. serialize(): any;
  87514. /**
  87515. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87516. * @param parsedTexture defines parsed texture data
  87517. * @param scene defines the current scene
  87518. * @param rootUrl defines the root URL containing fire procedural texture information
  87519. * @returns a parsed Fire Procedural BABYLON.Texture
  87520. */
  87521. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87522. }
  87523. }
  87524. declare module BABYLON {
  87525. /** @hidden */
  87526. export var grassProceduralTexturePixelShader: {
  87527. name: string;
  87528. shader: string;
  87529. };
  87530. }
  87531. declare module BABYLON {
  87532. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87533. private _grassColors;
  87534. private _groundColor;
  87535. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87536. updateShaderUniforms(): void;
  87537. get grassColors(): BABYLON.Color3[];
  87538. set grassColors(value: BABYLON.Color3[]);
  87539. get groundColor(): BABYLON.Color3;
  87540. set groundColor(value: BABYLON.Color3);
  87541. /**
  87542. * Serializes this grass procedural texture
  87543. * @returns a serialized grass procedural texture object
  87544. */
  87545. serialize(): any;
  87546. /**
  87547. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87548. * @param parsedTexture defines parsed texture data
  87549. * @param scene defines the current scene
  87550. * @param rootUrl defines the root URL containing grass procedural texture information
  87551. * @returns a parsed Grass Procedural BABYLON.Texture
  87552. */
  87553. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /** @hidden */
  87558. export var marbleProceduralTexturePixelShader: {
  87559. name: string;
  87560. shader: string;
  87561. };
  87562. }
  87563. declare module BABYLON {
  87564. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87565. private _numberOfTilesHeight;
  87566. private _numberOfTilesWidth;
  87567. private _amplitude;
  87568. private _jointColor;
  87569. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87570. updateShaderUniforms(): void;
  87571. get numberOfTilesHeight(): number;
  87572. set numberOfTilesHeight(value: number);
  87573. get amplitude(): number;
  87574. set amplitude(value: number);
  87575. get numberOfTilesWidth(): number;
  87576. set numberOfTilesWidth(value: number);
  87577. get jointColor(): BABYLON.Color3;
  87578. set jointColor(value: BABYLON.Color3);
  87579. /**
  87580. * Serializes this marble procedural texture
  87581. * @returns a serialized marble procedural texture object
  87582. */
  87583. serialize(): any;
  87584. /**
  87585. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87586. * @param parsedTexture defines parsed texture data
  87587. * @param scene defines the current scene
  87588. * @param rootUrl defines the root URL containing marble procedural texture information
  87589. * @returns a parsed Marble Procedural BABYLON.Texture
  87590. */
  87591. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87592. }
  87593. }
  87594. declare module BABYLON {
  87595. /** @hidden */
  87596. export var normalMapProceduralTexturePixelShader: {
  87597. name: string;
  87598. shader: string;
  87599. };
  87600. }
  87601. declare module BABYLON {
  87602. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87603. private _baseTexture;
  87604. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87605. updateShaderUniforms(): void;
  87606. render(useCameraPostProcess?: boolean): void;
  87607. resize(size: any, generateMipMaps: any): void;
  87608. get baseTexture(): BABYLON.Texture;
  87609. set baseTexture(texture: BABYLON.Texture);
  87610. /**
  87611. * Serializes this normal map procedural texture
  87612. * @returns a serialized normal map procedural texture object
  87613. */
  87614. serialize(): any;
  87615. /**
  87616. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87617. * @param parsedTexture defines parsed texture data
  87618. * @param scene defines the current scene
  87619. * @param rootUrl defines the root URL containing normal map procedural texture information
  87620. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87621. */
  87622. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87623. }
  87624. }
  87625. declare module BABYLON {
  87626. /** @hidden */
  87627. export var perlinNoiseProceduralTexturePixelShader: {
  87628. name: string;
  87629. shader: string;
  87630. };
  87631. }
  87632. declare module BABYLON {
  87633. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87634. time: number;
  87635. timeScale: number;
  87636. translationSpeed: number;
  87637. private _currentTranslation;
  87638. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87639. updateShaderUniforms(): void;
  87640. render(useCameraPostProcess?: boolean): void;
  87641. resize(size: any, generateMipMaps: any): void;
  87642. /**
  87643. * Serializes this perlin noise procedural texture
  87644. * @returns a serialized perlin noise procedural texture object
  87645. */
  87646. serialize(): any;
  87647. /**
  87648. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87649. * @param parsedTexture defines parsed texture data
  87650. * @param scene defines the current scene
  87651. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87652. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87653. */
  87654. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87655. }
  87656. }
  87657. declare module BABYLON {
  87658. /** @hidden */
  87659. export var roadProceduralTexturePixelShader: {
  87660. name: string;
  87661. shader: string;
  87662. };
  87663. }
  87664. declare module BABYLON {
  87665. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87666. private _roadColor;
  87667. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87668. updateShaderUniforms(): void;
  87669. get roadColor(): BABYLON.Color3;
  87670. set roadColor(value: BABYLON.Color3);
  87671. /**
  87672. * Serializes this road procedural texture
  87673. * @returns a serialized road procedural texture object
  87674. */
  87675. serialize(): any;
  87676. /**
  87677. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87678. * @param parsedTexture defines parsed texture data
  87679. * @param scene defines the current scene
  87680. * @param rootUrl defines the root URL containing road procedural texture information
  87681. * @returns a parsed Road Procedural BABYLON.Texture
  87682. */
  87683. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87684. }
  87685. }
  87686. declare module BABYLON {
  87687. /** @hidden */
  87688. export var starfieldProceduralTexturePixelShader: {
  87689. name: string;
  87690. shader: string;
  87691. };
  87692. }
  87693. declare module BABYLON {
  87694. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87695. private _time;
  87696. private _alpha;
  87697. private _beta;
  87698. private _zoom;
  87699. private _formuparam;
  87700. private _stepsize;
  87701. private _tile;
  87702. private _brightness;
  87703. private _darkmatter;
  87704. private _distfading;
  87705. private _saturation;
  87706. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87707. updateShaderUniforms(): void;
  87708. get time(): number;
  87709. set time(value: number);
  87710. get alpha(): number;
  87711. set alpha(value: number);
  87712. get beta(): number;
  87713. set beta(value: number);
  87714. get formuparam(): number;
  87715. set formuparam(value: number);
  87716. get stepsize(): number;
  87717. set stepsize(value: number);
  87718. get zoom(): number;
  87719. set zoom(value: number);
  87720. get tile(): number;
  87721. set tile(value: number);
  87722. get brightness(): number;
  87723. set brightness(value: number);
  87724. get darkmatter(): number;
  87725. set darkmatter(value: number);
  87726. get distfading(): number;
  87727. set distfading(value: number);
  87728. get saturation(): number;
  87729. set saturation(value: number);
  87730. /**
  87731. * Serializes this starfield procedural texture
  87732. * @returns a serialized starfield procedural texture object
  87733. */
  87734. serialize(): any;
  87735. /**
  87736. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87737. * @param parsedTexture defines parsed texture data
  87738. * @param scene defines the current scene
  87739. * @param rootUrl defines the root URL containing startfield procedural texture information
  87740. * @returns a parsed Starfield Procedural BABYLON.Texture
  87741. */
  87742. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87743. }
  87744. }
  87745. declare module BABYLON {
  87746. /** @hidden */
  87747. export var woodProceduralTexturePixelShader: {
  87748. name: string;
  87749. shader: string;
  87750. };
  87751. }
  87752. declare module BABYLON {
  87753. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87754. private _ampScale;
  87755. private _woodColor;
  87756. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87757. updateShaderUniforms(): void;
  87758. get ampScale(): number;
  87759. set ampScale(value: number);
  87760. get woodColor(): BABYLON.Color3;
  87761. set woodColor(value: BABYLON.Color3);
  87762. /**
  87763. * Serializes this wood procedural texture
  87764. * @returns a serialized wood procedural texture object
  87765. */
  87766. serialize(): any;
  87767. /**
  87768. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87769. * @param parsedTexture defines parsed texture data
  87770. * @param scene defines the current scene
  87771. * @param rootUrl defines the root URL containing wood procedural texture information
  87772. * @returns a parsed Wood Procedural BABYLON.Texture
  87773. */
  87774. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87775. }
  87776. }